When you create a call following the static method, you represent the server-side Web service architecture on the client by creating a client stub and a client:

The call is constructed by compiling information from the client stub, client, and various other supporting classes that hold static information.

For example, to create a static call to the loginUser Web service:

  1. Create and compile the client stub, if one does not already exist for the Web service. See Creating and Compiling a Client Stub below.

  2. Add the client stub to the CLASSPATH variable so the client stub is available to local Web services resources.

  3. Create and compile the client. See Creating and Compiling a Client below.

  4. Use Axis to execute the Web service call:

    loginStub.createUser(pProfileAsXML)

    The format of this call is
    clientStub.web_service(generated_web_Service_Call_instance)

    Axis creates the XML message, wraps it in SOAP, and sends it via HTTP to the Web service location in the client stub.

Creating and Compiling a Client Stub

The client stub describes the Web service method and supporting resources in a structure that’s familiar to the client. Each Web service requires a stub for each client that executes it. You can reuse a stub for subsequent calls so you only need to create it once. However, simultaneous calls to a Web service made by different threads will require that a unique client stub instance exists for each thread.

To create and compile a client stub for the loginUser Web service:

  1. Locate the active WSDL file via HTTP for the Web service you want to call. The URL is provided in with the documentation that describes each Web Service:

    It’s important that you access the runtime and not the static version of the WSDL document. Assuming that you included the modules holding the Web services you want to access when you assembled your application, you should be able to download the runtime version of the WSDL.

  2. Use the Axis WSDL-to-Java tool to generate the client stub based on the WSDL.

  3. Compile the client stub.

Creating and Compiling a Client

A Web service client is a Java file that describes precisely what the Web service should do. It provides the actions the Web service should commit and initial values.

If you want to enable Web services to share sessions, your code needs to pass cookies between calls. The following example, which creates a static Web service call to the loginUser Web service, uses the CookieContainer class shown in Writing a CookieContainer Class:

{
 LoginUserSEIService loginService = new LoginUserSEIServiceLocator();
 LoginUserSEI loginStub = loginService.getLoginUserSEIPort();
 org.apache.axis.client.Stub axisStub = (org.apache.axis.client.Stub) loginStub;
 CookieContainer cookieContainer = new CookieContainer();

 axisStub.setMaintainSession(true);
 // Don't allow XML elements to reference other XML elements
 axisStub._setPropertyValue(AxisEngine.PROP_DOMULTIREFS, new Boolean(false));
 // Push cookies onto the Stub
 cookieContainer.pushCookies(stub);

 String userId = loginStub.loginUser("bhavern", " xyo8bnif", false);

 // Get cookies out of the Stub, and pass them to subsequent calls as needed
 cookieContainer.extractCookies(stub);
}
 
loading table of contents...