9 Replies Latest reply on Mar 15, 2010 9:58 AM by John Doyle

    XML Connector

    jose luis Newbie

      Hello,

       

      I'm new in Teiid and i'm trying to make something:

       

      I want to connect my model in Teiid with and REST Web Service (Atom service).

       

      I have follow the next steps:

       

      1 - I have created a Model Proyect

      2 - I have imported "XML Schema as Relational Source Model"

           - I select the xsd of Atom format

      3 -  I have created a "XML-Relational File Connector", so the xml response of REST Service in atom format was stored in filesystem  (for this example).

      4 - I have created a vdb with the model

      5 - I have executed the vdb and i received empty results any query

       

       

      Are there the correct steps? Who i can create and model connected with a rest web service?

       

      Thanks in advanced!

        • 1. Re: XML Connector
          Ramesh Reddy Master

          Jose,

           

          We currently do not support REST at Connector level as source. We have support for SOAP, FILE, HTTP. You can try to fit HTTP XML connector, but now sure how well that will work.

           

          If you are interested in this feature, please create a JIRA, we will try to schedule into our upcoming releases.

           

          Thanks.

           

          Ramesh..

          • 2. Re: XML Connector
            Ken Johnson Newbie
            Regarding the HTTP connector, it may be useful depending on the nature of the requests.   Is it a simple GET with query parameters (e.g. http://foo.org/bar?customer=smith) or does the REST service take a full URL (e.g.  http://foo.org/bar/customer/smith)?  Both are possible, the first is relatively easy but the second is case is more complicated.  . Also it greatly expedites the modeling process if you have an XSD that describes the response XML.  In that case you can use the XSD as Relational Source Model import wizard in the Teiid Designer tooling.
            • 3. Re: XML Connector
              jose luis Newbie

              I have created a Relational Source Model from a xsd that describe the xml with the data, and i have created a XML-Relational HTTP Connector to a URL (GET with parameters) that return the xml.

               

              But when i executed the query, i received 0 rows in the response.

               

              What do you think about this?

               

              The URL is something this:

               

              http://localhost:8080/test/select?wt=xslt&format=atom

               

              The xsd is something this:

               

              <?xml version="1.0" encoding="UTF-8" ?>
              
              <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
                <xs:element name="author">
                  <xs:complexType>
                    <xs:sequence>
                      <xs:element ref="name" />
                      <xs:element ref="email" />
                    </xs:sequence>
                  </xs:complexType>
                </xs:element>
              
                <xs:element name="email">
                  <xs:complexType mixed="true" />
                </xs:element>
              
                <xs:element name="entry">
                  <xs:complexType>
                    <xs:sequence>
                      <xs:element ref="title" />
                      <xs:element ref="link" />
                      <xs:element ref="id" />
                      <xs:element ref="summary" />
                      <xs:element ref="updated" />
                    </xs:sequence>
                  </xs:complexType>
                </xs:element>
              
                <xs:element name="feed">
                  <xs:complexType>
                    <xs:sequence>
                      <xs:element ref="title" />
                      <xs:element ref="subtitle" />
                      <xs:element ref="author" />
                      <xs:element ref="link" />
                      <xs:element ref="updated" />
                      <xs:element ref="id" />
                      <xs:element ref="entry" />
                    </xs:sequence>
                  </xs:complexType>
                </xs:element>
              
                <xs:element name="id">
                  <xs:complexType mixed="true" />
                </xs:element>
              
                <xs:element name="link">
                  <xs:complexType>
                    <xs:attribute name="rel" type="xs:NMTOKEN" use="optional" />
                    <xs:attribute name="href" type="xs:string" use="required" />
                    <xs:attribute name="type" type="xs:string" use="optional" />
                  </xs:complexType>
                </xs:element>
              
                <xs:element name="name">
                  <xs:complexType mixed="true" />
                </xs:element>
              
                <xs:element name="subtitle">
                  <xs:complexType mixed="true" />
                </xs:element>
              
                <xs:element name="summary">
                  <xs:complexType mixed="true" />
                </xs:element>
              
                <xs:element name="title">
                  <xs:complexType mixed="true" />
                </xs:element>
              
                <xs:element name="updated" type="xs:string" />
              
              </xs:schema>

               

               

              And the xml is something this:

               

              <?xml  version="1.0" encoding="utf-8" ?>
              <title>Example Feed</title>
              <subtitle>This has been formatted by the sample Atom feed.</subtitle>
              - <author>
              <name>John</name>
              <email>john@test.org</email>
              </author>
              <link rel="self" type="application/atom+xml" href="http://localhost:8080/test/select?wt=xslt&format=atom" />
              <updated />
              <id>tag:localhost,2007:example</id>
              - <entry>
              <title>Example Feed</title>
              <id>tag:localhost,2007:S</id>
              <summary>This is an example</summary>
              <updated />
              </entry>
              </feed>

               

               

              Thanks in advanced!

              • 4. Re: XML Connector
                John Doyle Apprentice

                In your connector binding there is a property to 'Log the Request and Response document".  Try turning that property to true to validate that you're actually getting the document back.  If you find the document in the log, then it's a problem with the model not pulling data from the doc, and we should be able to fix the model.  If you're not getting the doc the, log should contain the info about the URL you are hitting, and you should be able to vaidate if it's correct or not.  We can fix that too with model or binding changes.

                 

                ~john

                • 5. Re: XML Connector
                  John Doyle Apprentice
                  Also, what's your query look like.
                  • 6. Re: XML Connector
                    jose luis Newbie

                    I chaged the "Log XML Request and Response Documents" property true, and executed the query (select mmid, title, subtitle, author_name, author_email, link_href, link_rel, link_type, updated, id, entry_title, entry_link_href, entry_link_rel, entry_link_type, entry_id, entry_summary, entry_updated from "myvdb"."mymodel.feed"), but the log is empty.

                     

                    I'm not be able to see what`s happened and where is the error.

                     

                    Some ideas?

                     

                    Thanks!

                    • 7. Re: XML Connector
                      John Doyle Apprentice

                      If the log is 'empty' you've got bigger problems than the connector not working. 

                       

                      Are you executing this in designer?  If so, try getting the log by clicking the 'Set log level' button in the Connections view, setting it to trace, executing your query, and then clicking the 'Open Log' button.  You can paste the results here.

                       

                      ~john

                      • 8. Re: XML Connector
                        jose luis Newbie

                        Yes, i'm using Eclipse Teiid Designer, but, I don't find that options.

                         

                        I attach an screenshot of the connections tab.

                         

                        Thanks

                        • 9. Re: XML Connector
                          John Doyle Apprentice

                          You're right, those buttons have disappeared from 6.3.  Strange, not sure why they were taken out.  No matter, you can get the log from the filesystem.  Take a look in your workspace (the directory where here the projects are saved) and look in the .metadata/.plugins/org.teiid.designer.dqp/logs directory.  In there you should find a number of logs.  You should find the info in there.

                           

                          ~john