Calling a web service To a Client

Monday, 29 August 2016

Calling a web service To a Client


Creating the Proxy
before using web service to the client a proxy must be created which is registered with the client application.Then the  client application makes the calls to the web service as it were using a local method.The proxy takes the calls, wraps it in proper format and sends it as a SOAP request( Learn about SOAP Click here) to the server. This protocol is used for exchanging web service data.When the server returns the SOAP package to the client, the proxy decodes everything and

presents it to the client application.This Process is describe in this picture

















Now take the following steps for creating the proxy:
Step (1) :In my case, client is a windows application. so to add web reference first right click on application then select add service reference, Now Click on Advance it will open up service reference settings there at the end of the window click add web reference.


















Step (2) : Now add web reference window will open and you have to copy the hosted web service address to the URL address bar. A meaning full web service reference name should be given then click on add reference. It will add the service reference with the client application now from the client application you can create object of the service reference and call the web service method.

Step (3) :  write down the below code to create object of the service .
                  ConsumeService.Service1  obj = new ConsumeService.Service1();