Programming Tips and Tricks

Thursday, October 26, 2006

Web service Server Auto-creation Using WSDL

If you ever work with web services between different parties for any B2B transfer you will likely come across situations when first party will generate all the WSDL and the second party will have to take those WSDL and generate a Web Service Server that conforms to that. When you are using custom namespaces it becomes very messy to go through WSDL manually and determine what methods needs to be exposed by you Web Service. In such condition it becomes vital to be able to auto generate Web Service Server using the WSDL.

The easiest way to accomplish this using .NET Framework 1.1 is using WSDL.exe!

When you create a Web Service client using Visual Studio by adding a web reference, it essentially calls the WSDL.exe to generate the client class. But if you whish to generate the Web Service Server using existing WSDL, you will have to use the command line WSDL.exe directly since Visual Studio does not gives any such options.

Following are step by step instructions:
1) Open up .Net Command Prompt: Start>programs>Microsoft Visual Studio .Net 2003>Visual Studio .NET tools>Visual Studio .NET 2003 Command Prompt.
2) Type in: Wsdl /Server [WSDL file Name]

Doing this will create a .CS file in your current path with same name as the WSDL file name. Please note that this process just generates an abstract class with abstract methods. You will have to implement these methods before you can compile a Web Service project with this code.

Going through above steps will save lots of time as opposed to if you have to reverse engineer a WSDL to generate you own Web Service which will conform to any clients generated by that WSDL file.

Hope this tip will be helpful to you!

Happy Coding!

-Goldie.

My Intro

Hello All!

My Name is Goldie Satpal and I have been working in Microsoft Technologies mostly .NET Framework 1.1 for last 3 years. With this blog I will try to share some hard to find information that I have learned in my professional carrier with all the fellow bloggers. Hopefully you will find the information here helpful.

Happy coding!

Goldie.