InvokeHttp method returns binary contents, it is up how you are further processing the result that matters.
Since your service returns JSON, and Teiid does not have any JsonTable construct like XMLTable construct in 6.4.5 you would need to convert JSON to XML using JSONtoXML function and then use XMLTable to parse the contents.
I know that. But I want to use the OData translator and in the browser the webservice returns XML content. Therefore I was confused about the error I got.
With the WS translator I currently use I use the InvokeHttp method indeed.
Mendix documentation in question, Mendix only has OData3, I thought using OData4 would solve that?:
Basically an OData service returns the payload based on the "Accept:" header that an HTTP client sends. In the case of the browser, it automatically defaults to XML, thus you are seeing an XML formatted response. If you were calling through "invokeHTTP" and did not add in any headers then the OData service chooses whatever default it is configured with, which in this case looks like JSON. You in order to get XML response you need to add the "Accept" header to your request
call invokeHttp(... headers=>jsonObject('application/json' as "Accept")
Thanks for the explanation.
So how do I tell a source model table in Teiid designer to "call invokeHttp....."?
Because I don't want to use a PRC that calls invokeHttp, I want to use the provided OData translator which automatically creates a source model for me based on the OData webservice.
I would assume that this OData translator figures out for me whether to use XML or JSON and automatically sends the correct headers.
I think you misunderstand what I want to achieve and when I get the error. I have absolutely no problem consuming the OData (or whatever webservice) service using the invokeHttp using the WS translator, I made myself a program that autogenerates this for me using the metadata of a webservice. However, I do have trouble consuming an OData webservice that I constructed using the Teiid Connection to my server which then autocreates a source model including all tables with their columns and types; even primary keys.
Below is a working example which consumes Sap SuccessFactors (using either the sap-gateway or odata translator):
As you can see, there is no invokeHttp, at least as far as I can tell not directly visible in my development environment.
I might miss something but how can I tell my Mendix source model to send a header to the OData webservice to provide me with XML content?
>However, I do have trouble consuming an OData webservice that I constructed using the Teiid Connection to my server which then autocreates a source model including all tables with their columns and types; even primary keys.
So you are consuming from OData service called Mendix on back end service using Teiid's OData translator. Then you are using the Teiid JDBC connection to connect to the Mendix based VDB and building your own OData service on top of it? Do I have that right?
If yes, Why not use the OData API Teiid exposes already over any VDB?
The setup is as follows.
I created a datasource (resource adapter) on my server which I gave the odata translator and the base url of the odata webservice (e.g. https://api5.successfactors.eu/odata/v2/ or something ending at /odata4/).
Then in Teiid Designer I start the server. The I select Import -> Teiid Connection -> the just created datasource -> Select the OData translator -> Let this create a source model (based on the metadata) for me automatically; this source model contains all tables, columns and even primary keys.
This works almost flawlessly with for example Sap SuccessFactor except only some trouble with automatically converting dates (but we do that in our virtual base layer). When I follow the same steps for the Mendix OData webservice I get the source model with all the tables. However, when I try to access the data using either preview or a newly created VDB I get the error mentioned in the first post.
To be honest, I didn't know I could consume a OData webservice this way with Teiid until 2 months ago and since this looks like the way to go because it can query the webservice in a more efficient way.
Ok, that is more clear. I think your Mendix OData service is not capable of returning the payload in XML perhaps? The Teiid's OData translator uses the XML format for reading the entities. You can easily check this by attaching "?$format=xml" to end of query on a web browser. for ex: http://<mendix>/service/entityName?$formamat=XML then see what is returned?
That is just the weird part. By default it returns XML content in the browser. But I will try you suggestion to see what it does. It might that it doesn't understand the format= option.