locked
Using WSDL Web Service from Metro app supported? RRS feed

  • Question

  • As a test app for Metro, I want to code up a little notifier for the Washington State Ferries.  Turns out that WSDOT exposes the ferry information as WSDL web services - for instance, see http://b2b.wsdot.wa.gov/ferries/terminals/default.asmx?WSDL

    Here's what I did:

    * Downloaded this WSDL

    * Started a Developer Command Prompt on my prototype BUILD hardware

    * Ran

    wsdl /language:CS /n:MyFerry.WSF /out:WSFTerminals2.cs xxxx.wsdl

    Where the xxxx.wsdl is the WSDL downloaded from the URL above.  It generated a WSDL proxy which I added to my VS 11 project and built.  Problems:

    PROBLEMS:

    * There are numerous missing assemblies - I added these from C:\WINDOWS\MICROSOFT.NET\Framework64\v4.0.30319 (System.XML, System.Web.Services, System.ComponentModel).  Is that OK?

    * Got lots of compile errors for two attributes:

     


    // REMOVED - [System.SerializableAttribute()]
    // REMOVED - [System.ComponentModel.DesignerCategoryAttribute("code")]

    - Just commented out these attributes as shown to see what would happen (the designer hint one I'm not concerned about; the XmlSerializable I'm not as sure about)

    - After doing this, I'm down to these errors:

    c:\Windows\Microsoft.NET\Framework64\v4.0.30319\System.Web.Services.dll : warning CS1684: Reference to type 'System.ComponentModel.Component' claims it is defined in 'c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETCore\v4.5\System.dll', but it could not be found
    c:\Windows\Microsoft.NET\Framework64\v4.0.30319\System.Web.Services.dll : error CS0011: The base class or interface 'System.ComponentModel.Component' in assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' referenced by type 'System.Web.Services.Protocols.WebClientProtocol' could not be resolved
    WSFTerminals2.cs(655,28,655,40): error CS0234: The type or namespace name 'XmlAttribute' does not exist in the namespace 'System.Xml' (are you missing an assembly reference?)
    WSFTerminals2.cs(669,27,669,39): error CS0234: The type or namespace name 'XmlAttribute' does not exist in the namespace 'System.Xml' (are you missing an assembly reference?)
    WSFTerminals2.cs(668,35,668,59): error CS0234: The type or namespace name 'XmlAnyAttributeAttribute' does not exist in the namespace 'System.Xml.Serialization' (are you missing an assembly reference?)
    WSFTerminals2.cs(668,35,668,59): error CS0234: The type or namespace name 'XmlAnyAttributeAttributeAttribute' does not exist in the namespace 'System.Xml.Serialization' (are you missing an assembly reference?)

    Any ideas?  Is using a WSDL service via proxy from a Metro app supported?

    Thursday, September 15, 2011 9:55 PM

Answers

  • Mike, thanks for trying out the bits.

    The original .NET 1.x asmx-based Web Reference proxies are not supported in Metro style apps, hence why you get build errors when you trying to consume the WSDL.exe generated code. Also adding references to .NET Framework assemblies, although seemly quasi-working today, will not work in future versions and will not run, so please don't rely on that.

    That above web service provides four end points, out of which only the SOAP 1.1 end point is supported by Add Service Reference (right-click on a project and choose Add Service Reference) in Metro style apps. In saying that, however, it appears that there is a bug today in the web service proxy generation that causes it generate code that will not build (I've filed a bug internally to track it).

    A workaround should be remove the offending constructor that fails to build (unfortunately, you'll need to do that everytime you regenerate the code), and to pass an instance BasicHttpBinding and EndpointAddress to one of the constructors of the WSFTerminalsSoapClient.

    Regards

    David

     

     

     

     

     

     


    Base Class Library Team (BCL) | My Blog: http://davesbox.com

    Thursday, September 15, 2011 11:57 PM

All replies

  • Mike, thanks for trying out the bits.

    The original .NET 1.x asmx-based Web Reference proxies are not supported in Metro style apps, hence why you get build errors when you trying to consume the WSDL.exe generated code. Also adding references to .NET Framework assemblies, although seemly quasi-working today, will not work in future versions and will not run, so please don't rely on that.

    That above web service provides four end points, out of which only the SOAP 1.1 end point is supported by Add Service Reference (right-click on a project and choose Add Service Reference) in Metro style apps. In saying that, however, it appears that there is a bug today in the web service proxy generation that causes it generate code that will not build (I've filed a bug internally to track it).

    A workaround should be remove the offending constructor that fails to build (unfortunately, you'll need to do that everytime you regenerate the code), and to pass an instance BasicHttpBinding and EndpointAddress to one of the constructors of the WSFTerminalsSoapClient.

    Regards

    David

     

     

     

     

     

     


    Base Class Library Team (BCL) | My Blog: http://davesbox.com

    Thursday, September 15, 2011 11:57 PM
  • VS11 Express for Windows Developer Preview does not have an "Add Service Reference". What now???
    Thursday, October 20, 2011 5:19 AM
  • Add Service Reference (WCF) is supported, the old Add Web Reference (ASMX services) however is not.
    Base Class Library Team (BCL) | My Blog: http://davesbox.com
    Thursday, October 20, 2011 5:24 AM
  • I'm looking at using a web reference as well, so I want to ask how do I consume a wsdl for a Metro app?
    Sunday, February 12, 2012 1:16 AM
  • Have you tried consuming it via Add Service Reference (right-click on a project and choose Add Service Reference)?

    Base Class Library Team (BCL) | My Blog: http://davesbox.com

    Sunday, February 12, 2012 4:16 PM
  • Sorry about not getting back as quickly as you got back to me.  Yes, I tried that but not all of the methods are available when I add it as a service reference.  Viewing it in the object browser confirmed that some of the methods are not there.

    I am able to use it in the APIs sample.  The sample is a VS2010 project with the wsdl already added as a web reference.  Upgrading that project in VS 11 works and the project works successfully.  You mentioned that "Adding references to .NET Framework assemblies, although seemly quasi-working today, will not work in future versions and will not run, so please don't rely on that."  Does that mean that this won't work in the future in VS11?

    Is there any way I can safely use these wsdls in my Metro app?

    Thursday, February 16, 2012 5:12 AM
  • I am also trying to reference a Web Service in a metro style app and not all the methods come across. I noticed that the WebMethods that have an out param do not come across in the reference. Besides this issue, even the ones that come across, the client code to use/call them is not just doing a new on the XYZSoapClient class and invoking them via the instance, which is the way one of the article/response in this forum suggests. Rather it looks like one has to cast the class instance to the interface and then invoke them.

    Waiting for your response. Thanks

    -Kasim


    -Kasim

    Monday, February 27, 2012 4:17 PM
  • Hi, I'm also trying to add a web service to my metro application and with some methods I'm getting the following exception message: "Error in deserializing body of reply message for operation". Also the file app.config is not generated after I add the service reference from my wsdl file. How can I fix this? Thanks!
    Thursday, April 19, 2012 9:02 PM
  • I am trying to use VS2012 Pro to add a service reference using the National Weather Service's WSDL: http://graphical.weather.gov/xml/DWMLgen/wsdl/ndfdXML.wsdl

    As of today, the operations I need to access show when I click on the Go button in the Add Service Reference dialog and then, in the Services list box (on the left), I expand the node for ndfdXML and then further expand ndfdXMLPortType.

    However, after generating all of the files and compiling, the only place these operations/methods exist is in the .wsdl file. Perhaps I am missing the boat here, since I may have to do some translation of xsd (which I am not very knowledgeable about yet), but the guidance is a wee bit foggy in the area of calling Soap services from Windows 8 Store apps.

    I was able to follow the example here http://blogs.msdn.com/b/piyushjo/archive/2011/09/22/wcf-in-win8-metro-styled-apps-absolutely-supported.aspx using a different web service for weather, but I have a stronger desire to use the NWS Database for other reasons.

    I've also tried using WSDL.exe (after following some fairly stale online examples) and there were references generated that didn't work. However, that approach works for this example: http://www.codeproject.com/Articles/10231/How-to-Add-a-5-Day-Forecast-to-your-Website. Can I use that program to generate the proxy if I get a reference to the WSE SDK?

    Thanks, HAL_2010 ("Dave? Will I dream?")

    Monday, September 17, 2012 6:22 PM