Creating a .NET class file from a WSDL

February 14, 2010

A common approach when adding a web service to an ASP.net application, is to right click "Add Web Reference" and specify the path of the WSDL which outlines the interface for the service.   An alternative, and relatively simple to accomplish, alternative to this approach is to create a class that represents the xml contract outlined in a WSDL (Web Service Definition Language) file.   This WSDL could be stored locally, or specified via a full URL.  This is accomplished by using the wsdl.exe command line utility.  

The WSDL.exe command is available in the following path:
C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\wsdl.exe

An simple example use of this command is:
wsdl.exe /out:WeatherService.vb /l:VB http://www.weather.gov/forecasts/xml/DWMLgen/wsdl/ndfdXML.wsdl

A full description of the wsdl.exe command line utility is available here: 
http://msdn.microsoft.com/en-us/library/7h3ystb6(VS.80).aspx

There are many advantages to this, including but not limited to:

  • Achieving better understanding of underlying system calls to service
  • Including an audit/trace of service calls easily
  • Examining data being transmitted and received
  • Programmatically specify a sandbox/production URL interchangeably (this I find frequently useful)

I hope this helps in your programming endeavors, it has certainly helped me.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

posted in Archive posts by admin

Follow comments via the RSS Feed| Trackback URL

 
Powered by Wordpress and MySQL. Theme by Shlomi Noach, openark.org