-
1. Re: RESTful web service error: Unexpected multi-valued result
rareddy Jun 9, 2014 9:28 AM (in response to sarin_ashish)Ashish,
This typically means that your root where you are starting is higher level. Change the XML root to "/CUSTOMERList/CUSTOMER" and give it a try.
SELECT A.CUSTOMER AS CUSTOMER FROM (EXEC Customer.invokeHttp('GET', null, 'http://www.thomas-bayer.com/sqlrest/CUSTOMER/', 'TRUE')) AS f, XMLTABLE(XMLNAMESPACES('http://www.w3.org/1999/xlink' AS xlink), '/CUSTOMERList/CUSTOMER' PASSING XMLPARSE(DOCUMENT f.result) COLUMNS CUSTOMER string PATH 'text()') AS A
Ramesh..
-
2. Re: RESTful web service error: Unexpected multi-valued result
sarin_ashish Jun 10, 2014 4:01 AM (in response to rareddy)It didn't work; i got the same exception again. Can you also let me know how Teiid deals with RESTful web services that return JSON or may be simple text?
regards
ashish
-
3. Re: Re: RESTful web service error: Unexpected multi-valued result
rareddy Jun 10, 2014 8:16 AM (in response to sarin_ashish)You must be doing something else wrong then, I copied above from my working copy from your endpoint where I could get results fine. I attached my Desinger project to this thread.
If you need to deal with JSON, use function JSONTOXML, to convert the results to XML then use XMLTABLE construct to read contents out. Check the documentation on JSONTOXML.
Ramesh..
-
customer.zip 8.7 KB
-
-
4. Re: RESTful web service error: Unexpected multi-valued result
shawkins Jun 10, 2014 8:18 AM (in response to sarin_ashish)1 of 1 people found this helpfulWith the sql that Ramesh provided, it's not possible to get that exception. The message is indicating that from once the column expression is evaluated relative to the root xquery you are getting a sequence back, not a single value. For example with the doc:
{code}
<a>
<b x="1"/>
<b x="2"/>
</a>
{code}
The xmltable:
{code}
XMLTABLE('/a' PASSING doc COLUMNS x string PATH 'b/@x')
{code}
Will throw an exception because you are saying "for each a make the the string column value for x to b/@x" - however for the root a, there are two values for the attribute x.
Where as:
{code}
XMLTABLE('/a/b' PASSING doc COLUMNS x string PATH '@x')
{code}
Will be fine because the context is now the b element which does have a single x attribute value. You can even do things like selecting a single element out of the children if that is more appropriate:
{code}
XMLTABLE('/a' PASSING doc COLUMNS x string PATH 'b[1]/@x')
{code}
> Can you also let me know how Teiid deals with RESTful web services that return JSON or may be simple text?
JSON is primarily handled through the JSONToXML function, with the resultant XML then processed in xmltable. Simple text presumably means something structured which would be processed by texttable as delimited or fixed width content.
-
5. Re: RESTful web service error: Unexpected multi-valued result
sarin_ashish Jun 11, 2014 2:12 AM (in response to shawkins)Thanks. Is there any documentation which talks about how to consume a RESTful web service that returns JSON. The Import -> File Source(XML) >> Source and View Model option only allows us to consume a RESTful web service that returns XML.
regards
ashish
-
6. Re: RESTful web service error: Unexpected multi-valued result
shawkins Jun 11, 2014 8:29 AM (in response to sarin_ashish)Moved to Designer as that has been the context for your questions. You can see more on JSONTOXML at JSON Functions - Teiid 8.8 (draft) - Project Documentation Editor but you'll want someone from Designer to weigh in on what design time aids may be available.
-
7. Re: RESTful web service error: Unexpected multi-valued result
rareddy Jun 11, 2014 8:54 AM (in response to sarin_ashish)You can see the discussion about this in the community https://community.jboss.org/message/870385