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

Writing mobile web service applications Next Page

Setting up .NET mobile web service applications


Before using .NET with QAnywhere, you must make the following changes to your Visual Studio .NET project:

Complete instructions follow.

To add references to the QAnywhere .NET API and mobile web services API in a Visual Studio .NET project
  1. Start Visual Studio .NET and open your project.

  2. In the Solution Explorer window, right-click the References folder and choose Add Reference from the popup menu.

    The Add Reference dialog appears.

  3. On the .NET tab, click Browse to locate iAnywhere.QAnywhere.Client.dll and iAnywhere.QAnywhere.WS.dll. The location of these files is (relative to your SQL Anywhere installation directory):

    From the appropriate directory for your environment, select each DLL and click Open.

  4. To verify that the DLLs are added to your project, open the Add Reference dialog and open the .NET tab. iAnywhere.QAnywhere.Client.dll and iAnywhere.QAnywhere.WS.dll appear in the Selected Components list. Click OK.

Referencing the data provider classes in your source code
To reference the QAnywhere .NET API and mobile web services API classes in your code
  1. Start Visual Studio .NET and open your project.

  2. If you are using C#, add the following lines to the list of using directives at the beginning of your file:

    using iAnywhere.QAnywhere.Client;
    using iAnywhere.QAnywhere.WS;
  3. If you are using Visual Basic .NET, add the following lines to the list of imports at the beginning of your file:

    Imports iAnywhere.QAnywhere.Client
    Imports iAnywhere.QAnywhere.WS
    

    The Imports lines are not strictly required. However, they allow you to use short forms for the QAnywhere and mobile web services classes. Without them, you can still use the fully qualified class name in your code. For example, the following code uses the long form:

    iAnywhere.QAnywhere.Client.QAManager 
    mgr = 
     new iAnywhere.QAnywhere.Client.QAManagerFactory.Instance.CreateQAManager(
    "qa_manager.props" );

    The following code uses the short forms:

    QAManager mgr = QAManagerFactory.Instance.CreateQAManager(
     "qa_manager.props" );
To initialize QAnywhere and mobile web services for .NET
  1. Include the iAnywhere.QAnywhere.Client and iAnywhere.QAnywhere.WS namespaces, as described in the previous procedure.

    using iAnywhere.QAnywhere.Client;
    using iAnywhere.QAnywhere.WS;
  2. Create a QAManager object.

    For example, to create a default QAManager object, invoke CreateQAManager with null as its parameter:

    QAManager mgr;
    mgr = QAManagerFactory.Instance.CreateQAManager( null );
    Tip

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

    For more information about QAManagerFactory, see QAManagerFactory class.

    Alternatively, you can create a QAManager object that is customized using a properties file. The properties file is specified in the CreateQAManager method:

    mgr = QAManagerFactory.Instance.CreateQAManager( 
      "qa_mgr.props" );

    where qa_mgr.props is the name of the properties file that resides on the remote device.

  3. Initialize the QAManager object. For example:

    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:

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

  4. 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.

    The QAManager is used by the instance of the web service binding class to perform messaging operations in the process of making web service requests. You specify the connector address to use to send web service requests through QAnywhere by setting the property WS_CONNECTOR_ADDRESS of the service binding class. You configure each QAnywhere web service connector with the URL of a web service to connect to, and if an application needs web services located at more than one URL, configure the connector for each 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

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

// QAnywhere initialization
  QAManager mgr = QAManagerFactory.Instance.CreateQAManager( null );
  mgr.SetProperty( "CONNECT_PARAMS", "eng=qanywhere;dbf=qanywhere.db;uid=ml_qa_user;pwd=qanywhere" );
  mgr.Open( AcknowledgementMode.IMPLICIT_ACKNOWLEDGEMENT );
  mgr.Start();
  
  // Instantiate the web service proxy
  CurrencyConvertorSoap service = new CurrencyConvertorSoap();
  service.SetQAManager( mgr );
  service.SetProperty( "WS_CONNECTOR_ADDRESS", "ianywhere.connector.currencyconvertor\\" );