Consuming the Service in VS2005

Discussion about Schedules Direct grabber code and data formats.

Consuming the Service in VS2005

Postby jtpowell » Thu Aug 30, 2007 9:39 am

I get this error after adding the web service reference in VS 2005

Error 1 Custom tool error: Unable to import WebService/Schema. Unable to import binding 'xtvdBinding' from namespace 'urn:TMSWebServices'. Unable to import operation 'download'. Types must be declared at the top level in the schema. Please review schema type 'xtvdResponse' from namespace 'urn:TMSWebServices': element 'messages' is using anonymous type declaration, anonymous types are not supported with encoded SOAP. H:\docs\programming\dotnet\sharpTV\listings\Properties\Settings.settings 1 1 listings
jtpowell
 
Posts: 4
Joined: Thu Aug 30, 2007 8:41 am

Re: Consuming the Service in VS2005

Postby the_tom » Mon Sep 10, 2007 4:40 pm

jtpowell wrote:I get this error after adding the web service reference in VS 2005

Error 1 Custom tool error: Unable to import WebService/Schema. Unable to import binding 'xtvdBinding' from namespace 'urn:TMSWebServices'. Unable to import operation 'download'. Types must be declared at the top level in the schema. Please review schema type 'xtvdResponse' from namespace 'urn:TMSWebServices': element 'messages' is using anonymous type declaration, anonymous types are not supported with encoded SOAP. H:\docs\programming\dotnet\sharpTV\listings\Properties\Settings.settings 1 1 listings


Heh. When that vs2005 web service client stuff works, it is as slick as it gets. However, the MS stack (still) thinks the wsdl for this service is invalid, and won't take it.

I got my own (personal, non-distributed) VB 2005 Express client working again with the SD version of the service in about 4 hours of hacking at the SD wsdl, code gen with MS's wsdl.exe ute, and some consequent reorg of my own code. (No burden on the service - I had exactly one failed end-to-end test and that only downloaded about 320 program listings). Another hour as a "user" and I had a new schedule built and my (personal, non-distributed) capture sw is happy as ever.

The zap2it wsdl was the same, it didn't work with the MS stuff unless you hacked it a bit; so I guess you are just trying this for the first time - whereas I guess most home-use developers of zap2it got their stuff working with zap2it a long time ago and anybody using VS already knew it had problems. I could post details of the edits needed... but I hope you're not trying to develop a bridge into some prohibited commercial sw, or do anything else that would make a mess of this reprieve that we free-and-or-personal-use developers are all SO happy to have?

-tom-
the_tom
 
Posts: 15
Joined: Mon Sep 10, 2007 4:19 pm

Re: Consuming the Service in VS2005

Postby rmeden » Mon Sep 10, 2007 5:15 pm

sounds like it may be easier to just use XMLTV.EXE to get the data. :)

xmltv.exe tv_grab_na_dd --dd-data dd.xml --download-only.

(or you can let it convert to XMLTV format and parse that)

Robert
rmeden
SD Board Member
 
Posts: 1513
Joined: Tue Aug 14, 2007 2:31 pm
Location: Cedar Hill, TX

Re: Consuming the Service in VS2005

Postby whurlston » Mon Sep 10, 2007 5:41 pm

the_tom, I would be interested in knowing how you got it to work.
whurlston
 
Posts: 62
Joined: Thu Aug 16, 2007 10:43 pm

Re: Consuming the Service in VS2005

Postby the_tom » Tue Sep 11, 2007 7:23 am

rmeden wrote:sounds like it may be easier to just use XMLTV.EXE to get the data. :)
...
Robert


Perhaps, depending on one's starting point... but I rolled my own in support of the educational portion of the SD mission :lol:

-tom-
the_tom
 
Posts: 15
Joined: Mon Sep 10, 2007 4:19 pm

Re: Consuming the Service in VS2005

Postby jtpowell » Tue Sep 11, 2007 9:05 am

Please post the details! I'm writing something similiar to WebVcr+ in c# http://sourceforge.net/projects/sharptv
I figured it was the wsdl but haven't had time to hack away at it. I'd rather write my own then use xmltv
The reason I'm not planning on using xmltv is I want one executable for the user regardless of the platform they are on. When its all said and done (hopefully) if the platform supports .NET the user will just need that one executable without a lot of dependencies to download. I've not tested on Mac OSX but so far I've gotten everything to run on Windows XP and Linux by only changing a few system specific things in the ini file.
jtpowell
 
Posts: 4
Joined: Thu Aug 30, 2007 8:41 am

Re: Consuming the Service in VS2005

Postby neopelago » Tue Sep 11, 2007 9:27 am

rmeden wrote:sounds like it may be easier to just use XMLTV.EXE to get the data. :)
xmltv.exe tv_grab_na_dd --dd-data dd.xml --download-only.
(or you can let it convert to XMLTV format and parse that)
Robert


The ddClient I had been using to download from Zap2it until the end of last month would not work with SD (maybe an older version) so I have been using XMLTV that way with good results. Even a bit of nostalgia with good old DOS batch files.

But what I would really like to have is a simple java library with routines that would do just what that XMLTV function does, without any parsing or processing of the raw data. Then that library could be easily added to all kinds of hobbyist programs like mine to make
specification and downloads part of the programs rather than a separate chore.

How are chances of SD experts eventually creating such a library, or providing advice to anyone who might like to try?

Larry
neopelago
 
Posts: 16
Joined: Fri Aug 17, 2007 9:51 am

Re: Consuming the Service in VS2005

Postby the_tom » Tue Sep 11, 2007 9:58 am

whurlston wrote:the_tom, I would be interested in knowing how you got it to work.


OK, here goes.

The prior (zap2it-based) version of my own schedule downloader was written in VB.net but also relied on a dll built from the C# code that another developer had generated and posted in the zap2it forum. As he noted, some editing of the wsdl was needed to get the Microsoft stuff to accept it.

To work with Schedules Direct, I could have just edited that CS code - really only the URL changed. But I decided to start with the current wsdl and see what it took, to learn more about it; and I wanted it in VB anyway, since the rest of my project is VB and the Express versions do not support mixed-language solutions well. It took a few rounds of grappling with MS error messages, but now I have my reworked solution all in VB 2005 Express.

I emailed Schedules Direct to make sure they had no objection to my posting the details; they said they didn't see any problem, and I interpret the response as meaning that I can post the entire edited wsdl, not just my notes (if I have misinterpreted this, I'm sure the board admin can delete the attachment). Anyway, here are my detailed notes

It's a little more work than when the automagic support in VS works. Here's what I did:


1. Get a local copy of the wsdl/schema

a. Download the wsdl (the link is in this thread: viewtopic.php?f=8&t=41 ), and the two xml schema files that it uses (follow the URLs on the "includes" in the wsdl and in the first xsd)

b. Edit the wsdl and first xsd so they include the xml schema from files not urls (I did this thought I might have to edit the xsd's too; I didn't, and so you may not need to do this, if you don't the tools should fetch the schema from the web).


2. Edit the wdsl:

a. remove the 'xmlns="http://schemas.xmlsoap.org/wsdl/"' and then edit the places in operation acknowledge where the wdsl: namespace was left off the element names (input, output, fault in operation acknowledge). {this whole step also may not actually be required; I saw this inconsistency in how the wsdl was coded early in the process, and it confused me, I only guessed that maybe it was also confusing the MS stack; but if you do the first part you certainly need the second part}

b. Edit all the soap:body elements and change use="encoded" to use="literal"

c. Cut (as in, remove) the namespace attribute from the soap:fault name="webserviceFault" element

d. Paste that namespace attribute into the input and output elements nested under operation name="acknowledge"

e. Remove the attempted namespace prefix tms: from the name in soap:fault name="tms:webserviceFault"

f. Remove the xml:lang="en" attribute from the wsdl:documentation element

g. Change the type for the startTime and endTime elements of the downloadRequest message from tms:dateTime to xsd:string (see below)

h. Add style="rpc" attribute to the soap action for acknowledge.


3. Generate the code

You might be able to select that edited local copy of the wsdl in the full version of VS 2005; I'm not sure if it works with local files. Anyway the VS Express versions don't have that full integrated support for web services, so I used the command line tool insetad.

a. Start a shell with visual studio in the path (I used the menu item under VC++).

b. Switch to the project directory and run the wsdl.exe tool; my command line was

Code: Select all
wsdl /language:vb /namespace:ScheduleDirect /out:D:\projects\vsx2005\vb\RoboSched2 m_tvDataDelivery.wsdl

Repeated cycles running this wsdl.exe tool, and staring at its error messages, led to the edits detailed in the prior section. (And, yeah, I missed the second "s" in SchedulesDirect.)


4. Incorporate the code into my project

a. I removed the reference to my old dll and added a reference to the System.Webservices assembly and the added the generated vb code file from the step above.

b. Instantiate generated classes and use to access the service. The generated code provides a full object model providing a strongly typed representation of the service's document structures, and an xtvdWebService class that does the work of interacting with the web service. There are just two "tricks" to it: you have to format the date-time parameters correctly, and you have to prepare and set the credential used to log on. I could not see any way to get the MS generated and inherited code to format the start and end times correctly when it knew they were date-time types: it was stuck at local time and would not put the Z on the end. There may be a clever way to subclass or configure something to get it to work, but I didn't see it, and you can't just edit the generated VB code to do the formatting, because then it fails in the internals of some inherited method; which is why I had to change the datatype to string in my local copy of the wsdl.)

My code to get data from the web service looks like this (with possible typos, I extracted this from several methods and edited for clarity; username, password, startTime, endTime are all input parameters here):

Code: Select all
Dim zws As ScheduleDirect.xtvdWebService = New ScheduleDirect.xtvdWebService()
Dim cred As System.Net.ICredentials = New System.Net.NetworkCredential(username, password, String.Empty)
zws.Credentials = cred
Dim startString As String = startTime.ToUniversalTime().ToString("yyyy-MM-dd\THH:mm:ss\Z", System.Globalization.CultureInfo.InvariantCulture)
Dim endString As String = endTime.ToUniversalTime().ToString("yyyy-MM-dd\THH:mm:ss\Z", System.Globalization.CultureInfo.InvariantCulture)
Dim downloadResults As xtvdResponse = zws.download(startString, endString)

c. and the response doc (downloadResults object) has two properties, a string array of all messages in the response, and an xtvd object with the downloaded data; etc; you can follow it easily in the code, or more easily in the debugger, the nested object structures simply mirrors the document as defined in the schema.

HTH,

-tom-
the_tom
 
Posts: 15
Joined: Mon Sep 10, 2007 4:19 pm

Re: Consuming the Service in VS2005

Postby the_tom » Tue Sep 11, 2007 10:05 am

The attachment did not seem to work, trying again.

{Edit: nope, I still don't see it. Is it broken, or is it cached waiting for editorial review, or ???}
the_tom
 
Posts: 15
Joined: Mon Sep 10, 2007 4:19 pm

Re: Consuming the Service in VS2005

Postby rmeden » Tue Sep 11, 2007 10:38 am

{Edit: nope, I still don't see it. Is it broken, or is it cached waiting for editorial review, or ???}

Attachements are turned off... we don't want folks using this for software distributions at the moment. A <code> segment should work.

Robert
rmeden
SD Board Member
 
Posts: 1513
Joined: Tue Aug 14, 2007 2:31 pm
Location: Cedar Hill, TX

Next

Return to Developers Corner

Who is online

Users browsing this forum: No registered users and 5 guests

cron