Setting up Java mobile web service applications

To create mobile web service applications in Java, you must complete the following initialization tasks.

 Initialize QAnywhere and mobile web services for Java
  1. Add the location of the following files to your classpath. By default, they are located in %SQLANY12%\Java:

    • qaclient.jar
    • iawsrt.jar
    • jaxrpc.jar
  2. Import the ianywhere.qanywhere.client and ianywhere.qanywhere.ws packages:

    import ianywhere.qanywhere.client.*;
    import ianywhere.qanywhere.ws.*;
  3. Create a QAManager object.

    QAManager mgr;
    mgr = QAManagerFactory.getInstance().createQAManager(null);

    You can also customize a QAManager object by specifying a properties file to the createQAManager method:

    mgr = QAManagerFactory.getInstance().createQAManager("qa_mgr.props.");
    Tip

    For maximum concurrency benefits, multi-threaded applications should create a QAManager for each thread. See Multi-threading considerations.

  4. Initialize the QAManager object.

    mgr.open(AcknowledgementMode.EXPLICIT_ACKNOWLEDGEMENT);

    The argument to the open method is an acknowledgement mode, which indicates how messages are to be acknowledged. It must be one of IMPLICIT_ACKNOWLEDGEMENT or EXPLICIT_ACKNOWLEDGEMENT.

    QAnywhere messages used by mobile web services are not accessible to the mobile web services application. When using a QAManager in EXPLICIT_ACKNOWLEDGEMENT mode, use the Acknowledge method of WSResult to acknowledge the QAnywhere message that contains the result of a web services request. This method indicates that the application has successfully processed the response.

    For more information about acknowledgement modes, see:

    Note

    Instead of creating a QAManager, you can create a QATransactionalManager. See Implementing transactional messaging for Java clients.

  5. Create an instance of the service binding class.

    The mobile web services WSDL compiler generates the service binding class from the WSDL document that defines the web service.

    In the process of making web service requests, the QAManager is used by the instance of the web service binding class to perform messaging operations. You specify the connector address to use to send web service requests through QAnywhere by setting the WS_CONNECTOR_ADDRESS property of the service binding class. Each QAnywhere web service connector is configured with a URL of a web service to connect to. This means that if an application needs web services located at more than one URL, then a QAnywhere connector must be configured for each service URL.

    For example:

    CurrencyConverterSoap service = new CurrencyConverterSoap( );
    service.setQAManager(mgr);
    service.setProperty("WS_CONNECTOR_ADDRESS", "ianywhere.connector.currencyconvertor\\");

    Note that the final \\ in the address must be included.

 See also
 Example