Tuesday, 16 February 2010

Auto generating from a Web Services Description Language (WSDL) to ASP.NET (C#)

I ALWAYS forget how to do this so I'm going to blog the steps:

1.) Open a Visual Studio command prompt (not a DOS prompt!)
2.) Drill down to the folder location where you want the auto generated class to be saved.
3 a.) If you are using a WSDL file rather than a URL, drop the file into the same location and type the following command (where filename.wsdl is the name of the file) and press Enter:

filename.wsdl /language:C#

3 b.) If the WSDL comes via a URL, make sure the service is running and type the following command (where http://webservice?wsdl is the URL of the WSDL) and press Enter:

http://webservice?wsdl /language:C#

4.) You should find it has generated a class and config file which contains all the services, ports, bindings and messaging you need to communicate with this particular web service.

FYI - More WCF proxy generating info here.