Accessing data using raw XML

Discussion about Schedules Direct grabber code and data formats.

Accessing data using raw XML

Postby Jenny » Sat Jan 19, 2008 4:13 pm

I'm trying to learn about accessing the grid data on a low level (raw SOAP). Unfortunately I don't have access to any SOAP frameworks, so I'm trying to access TMS' server using Microsoft's XMLHttp object from script, passing it XML that I built up "manually".

I keep getting a 500 (Internal server error) response. Any ideas on what's going wrong?

Here's the script. It's in WinBatch, which isn't exactly a mainstream language, but when it comes to accessing COM objects it's pretty similar to VBS, etc. on a Windows environment:

Code: Select all
sSOAPUrl = "http://webservices.schedulesdirect.tmsdatadirect.com/schedulesdirect/tvlistings/xtvdService"
sSOAPRq = (built up over several lines, but here's the whole string after I dumped it to a text file (between the dashes):)
--------------------------------------
<?xml version=1.0 ?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
                   SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
   <SOAP-ENV:Body>
      <m:download xmlns:m="urn:TMSWebServices">
         <m:startTime>2008-01-19T14:50:35Z</m:startTime>
         <m:endTime>2008-01-20T14:50:35Z</m:endTime>
      </m:download>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
--------------------------------------

oXML = ObjectOpen ("MSXML2.XMLHTTP")
oXML.open ("POST", sSOAPUrl, @FALSE, "my sd username", "my sd password")
oXML.setRequestHeader ("Content-length", strlen(sSOAPRq))
oXML.setRequestHeader ("Content-type", "text/xml")
oXML.setRequestHeader ("SOAPAction", "urn:TMSWebServices:xtvdWebService#download")

oXML.send (sSOAPRq)

if (oXML.status!=200)
   gosub BuildErrorLine
else
   sXML = oXML.responseText ()
        etc. etc.......
endif


I'd be surprised if the problem was in the POSTDATA itself, because if that had an error I'd expect to get a SOAP fault message as my return body. So I don't think the server got that far.

Apparently we can't access any of TMS' documentation, so I sort of have to wing it...

TIA!
Jenny
Seattle
Jenny
 
Posts: 2
Joined: Sat Jan 19, 2008 3:28 pm

Re: Accessing data using raw XML

Postby rmeden » Sat Jan 19, 2008 4:44 pm

I've noticed the TMS service often give internal errors when there's something it doesn't understand....

Try this:
Code: Select all
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <SOAP-ENV:Body>
      <m:download xmlns:m="urn:TMSWebServices" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
         <startTime xsi:type="xsd:dateTime">2008-01-22T19:00:00Z</startTime>
         <endTime xsi:type="xsd:dateTime">2008-01-23T21:00:00Z</endTime>
      </m:download>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
rmeden
SD Board Member
 
Posts: 1505
Joined: Tue Aug 14, 2007 2:31 pm
Location: Cedar Hill, TX

Re: Accessing data using raw XML

Postby Jenny » Sat Jan 19, 2008 5:56 pm

rmeden wrote:I've noticed the TMS service often give internal errors when there's something it doesn't understand....

Try this:

Cool, that worked!

So, I started stripping items out from what you sent me, and I ended up with this minimal query that still worked:

Code: Select all
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Body>
      <m:download xmlns:m="urn:TMSWebServices">
         <startTime>2008-01-19T16:41:33Z</startTime>
         <endTime>2008-01-19T17:41:33Z</endTime>
      </m:download>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

I probably got one of the initial namespace declarations wrong in my earlier attempt, but it seems the real problem was putting the "m" prefix on the download parameters & not just the operation name.

Thanks for the help! (And congrats on SD - it's a very cool service.)
Jenny
 
Posts: 2
Joined: Sat Jan 19, 2008 3:28 pm

Re: Accessing data using raw XML

Postby brianboonstra » Sat Feb 14, 2009 2:56 pm

I wanted to use nothing but the command line. Based on http://curl.haxx.se/mail/lib-2005-04/0168.html, I managed to use wget to grab the raw XML. First you create an XML file named soap.xml containing the request, as in
Code: Select all
<?xml version='1.0' encoding='utf-8'?> <SOAP-ENV:Envelope
xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns:SOAP-ENC='http://schemas.xmlsoap.org/soap/encoding/'>
        <SOAP-ENV:Body>
                <ns1:download xmlns:ns1='urn:TMSWebServices'>
                        <startTime xsi:type='xsd:dateTime'>2009-02-15T00:00:00Z</startTime>
                        <endTime xsi:type='xsd:dateTime'>2009-02-17T00:06:00Z</endTime>
                </ns1:download>
        </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

(don't forget to substitute the dates you actually care about here)

then you use wget to get the data, using the following:
Code: Select all
wget --debug --http-user='my_sd_username' --http-passwd='my_sd_passwd' --post-file='soap.xml' --header='Accept-Encoding:gzip' http://webservices.schedulesdirect.tmsdatadirect.com/schedulesdirect/tvlistings/xtvdService --output-document=tv.gz


This results in a compressed filed tv.gz containing the data. You have to use gzcat or gunzip or the like to see the contents.
brianboonstra
 
Posts: 1
Joined: Sat Feb 14, 2009 2:43 pm

Re: Accessing data using raw XML

Postby baldwin5881 » Sun Apr 19, 2009 10:59 am

Jenny,

I was looking through the XML that you had listed originally, and I believe the issue you were having was probably caused by a trailing '/' in your Soap Envelope element. This would probably cause an issue with the XML parser, as it would be interpretted the same as having a close tag immediately after. The line with the extra '/' is listed below:

Code: Select all
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
                   SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
baldwin5881
 
Posts: 1
Joined: Sun Apr 19, 2009 10:50 am


Return to Developers Corner

Who is online

Users browsing this forum: No registered users and 3 guests

cron