A dynamic Web service call holds all relevant information in one file, the client, which Axis converts directly into the SOAP message. Essentially, the client you create is a Java version of the call itself, excluding some relative values that are replaced with absolute ones at compile time.

Keep in mind that if you want to access a Web service that uses non-standard data types, you need to create your Web service call following the static process. See Creating a Call Using a Client Stub (Static).

If you want to make this Web service able to share sessions, your code needs to communicate with the CookieContainer. The CookieContainer gets assigned to a client when it is compiled. Later, when the Web service executes, it checks the CookieContainer for an active session ID and uses that in the cookie it sends. See Sharing Sessions for more information.

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

  1. Create a Java file that includes the following information:

    Service service = new Service();
    Call call = (Call) service.createCall();
    call.setTargetEndpointAddress(new
    java.net.URL("http://hostname:port/userprofiling/usersession/loginUser/
    loginUser") );
    call.addParameter("Login",
       org.apache.axis.Constants.XSD_STRING,
       javax.xml.rpc.ParameterMode.IN);
    call.addParameter("Password",
       org.apache.axis.Constants.XSD_STRING,
       javax.xml.rpc.ParameterMode.IN);
    call.addParameter("IsPasswordEncrypted",
       org.apache.axis.Constants.XSD_BOOLEAN,
       javax.xml.rpc.ParameterMode.IN);
    call.setReturnType(org.apache.axis.Constants.XSD_STRING);
    call.setOperationName(new QName("http://www.atg.com/webservices",
    "loginUser"));
    String userId = (String) call.invoke( new Object[] { "bhavern",
    "xyo8bnif", Boolean.FALSE } );

  2. To provide session sharing capabilities, you need to add the following code:

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

    call.setMaintainSession(true);
    call.setCookieContainer(cookie);

    This code makes the following operations possible: it 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 class.

  4. Execute the Web service call:

    Axis converts the file into a XML message, wraps it in SOAP, and sends it via HTTP to the target endpoint specified within it.

 
loading table of contents...