Three Test Web Services


Testing Web Services

Now that you have three Web Services that represent the different environments covered in this book, you need to test them in order to create consumers. The first part of this involves setting up the environment for Tomcat such that both Axis and SOAP Web Services are able to execute simultaneously.

Once the environment is set up correctly, .NET WebService Studio, which is provided as a free download from Microsoft on the www.gotdotnet.com Web site, allows you to easily test any Web Service that generates WSDL because it builds a proxy and a client dynamically without having to write and compile a program.

Environment Setup

On the CD The trick with executing SOAP and Axis simultaneously is to set up the CLASSPATH and other environmental variables so that all the necessary libraries are available. The CD-ROM for this book has the MSDOS batch file (Example 9-5.bat) the author used to set up the environment for the examples in this chapter.

The batch file code looks like the following.

        set PATH=%PATH%;c:\J2SDK_FORTE\jdk1.4.0\bin;         set JAVA_HOME=c:\J2SDK_FORTE\jdk1.4.0         set CLASSPATH=             c:\xmlapache\tomcat\webapps\axis\WEB-INF\lib\axis.jar;             c:\xmlapache\tomcat\webapps\axis\WEB-INF\lib\commons-                 logging.jar;             c:\xmlapache\tomcat\webapps\axis\WEB-INF\lib\jaxrpc.jar;             c:\xmlapache\tomcat\webapps\axis\WEB-INF\lib\saaj.jar;             c:\xmlapache\tomcat\webapps\axis\WEB-INF\lib\log4j-                 1.2.4.jar;             c:\xmlapache\tomcat\webapps\axis\WEB-INF\lib\tt-                 bytecode.jar;             c:\xmlapache\tomcat\webapps\axis\WEB-INF\lib\xerces.jar;             c:\xmlapache\tomcat\webapps\axis\WEB-INF\lib\wsdl4j.jar;             c:\xmlapache\axis-1_0\;             c:\xmlapache\javamail\mail.jar;             c:\xmlapache\jaf\activation.jar;             c:\xmlapache\soap;             c:\xmlapache\soap\lib\soap.jar;             c:\xmlapache\tomcat\lib\servlet.jar;

If you look closely at the batch file, you’ll notice that it includes all the libraries that SOAP and Axis need to execute properly. If you can start Tomcat and then access both the SOAP and Axis admin pages, your environmental setup is correct.

Using .NET WebService Studio

.NET WebService Studio provides an easy means of testing the compatibility of Web Services with Dot Net. By utilizing .NET WebService Studio, you’ll save time because you’ll know that your Web Services are working properly without having to write and compile a program.

Begin by downloading the .NET WebService Studio from www.gotdotnet.com. Appendix B contains the information about where to download the file. It is simply an executable, so all you need to do is double-click on the .exe file once it’s extracted.

Click the “Browse” button and browse to the WSDL file for the ApacheAxixIdservice.

Remember the port problem mentioned in the tip earlier, so if your Web Service resides on a port greater than 80 you may wish to browse to a local file rather than one at a URL. Click on “Get.” The application examines the WSDL file and compiles a proxy. This allows you to call the Web Service without writing a client. Once it considers the WSDL, it brings you to a screen that shows available methods. Select the method you want to test by highlighting it, and then select the parameter that gets passed (if any), and enter a value. Clicking “Invoke” causes WebServiceStudio to call the appropriate Web Service and print out the reply. Results of such a test are shown in Figure 9.6.

click to expand
Figure 9.6: Notice the output window of the WebServiceStudio for the results of calling the Axis Web Service.

The “Request and Response” tab allows you to see the SOAP messages that are sent and received by the Axis Web Service. An example of this is shown in Figure 9.7. This can be very useful during a debugging process where you may be trying to determine why you cannot invoke a particular service.

click to expand
Figure 9.7: The “Request and Response” to the Axis Web Service in WebServiceStudio.

The “WSDL and Proxy” tab allows you to view WSDL file you pointed to. The code generated for the proxy is shown in Figure 9.8.

click to expand
Figure 9.8: The client and proxy code shown in WebServiceStudio.

WebServiceStudio provides you with a quick means of developing a client for testing your Web Services. As long as WSDL is available, .NET WebService Studio can test both .NET and Apache Web Services.




Cross-Platform Web Services Using C# and Java
Cross-Platform Web Services Using C# & JAVA (Charles River Media Internet & Web Design)
ISBN: 1584502622
EAN: 2147483647
Year: 2005
Pages: 128

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