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 supportive 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 the 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 supportive resources in a structure that’s familiar to the client. Each Web service requires a stub for each client that executes it. You can re-use 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 exist 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.

To make your Web service able to share sessions with other Web services, you create a CookieContainer to permit session sharing. When you instantiate the client, you must assign a CookieContainer to it. That CookieContainer is then used to store and retrieve cookies provided by HTTP requests. See Sharing Sessions for more information.

To create and compile a client for loginUser:

  1. Create a Web service client that includes the following standard code:

    LoginUserSEIService loginService = new LoginUserSEIServiceLocator();
    LoginUserSEI loginStub = loginService.getLoginUserSEIPort();
    String userId = loginStub.loginUser("bhavern", "xyo8bnif", false);

  2. To enable session sharing for this Web service call, include the following information in your client stub:

    org.apache.axis.cookies.CookieContainer cookie = new CookieContainer();

    ((loginUser)loginUser).setMaintainSession(true);
    ((loginStub)loginService).setCookieContainer(cookie);

    This code instantiates the CookieContainer, saves the Web service call’s session ID to the CookieContainer when an ID exists, and permits the CookieContainer to share the Web service call’s session ID with other calls.

  3. Compile the client.

 
loading table of contents...