Friday, January 27, 2006

VS : Looking at the SOAP proxy code

So you are writing a web client with Visual Studio (assume command line) and you need to add a web reference.

Solution Explorer - right click References - Add Web Reference.

Point to the WSDL - GO and it's done.

What's done? - where's the generated code?

Open File - navigate to Web References / WebReference / Reference.cs.

This will show the SOAP methods and signatures you can call.

It will start with "public class X".

So use:

X x = new X ();
and the SOAP call will be x.method.

(Hint - when compiling add a "using" to your main class and check the namespace of the generated code.)

The line "this.Url = "http://a.b.c.e"; " is useful. Change this url if you move your web service.

Enjoy.

No comments: