Consuming Web Services

There are various ways of consuming web services. Here I am mentioning 3 of them.

1. Using Add Reference dialog box in the VS.Net IDE.
2. Using commandline utility- wsdl.exe/disco.exe
3. Using IE5.5 Behaviour - wed service behaviour(webservice.htc), enables client script to access web service without postback.

Consuming web service without using Add Reference dialog box.

Here I am going to describe how we can use wsdl.exe/disco.exe for consuming wed service.

Path of wsdl.exe/Disco.exe is < root >\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin

Using wsdl.exe

steps 1. Create .cs/.vb source file(proxy) using wsdl.exe. Example-


wsdl.exe /l:CS /out: < path of .cs file to be created > < path of the web service like - http://webservicehost/webservice/service.asmx?wsdl >

Or

wsdl.exe /l:CS /out: < path of .cs file to be created > < path of the web service like - http://webservicehost/webservice/service.asmx >

Or

wsdl.exe /l:CS /out: < path of .cs file to be created > < path of WSDL file like – d:\Service.wsdl >

Or

wsdl.exe /l:CS /out: < path of .cs file to be created > < path of DISCOMAP file like – d:\Results.discomap>

step 2.Include the created .cs/.vb source file(proxy) and use it just like other local source files of your project. Or use csc.exe/vbc.exe for creating dll from the source file(proxy). And than add reference of this dll and use it.

Using disco.exe

step 1- Use disco.exe to generate .disco, .wsdl,.discomap files. Example-

disco.exe /out:< directory name > < web service path like- http://webservicehost/webservice/service.asmx >

Or

disco.exe /out:< directory name > < web service path like- http://webservicehost/webservice/service.asmx?disco >

Or

disco.exe /out:< directory name > < web service path like- http://webservicehost/webservice/service.asmx?wsdl >

Note - In this case only .wsdl and .discomap files will be created.

step 2- Use wsdl.exe to generate source file(proxy)/dll from the .wsdl file.

1 comment:

Anonymous said...

Good for people to know.