Now that you know how to make product information available via one or more Web services and have the code for our Web service, the Web service can be utilised by a variety of client applications.
Conceptually, the service will be available publicly via an Internet connection so customers may easily use it. Of course, we need to be able to tell customers how to use it. A good test of the service is building a proxy class/client to consume it. In this week's article, we develop a simple proxy class via .NET.
Proxy class automation
In addition to testing the service with a basic browser call to the service asmx file, we can test it using SOAP as well. A client and a Web service can communicate using SOAP messages, which encapsulate the in and out parameters as XML. Fortunately, for Web service clients, the proxy class handles the work of mapping parameters to XML elements and then sending the SOAP message over the network.
A proxy class is created to shield the client from the complexity involved in invoking the Web service. A proxy class is a class containing all of the methods and objects exposed by the Web service. These methods handle the marshalling of the parameters into SOAP, sending the SOAP request over HTTP, receiving the response from the Web service, and unmarshalling the return value. The proxy class allows the client program to call a Web service as if the Web service was a local component.
A proxy class may be generated from a service description as long as it conforms to the Web Services Description Language (WSDL) standard. You can create a proxy class using the .NET command-line tool wsdl.exe. In turn, a Web service client may invoke proxy class methods, which communicate with a Web service over the network by processing the SOAP messages sent to and from the Web service.
Because a proxy class communicates with the Web service across the Internet, it is a good idea to verify that the url property of the proxy class references a trusted destination. The following command uses the wsdl.exe tool to generate a proxy class for our service:
wsdl /language:cs /protocol:soap
http://localhost/WebServiceExample/Service1.asmx
Listing A contains a small portion of the class generated by this call.
Listing A
A key aspect of the proxy class is its constructor that sets the url property so the Web service is properly accessed. The generated methods mimic methods in the actual Web service. Notice that each method invokes the corresponding method in the Web service.








1
H@K - 28/08/07
the above email doesnt work...dont email me... just tell me if you can put a proxy on my webpage ....
webpage... myotaku.com
username.... instantaccess
password... xxxx
( seriously its four x's )
thanx 4 ur help if u help me
fix asap
» Report offensive content
2
H@K - 28/08/07
the above email doesnt work...dont email me... just tell me if you can put a proxy on my webpage ....
webpage... myotaku.com
username.... instantaccess
password... xxxx
( seriously its four x's )
thanx 4 ur help if u help me
fix asap
» Report offensive content
3
Neeraj - 30/01/09
Great example for someone reading about proxy class.
Thanks alot!
» Report offensive content