Programming Security for Web Services

     Previous  Next    Open TOC in new window    View as PDF - New Window  Get Adobe Reader - New Window
Content starts here

Using Failover with a Web Services Client

OES supports the ability of Axis-based Web Services clients to fail over to another Web Services SSM when the client encounters a connection problem. The following sections describe this failover functionality:

Note: The Web Services client failover feature is supported for clients developed with Axis 1.2 or later. For more information, see the Apache Axis site: http://ws.apache.org/axis/ .

 


Configuring a Web Services Client for Failover

To configure a Web Services client for failover:

  1. In the client’s classpath, include /webservice-ssm/lib/ssmwsClientFailover.jar and Log4j.jar.
  2. In the client’s JAVA_OPTIONS, include:
  3. -Daxis.ClientConfigFile=<SSMWS_INSTANCE_HOME>/config/failover-client-config.wsdd
  4. In the client’s code, include failover initialization code similar to the code in Listing 4-1:
  5. Listing 4-1 Sample Failover Initialization
    // Populate the SSMInstanceList with the list of WS SSM instances. For example:

    ArrayList SSMInstanceList = new ArrayList();
    SSMInstanceList.add("http://12.10.1.4:9090");
    SSMInstanceList.add("http://12.10.1.2:9090");

    // Set the Http Connection Time Out and number of retry attempts
    // that will be made on the SSM instance

    int noOfRetry = 3;
    int httpConTimeOut = 60000; // The time is in milliseconds.
    FailOverManager.getInstance(SSMInstanceList, noOfRetry,httpConTimeOut);

    // <<<<<<< Original Client Code >>>>>>
    ServiceRegistryBindingStub serviceRegistry =
    new ServiceRegistryBindingStub(new java.net.URL(serviceRegistryURL),null);

    SsmIdType ssmIdType =
    new SsmIdType(ServiceTypeEnum.ALES_AUTHENTICATION, ssmId);
    ComplexAnyURI authURL;

    authURL = serviceRegistry.locateService(ssmIdType);

    System.out.println("Authentication URL: " + authURL.getLocateServiceResponse().toString());
    /**
    * Authentication Code
    */
    // get the URL for the Authentication Service should be
    // http://<hostname>:<webservice-ssm-port>/Authentication
    authenticationService = new AuthenticationBindingStub(
    new java.net.URL(authURL.getLocateServiceResponse().toString()),null);

Client Configuration File

Listing 4-2 gives an example of the failover-client-config.wsdd file.

Listing 4-2 Cache Client WSDD File
<?xml version="1.0" encoding="UTF-8"?>
<deployment name="defaultClientConfig"
            xmlns="http://xml.apache.org/axis/wsdd/"
            xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
  <globalConfiguration>
    <parameter name="disablePrettyXML" value="true"/>
    <parameter name="enableNamespacePrefixOptimization" value="false"/>
  </globalConfiguration>
  <transport name="http"   pivot="java:com.bea.security.ssmws.client.failover.FailOverHTTPSender"/>
  <transport name="local"   pivot="java:org.apache.axis.transport.local.LocalSender"/>
  <transport name="java" pivot="java:org.apache.axis.transport.java.JavaSender"/>
</deployment>

 


FailOverManager API

The FailOverManager class stores and manages the failover endpoints for Web Services clients. This class is a singleton; it stores a list of endpoints and the values for the number of retries on connection failure and HTTP connection timeout. It includes the following public methods:

getInstance()

Returns an instance of the FailOverManager. This method makes sure that there is only one instance of this class in the JVM. This method is invoked to get an instance of the FailOverManager configured with its default properties. The FailOverManager has the following configuration properties:

failOverEndPoints

A list of endpoints; on failover, the Web Services client attempts to connect to the listed endpoints in the order they are provided. If no endpoinnts are specified, the only connection URL that will be tried is the first one that is used when setting up a Web Service call via the BindingStub. Default is empty.

noOfRetries

The number of times each endpoint is tried before failing over to the next endpoint. Default is 3.

httpConTimeOut

Time, in milliseconds, to wait before trying again to connect to the current endpoint. Default is 0, indicating immediate retry.

If you need to change any of these values, then use the getInstance(ArrayList failOverEndPoints,int noOfRetries, int httpConTimeOut) method, which takes these as arguments.

getInstance(ArrayList failOverEndPoints,int noOfRetries, int httpConTimeOut)

Returns an instance of the FailOverManager. You can supply values for the failover endpoint list, number of retries, and HTTP connection timeout as arguments.

setEndPointList (ArrayList endpoints)

Replaces the existing list of failover endpoints with the provided list of endpoints. The currentEndPoint variable of the FailOverManager points to the first endpoint in the list. On failover, the Web Services client attempts to connect to the listed endpoints in the order they are provided. Each endpoint is tried the number of times specified by the noOfRetries property of the FailOverManager before failing over to the next endpoint. If all the endpoints fail, AXIS will throw the regular connection exception to the client.

This method is thread-safe; you can call this method during runtime to refresh the list of endpoints.

getEndPointList()

Returns the list of end points.


  Back to Top       Previous  Next