UDDI for Service Discovery and Integration

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 } Chapter 8 • Web Services 291 The code description is as follows: Line 1: Java package where the interface class is located. Line 2: Exception RemoteException may be thrown by the Web service methods. Lines 7–8: Method getPriceForecast takes one input argument, which is a Java Bean used to transport information to and from the Web service. The method return type is void , which implies that any result values will be returned in the args parameter. Lines 10–11: Method getRecommendation signature, defined similarly as for the method getPriceForecast. Web interaction Gathering stock information Pattern learning recognition e.g., neural network stock_analyst interact Internet database a analyze collect Internet b Web service proxies stubskeleton interact ParamsBean – parameters_ : HashMapString, Object + addParamString, Object + getParamString : Object + getParams : String, Object ws Generated by Axis WSDL2Java ForecastServer + getPriceForecastargs : ParamsBean + getRecommendationargs : ParamsBean ForecastServerImpl numOfTrials_ : long maxNumOfTrials_ : long + getPriceForecastargs : ParamsBean + getRecommendationargs : ParamsBean Internet b Web service proxies stubskeleton interact ParamsBean – parameters_ : HashMapString, Object + addParamString, Object + getParamString : Object + getParams : String, Object ParamsBean – parameters_ : HashMapString, Object + addParamString, Object + getParamString : Object + getParams : String, Object ws Generated by Axis WSDL2Java ForecastServer + getPriceForecastargs : ParamsBean + getRecommendationargs : ParamsBean ForecastServer + getPriceForecastargs : ParamsBean + getRecommendationargs : ParamsBean ForecastServerImpl numOfTrials_ : long maxNumOfTrials_ : long + getPriceForecastargs : ParamsBean + getRecommendationargs : ParamsBean ForecastServerImpl numOfTrials_ : long maxNumOfTrials_ : long + getPriceForecastargs : ParamsBean + getRecommendationargs : ParamsBean Figure 8-18: a UML package diagram for the example application. b Web-service related classes.