Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 10.0.1 » QAnywhere » Mobile Web Services » Writing mobile web service applications

Setting up .NET mobile web service applications Next Page

Setting up Java mobile web service applications

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

To 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 install-dir\java:

  2. Import the ianywhere.qanywhere.client and packages:

    import ianywhere.qanywhere.client.*;
  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.");

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

  4. Initialize the QAManager object.;

    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:

    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.setProperty("WS_CONNECTOR_ADDRESS", "ianywhere.connector.currencyconvertor\\");

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

See also

To initialize mobile web services, you must create a QAManager and create an instance of the service binding class. For example:

// QAnywhere initialization
  Properties props = new Properties();
  props.put( "CONNECT_PARAMS", "eng=qanywhere;dbf=qanywhere.db;uid=ml_qa_user;pwd=qanywhere" );
  QAManager mgr = QAManagerFactory.getInstance().createQAManager( props ); AcknowledgementMode.IMPLICIT_ACKNOWLEDGEMENT );
  // Instantiate the web service proxy
  CurrencyConvertorSoap service = new CurrencyConvertorSoap();
  service.setQAManager( mgr );
  service.setProperty( "WS_CONNECTOR_ADDRESS", "ianywhere.connector.currencyconvertor\\" );