Labels

Monday, July 7, 2008

03 - Discovering Web Service

Hi,

In this post we’ll learn XML Web Services Discovery Mechanism.

Once the Web Service is deployed and published, any client discover the sevice to use it. The discovery process is called as Web Services Discovery Mechanism.

This discovery mechanism enables to discover Web Service in two ways.

A. Discover using .asmx file

B. Discover using .disco file – This can only happen when XML Web Service are deployed with DISCO file.

Each of the above possesses two aproaches for dscovering. The approaches are:

- Add Web Reference

- Command line utility

We’ll discuss both approaches in each of them.

A. Web Services Discovery Mechanism Using .ASMX -

‘Add Web Reference’ Approach –

· In the Discovery Process, files, such as Service Descriptions (WSDL), XSD schemas, or Discovery Documents (.disco file), are downloaded to the client computer.

Finding Steps:

· Client accesses a UDDI service to locate an XML Web service (.asmx).

· UDDI service returns a URL to the discovery document (.disco) of the XML Web service.

· After the client receives the URL to the discovery document, the client makes a request to the server using the URL.

· The Server which returns the discovery document (.disco) to the client.

· The client uses the information (path to the WSDL file)in the discovery document and makes a request to the server.

· The server returns the service description (.wsdl file) of an XML Web service. The service description is a .wsdl file and enables a client to interact with an XML Web service.

· Once the client recieves the link to WSDL, it provides option to Add reference, which in turn creates a Proxy class.

· The Proxy class is then compiled into .dll and copied to /bin directory.

These two files are automatically generated and placed at cleint side, when we access the WebService(.asmx) using ‘Add Web Reference’ approach.

Figure 1

‘Command Line’ Approach – Using WSDL.EXE

Below are the steps required to add reference using DISCO.EXE utility.

- Run with the url passed.

c:\temp> wsdl.exe /l:cs http://localhost/math/math.asmx?wsdl

- This generates an output file – math.cs (Proxy Class)

- Comiple it and place it under /bin

After a client application discovers a Web service, the client application can access and use all the exposed methods of a Web service. The process of using an exposed method of a Web service is known as Consuming A Web Service.

B. Web Services Discovery Mechanism Using .DISCO -

Before we start let me tell you the fact - DISCO is a Microsoft technology and introduced in .Net , for publishing and discovering Web Services.

‘Add Web Reference’ Approach –

Here we access the .DISCO file (See Left figure) instead of .ASMX in the ‘Add Web Reference’ dialog. Doing this will give you a new kind of screen (See Right figure).

In the Right Figure –

* Selecting ‘View Service’ shows WSDL data (http://localhost:1678/TrialService/Service.asmx?wsdl)

* Selecting ‘View Documenation’ shows data equivalent to http://localhost:1678/TrialService/Service.asmx

You can select either of the one and select ‘Add Reference’ to do the rest of the work.

Figure 2

Figure 3

Note – When we select either of the one and select ‘Add Reference’, notice that this time only the .wsdl file is added under .discomap.

‘Command Line’ Approach – Using DISCO.EXE

This is used when we do not have access to ‘Add Web Reference’ facility. Below are the steps required to add reference using DISCO.EXE utility.

- Run with the url passed.

c:\temp> disco.exe http://localhost/math/math.disco

- This generates an output file (math.discomap) that contains information about the Web Services discovered at the specified.

- Now use wsdl.exe that can generate Web Service proxies from WSDL documents or the .discomap files generated by disco.exe. You can run it like so:

c:> wsdl.exe /l:cs math.discomap

- This generates an output file – math.cs (Proxy Class)

- Comiple it and place it under /bin

After a client application discovers a Web service, the client application can access and use all the exposed methods of a Web service. The process of using an exposed method of a Web service is known as Consuming A Web Service.

Thanks & Regards,

Arun Manglick || Senior Tech Lead

No comments:

Post a Comment