Non-functional Descriptions and Beyond WSDL

Chapter 8 • Web Services 289 implementation of the discovery agency. The UDDI registry offers a common repository to which service providers publish service information, and which service requestors inquire to find service information. UDDI defines a structure for the registry, together with a publishing and inquiry Application Programming Interface API for accessing the registry. If a service repository is used at runtime, we refer to this mode as dynamic Web services.

8.5 Developing Web Services with Axis

As the brief review above illustrates, the technology behind Web services is quite complex. Luckily, most Web services developers will not have to deal with this infrastructure directly. There are a number of Web services development toolkits to assist with developing and using Web services. There are currently many tools that automate the process of generating WSDL and mapping it to programming languages Figure 8-16. One of the most popular such tools is Axis. Apache Axis Apache EXtensible Interaction System, online at: http:ws.apache.orgaxis is essentially a SOAP engine—a framework for constructing SOAP processors such as clients, servers, gateways, etc. The current version of Axis is written in Java, but a C++ implementation of the client side of Axis is being developed. Axis includes a server that plugs into servlet engines such as Apache Tomcat, extensive support for WSDL, and tools that generate Java classes from WSDL. Axis provides automatic serializationdeserialization of Java Beans, including customizable mapping of fields to XML elementsattributes, as well as automatic two-way conversions between Java Collections and SOAP Arrays. Axis also provides automatic WSDL generation from deployed services using Java2WSDL tool for building WSDL from Java classes. The generated WSDL document is used by client developers who can use WSDL2Java tool for building Java proxies and skeletons from WSDL documents. Axis also supports session-oriented services, via HTTP cookies or transport-independent SOAP headers. The basic steps for using Apache Axis follow the process described in Section 8.3.4 above illustrated in Figure 8-16. The reader may also wish to compare it to the procedure for using Java RMI, described in Section 5.4.2 above. The goal is to establish the interconnections shown in Figure 8-2.

8.5.1 Server-side Development with Axis

At the server side or the Web service side, the steps are as follows: Ivan Marsic • Rutgers University 290 1. Define Java interface of the Web service and a class that implements this interface 2. Generate the WDSL document from the service’s Java interface Java → WSDL 3. Generate the skeleton Java class server-side proxy from the WSDL document WSDL → Java 4. Modify the skeleton proxy to interact with the Java class that implements the Java interface both created in Step 1 above Going back to the project for Web-based Stock Forecasters Section 1.5.5, I will now show how to establish the interconnections shown in Figure 8-2, so that a client could remotely connect to the Web service and request a price forecast for stocks of interest. The details for each of the above steps for this particular example are as follows. Step 1: Define the server object interface There are three key Java classes from the point of view of Web services responsible for providing a stock price forecast and trading recommendation Figure 8-18b: ForecastServer.java , its implementation ForecastServerImpl.java and ParamsBean.java , a simple container object used to transfer information to and from the Web service. The structure of other packages in Figure 8-18a is not important at this point, since all we care about is the Web service interface definition, which will be seen by entities that want to access this Web service. The Java interface ForecastServer.java is given as: Listing 8-4: Java interface of the forecasting Web service. 1 package stock_analyst.interact; 2 3 import java.rmi.RemoteException; 4 5 public interface ForecastServer { 6 7 public void getPriceForecast ParamsBean args 8 throws RemoteException; 9 10 public void getRecommendation ParamsBean args 11 throws RemoteException; 12 }