Friday, July 20, 2012

Create Proxy class using WSDL

Have you been in a situation were you are asked to call a Web Service where you just have a .wsdl generated from Web Service?

Once i was in a situation where i had to call a service with complex data type as input as well as output.
As a .NET developer we know that we can just make Web Reference to the Server URL and we can have all the underlying definition of target web service.
But what happen when it is not possible to have a live URL for the target web service.
Please find a very simple solution for the same.

you can just ask for the .wsdl file from the user/programmer of the target Web Service.

the next step is to create proxy class based on wsdl file.
wsdl command in .net framework provides you this feature where you can create proxy class for your target web service

on the underlying framework run this command

wsdl \out:[path to your new class file] [path to .wsdl file]

that it.

check for the file at path [path to your new class file]

Add that file to you project.

one thing to check and remember do not forget to change the URL property of generated proxy class.
URL should always point to the URL of your target Web Service.

Thank You