Chapter 17. Consuming Web Services

While Chapter 15 gave an overview of web services and Chapter 16 described in detail how to create a web service, this chapter will explain how to create a web service client application or web service consumer. The consuming application can be a web page, another web service, or a desktop application.

Once a web service is created and made available to consumers on the Internet, it is up to the developer creating the client application to find the web service, create the client proxy, and incorporate the proxy into the client. The client can then make method calls against the remote web service as though it were making local calls. In fact, the client application is making local method calls against the proxy -- it just behaves as if it is making calls directly to the web service over the Internet.

Discovery

Discovery is the process of finding out what web services are available, what methods and properties are exposed by a specific web service, what parameters those methods and properties expect to receive, and what data type the web method returns. All of this information is contained in the WSDL (Web Services Description Language) document, introduced in the preceding chapter.

Discovery is an optional process. If the consuming developer knows the URL of the web service file (.asmx) itself, then there is no need to do discovery. However, it will often be the case that the consuming developer will not know the location of the web service file or the WSDL document. In these instances, ASP.NET provides a discovery command-line utility called disco.exe that provides the consuming developer with the information necessary to create the client.

You have already seen in Chapter 16 how the disco utility allows the developer who created the web service to generate a .disco file. Now the consuming developer can use the same utility to aid in creation of the client.

There are two equivalent ways of using the disco utility to generate the WSDL file. If you know the URL of the web service file, you can use that as input, as shown in the following command line:

disco http://WebSrvcDomain.com/csStockTicker.asmx?WSDL

If you don’t know the URL of the .asmx file but do know the URL of the .disco file, you can use that file as input to disco, as in:

disco http://WebSrvcDomain.com/csStockTicker.disco

In either case, a WSDL file will be generated in the output directory.

To force the output directory to be somewhere other than the current directory, use the /out: parameter, or /o: for short, as in:

disco /out:<output directory name> 
      http://WebSrvcDomain.com/csStockTicker.disco

The disco utility executed in the above command line will put three files, summarized in Table 17-1, in the output directory.

Table 17-1. Files output by the disco utility

Filename

Description

csStockTicker.disco

Discovery document you are trying to create

csStockTicker.WSDL

The exact same WSDL for the Web Service generated by entering the .asmx file in a browser with “?wsdl? appended to the URL

results.discomap

Alternative discovery document

For a complete listing of all the parameters available to the disco utility, enter the following command line:

disco /?

In addition to outputting a .disco file and a WSDL file, the disco utility will also create a .discomap file, which can be used as input to the WSDL utility, described later in this chapter.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.99.152