10 Replies Latest reply on Apr 11, 2017 8:46 AM by rareddy

    Odata support with TEIID issue

    wickram09

      Hi,

       

      I am accessing the teiid with odata support

       

      http://localhost:8080/odata/webservice/Customers.CustomersView

       

      where webservice is a vdb, Customers is model name and CustomersView is my view name.

      using restEasy client but i am getting below error

      <html><head><title>Error</title></head><body>Forbidden</body></html>

       

      i am using correct credentials user and id.

      BUT using simpleclient query --

      mvn exec:java -Dvdb="webservice" -Dsql="select * from Customers.CustomersView" -Dusername="app" -Dpassword="password"

      i am able to get the result.

       

      not via odata url.

       

      Please look if somebody can assist.

       

      Thanks,

      wickram

        • 1. Re: Odata support with TEIID issue
          rareddy

          Did you try it using a browser issuing the same request? I suspect some issue in passing credentials in your Resteasy client.

          • 2. Re: Odata support with TEIID issue
            wickram09

            Yes Ramesh I tried using browser as well but getting same issue

            • 3. Re: Odata support with TEIID issue
              rareddy

              Well that does not make any sense. What is the Teiid version you are using? In Teiid 9.1 on wards we removed the OData V2 support, so you can try the OData V4 and see if that works for you. The equivalent URL for that would be

               

              http://localhost:8080/odata4/webservice/Customers/CustomersView 

              • 4. Re: Odata support with TEIID issue
                jdurani

                Your user needs to have role 'odata' assigned.

                 

                One more question. Did you modified web.xml descriptor of teiid-odata.war in any way?

                • 5. Re: Odata support with TEIID issue
                  wickram09

                  yes got it and working fine 

                   

                  thanks.

                   

                  one more issue is:

                  i have rest service which is returning a JSON response i  am creating a view and fetching  json response in VDB like below---

                  (EXEC CustomerSource.invokeHttp('GET', null, '<URL>', 'TRUE'))

                       AS f, XMLTABLE('/data' PASSING JSONTOXML('data', f.result) COLUMNS

                           id string PATH 'id/text()',.....

                   

                  IS IT correct format for JSON??

                  and

                  VDB is deployed and active but i am not getting data in this view.

                   

                  using simpleclient getting below exception--

                  [WARNING]

                  java.lang.reflect.InvocationTargetException

                      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

                      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                      at java.lang.reflect.Method.invoke(Method.java:606)

                      at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:297)

                      at java.lang.Thread.run(Thread.java:745)

                  Caused by: org.teiid.jdbc.TeiidSQLException: TEIID20018 Unable to find a component used authenticate on to Teiid

                      at org.teiid.jdbc.TeiidSQLException.create(TeiidSQLException.java:135)

                      at org.teiid.jdbc.TeiidSQLException.create(TeiidSQLException.java:71)

                      at org.teiid.jdbc.SocketProfile.connect(SocketProfile.java:66)

                      at org.teiid.jdbc.TeiidDriver.connect(TeiidDriver.java:107)

                      at org.teiid.jdbc.TeiidDriver.connect(TeiidDriver.java:55)

                      at java.sql.DriverManager.getConnection(DriverManager.java:571)

                      at java.sql.DriverManager.getConnection(DriverManager.java:215)

                      at JDBCClient.getDriverConnection(JDBCClient.java:70)

                      at JDBCClient.main(JDBCClient.java:59)

                      ... 6 more

                  Caused by: org.teiid.net.CommunicationException: TEIID20018 Unable to find a component used authenticate on to Teiid

                      at org.teiid.net.socket.SocketServerConnection.selectServerInstance(SocketServerConnection.java:147)

                      at org.teiid.net.socket.SocketServerConnection.<init>(SocketServerConnection.java:95)

                      at org.teiid.net.socket.SocketServerConnectionFactory.getConnection(SocketServerConnectionFactory.java:316)

                      at org.teiid.jdbc.SocketProfile.connect(SocketProfile.java:64)

                   

                   

                  thanks,

                  wickram09

                  • 6. Re: Odata support with TEIID issue
                    rareddy

                    Yes, that looks right. Basically you convert the JSON payload into XML format and use the XMLTABLE construct to parse it into tabular data. On the exception, it looks like your VDB is not ACTIVE or connecting to wrong VDB name.

                    • 7. Re: Odata support with TEIID issue
                      wickram09

                      thanks ramesh.

                       

                      i am not getting correct example of ODATA POST method call in VDB.

                      In VDB I marked OPTIONS (UPDATABLE 'TRUE') and calling a webservice using GET method

                      data is populating using odata get method  but POST is not working

                      I tried but getting below exception

                       

                      {

                      "error":

                      {

                       

                      "code": null

                      "message": "TEIID30492 Metadata does not allow updates on the group: .CustomersView"

                      }

                      }

                      Pls assist with any example for POST method with support Odata.

                       

                      Thanks,

                      wickram

                      • 8. Re: Odata support with TEIID issue
                        rareddy

                        Wickram,

                         

                        The error message saying that you do not have UPDATABLE 'TRUE' on your CustomersView table. So, the issue is not POST, the issue is not able to update because of metadata. You can try using SQL client and issue a UPDATE against the CustomersView you will see the same error.

                         

                        Ramesh..

                        • 9. Re: Odata support with TEIID issue
                          wickram09

                          hi ramesh i made it UPDATABLE 'TRUE' and tried but same issue.

                           

                          Another issue i am facing is:

                          {

                          "error":

                          {

                           

                          "code": null

                          "message": "TEIID30171 Unexpected multi-valued result was returned for XMLTable column "id". Path expressions for non-XML type columns should return at most a single result."

                          }

                          }

                           

                          If I have multiple values in JSON for same feild then how to fetch it in a view from rest webservice.

                          I am trying but getting above exception.

                          Is it possible in teiid with odata to get multiple values for a particular field fro rest as a webservice json format???

                           

                          thanks,

                          wickram

                          • 10. Re: Odata support with TEIID issue
                            rareddy

                            I would need to see your VDB for your update issue. You can attach the XML version of the VDB to the issue.

                             

                            On the multiple values issue, it is not a OData issue, it is your View design issue. You need to have your root of the document on XMLTABLE as the parent element where the multiple values exist. If you need ancestor values use "../???" in your XPATH for the fields.