Exploring XML Web Services with .NET WebService Studio

Microsoft's .NET WebService Studio (WSS) is an extraordinarily useful application for testing your own and others' Web services. The primary reason that this section is located midway through the chapter is the time and effort to prepare for its use if you haven't installed the prerequisites to run .NET applications. Another reason is WSS's capability to display the IXMLDOMNode property values that are described in the four preceding sections. Basic knowledge of the IXMLDOMNodeList and IXMLDOMNodes objects makes WSS's SOAP response data display meaningful.

WSS consists of a single tabbed .NET Windows form that lets you send SOAP request messages to a service, inspect the full text of the request and response messages, view the service's WSDL document, and read the C# proxy code. Like WSR, WSS generates the client proxy for the service. WSS, however, provides text boxes to supply the service's parameter values.

Tip

WSS is an essential tool for testing SQLXML Web services that you develop in the following sections. If you intend to make your SQL Server data accessible to Web services consumers, your investment to install WSS will be well rewarded.


Installing .NET WebService Studio and its Prerequisites

Following are the steps required to install and run WSS:

  1. Install the latest service pack (SP) and security upgrades for your operating system and IIS 5.1+ from the Windows Update site at http://v4.windowsupdate.microsoft.com/en/default.asp. You might not be able to install or use the .NET Framework if you haven't installed the latest SP or current security patches are missing.

  2. If you don't have the .NET Framework 1.0 or 1.1 installed on your machine, download and install the .NET Framework 1.1 Redistributable or SDK version from http://msdn.microsoft.com/netframework/.

    Note

    The Redistributable version is about a 20MB download; the SDK version, which includes documentation, sample applications, and command-line tools, is 270MB.

    If you encounter a run-time error when you start WSS under .NET Framework 1.1, install the .NET Framework 1.0 redistributable version from the same page. The two versions run side by side.

  3. Create a \Program Files\WebService Studio folder in which to install the application (WebServiceStudio.exe).

  4. Download and install .NET WebService Studio from http://www.gotdotnet.com/team/tools/web_svc/default.aspx. Be sure to download the original .NET Web Service Studio version, not version 2.0. Version 2.0 includes additional features that are beyond the scope of this book.

  5. If you want to learn more than this section offers about WSS, open and save the Readme file (http://www.gotdotnet.com/team/tools/Web_svc/readme.rtf) in your installation folder.

Tip

Microsoft's GotDotNet site offers several additional tools for Web service development, plus XML utilities. One of the most interesting XML utilities is an online XSD schema inference engine at http://apps.gotdotnet.com/xmltools/xsdinference/. Supply the path to an XML file and Microsoft XSD Inference 1.0 generates its XSD schema. You can read more about XSD Inference 1.0 at http://www.fawcette.com/xmlmag/2002_11/online/xml_rjennings_11_11_02/.


Running WSS with a Public Web Service

Here's how to give WSS a test drive, using the Alpha service as an example:

  1. Run WebServiceStudio.exe from your installation folder.

  2. Type the URL for a public Web service's WSDL file in the WSDL EndPoint text box. Alternatively, you can browse for a local copy of a WSDL file. For this example, type http://www.oakleaf.ws/SQLXML/alpha?wsdl.

  3. Click the Get button to connect to the WSDL document. WSS generates and compiles the C# client proxy code for the service. WSS displays the parameter datatypes and names in the Input list, if the service has parameters.

  4. Select one of the service's Web methods in the Invoke list (look ahead to Figure 31.12).

    Figure 31.12. WSS uses the IXMLDOMNodeList to generate a tree view of the contents of each IXMLDOMNode of the SOAP response message in the Output list.

    graphics/31fig12.jpg

  5. Select a parameter and type an appropriate entry in the Value text box of the Value list AMPL for the Alpha service.

  6. Repeat step 5 for each required parameter. Additional parameters for Alpha's GetTop### methods are optional, so add DVDP only.

  7. Click the Invoke button to consume the service and populate the lower Output and Value lists with data from the SOAP response message. Items in the Output tree view correspond to IXMLDOMNode elements from the IXMLDOMNodeList object returned by the proxy.

  8. Scroll the Output list to display the data elements at the lowest level of the hierarchy. Select a TextValue element to display its contents in the Value list (see Figure 31.12).

Clicking the Request/Response tab displays the full text of the SOAP request and response messages in two text boxes (see Figure 31.13). If the Web service requires Basic (clear-text) authentication, provide the credentials in the BasicAuthPassword and BasicAuthUserName text boxes. For services on an intranet that require Windows (NTLM) authentication, you can pass your logon credentials to the service by changing UseDefaultCredential's value to True. To use NTLM authentication, you also must set the AutoRedirect and KeepAlive HTTP properties to True.

Figure 31.13. Code behind WSS's form intercepts the serialized SOAP request and response messages and displays the XML contents in two text boxes.

graphics/31fig13.jpg

The WSDLs & Proxy page has a tree view list that lets you display the contents of the WSDL document, XSD schemas for the response document, if present, and the C# code for the Web service proxy, and WSS's client code that invokes the proxy. Selecting the Proxy and scrolling to the proxy for the first Web method lets you compare the C# code for invoking the method with the WSR clsws_ServiceName's wsm_FunctionName(Parameters...) As MSXML2.IXMLDOMNodeList VBA function (see Figure 31.14). WSS returns the SqlRowSet object as a .NET System.Data.DataSet type, which simplifies populating a DataGrid control in a .NET Windows or Web form (refer to Figure 31.11). The System.Xml.XmlNode type for SqlXml rows corresponds to MSXML2's IXMLDOMNode type.

Figure 31.14. The C# code for the Alpha Web service proxy is much more complex than that generated by WSR. The WSS proxy works, however, while the original WSR proxy fails.

graphics/31fig14.jpg



Special Edition Using Microsoft Office Access 2003
Special Edition Using Microsoft Office Access 2003
ISBN: 0789729520
EAN: 2147483647
Year: 2005
Pages: 417

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