Using the Web Service from a Browser


You can use a Web browser to invoke the Web service methods, and the following short exercise will show you how.

  1. Start Microsoft Internet Explorer.

  2. Type the URL for the Web service’s .asmx file into the Address bar. If you’ve named the Web service Converter and installed it on IIS on your local computer in the default virtual directory, the address will be http://localhost/Converter/Converter.asmx.

    Note

    If you’ve installed the service on a remote computer or used another virtual directory, you’ll have to amend the address accordingly.

    When you press ENTER, the Web server will return you details of the Converter service and the methods it supports.

    click to expand

    You can see how metadata has been extracted from the class and used to provide a description of the service.

  3. Click one of the two methods. An HTTP GET command is sent to the server, which results in the server autogenerating a Web service consumer and sending it back to the browser.

    click to expand

    The consumer takes the form of an HTML page that contains a description of the service, a way of testing the method, and descriptions of how to use the service using HTTP GET, HTTP POST, and SOAP.

  4. Test the method by entering a suitable value into the text box and clicking Invoke. The Web service will invoke the method and return the answer as XML.

    <?xml version="1.0" encoding="utf-8" ?> <double xmlns="http://VCSBS/WebServices/">42</double>

    The double element identifies the value as a double, and the namespace is used to identify the Web service that is returning the result.




Microsoft Visual C++  .NET(c) Step by Step
Microsoft Visual C++ .NET(c) Step by Step
ISBN: 735615675
EAN: N/A
Year: 2003
Pages: 208

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net