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

SQL Anywhere 12.0.0 » SQL Anywhere Server - Programming » HTTP web services » HTTP web service examples » Tutorial: Using JAX-WS to access a SOAP/DISH web service

 

Lesson 1: Set up a web server database to receive SOAP requests and send SOAP responses

In this lesson, you set up a SQL Anywhere web server running SOAP and DISH web services that handles JAX-WS client application requests.

 To set up a database server for receiving RAW requests and sending RAW responses
  1. Start the SQL Anywhere demo database using the following command:

    dbsrv12 -xs http(port=8082) samples-dir\demo.db

    This command indicates that the HTTP web server should listen on port 8082 for requests. Use a different port number if 8082 is disallowed on your network.

  2. Connect to the database server with Interactive SQL using the following command:

    dbisql -c "UID=DBA;PWD=sql;SERVER=demo"
  3. Create a stored procedure that lists Employees table columns.

    Run the following SQL script in Interactive SQL:



    CREATE PROCEDURE ListEmployees()
    RESULT (
        EmployeeID            INTEGER,
        Surname               CHAR(20),
        GivenName             CHAR(20),
        StartDate             DATE,
        TerminationDate       DATE )
    BEGIN
        SELECT EmployeeID, Surname, GivenName, StartDate, TerminationDate 
        FROM Employees;
    END;

    This script creates a new procedure named ListEmployees that defines the structure of the result set output, and selects certain columns from the Employees table.

  4. Create a new SOAP service to accept incoming requests.

    Run the following SQL script in Interactive SQL:

    CREATE SERVICE "WS/EmployeeList"
        TYPE 'SOAP'
        FORMAT 'CONCRETE' EXPLICIT ON
        DATATYPE ON
        AUTHORIZATION OFF
        SECURE OFF
        USER DBA
        AS CALL ListEmployees();

    This script creates a new SOAP web service named WS/EmployeeList that generates a SOAP type as output. It calls the ListEmployees procedure when a web client sends a request to the service.

    SOAP web services accessed from JAX-WS should be declared with the FORMAT 'CONCRETE' clause. The EXPLICIT ON clause indicates that the corresponding DISH service should generate XML Schema that describes an explicit dataset object based on the result set of the ListEmployees procedure. The EXPLICIT clause only affects the generated WSDL document. For more information about the EXPLICIT clause, see CREATE PROCEDURE statement (web clients).

    DATATYPE ON indicates that explicit data type information is generated in the XML result set response and the input parameters. This option does not affect the WSDL document that is generated. For more information about the DATATYPE clause, see CREATE PROCEDURE statement (web clients).

  5. Create a new DISH service to act as a proxy for the SOAP service and to generate the WSDL document.

    Run the following SQL script in Interactive SQL:

    CREATE SERVICE "WSDish"
        TYPE 'DISH'
        FORMAT 'CONCRETE'
        GROUP "WS"
        AUTHORIZATION OFF
        SECURE OFF
        USER DBA;

    DISH web services accessed from JAX-WS should be declared with the FORMAT 'CONCRETE' clause. The GROUP clause identifies the SOAP services that should be handled by the DISH service. The EmployeeList service created in the previous step is part of the GROUP WS because it is declared as WS/EmployeeList.

  6. Verify that the DISH web service is functional by accessing it through a web browser.

    Open your web browser and go to [external link] http://localhost:8082/demo/WSDish.

    The DISH service automatically generates a WSDL document that appears in the browser window. Examine the EmployeeListDataset object, which looks similar to the following output:



    <s:complexType name="EmployeeListDataset">
    <s:sequence>
    <s:element name="rowset">
      <s:complexType>
      <s:sequence>
      <s:element name="row" minOccurs="0" maxOccurs="unbounded">
        <s:complexType>
        <s:sequence>
        <s:element minOccurs="0" maxOccurs="1" name="EmployeeID" 
            nillable="true" type="s:int" /> 
        <s:element minOccurs="0" maxOccurs="1" name="Surname" 
            nillable="true" type="s:string" /> 
        <s:element minOccurs="0" maxOccurs="1" name="GivenName" 
            nillable="true" type="s:string" /> 
        <s:element minOccurs="0" maxOccurs="1" name="StartDate" 
            nillable="true" type="s:date" /> 
        <s:element minOccurs="0" maxOccurs="1" name="TerminationDate" 
            nillable="true" type="s:date" /> 
        </s:sequence>
        </s:complexType>
      </s:element>
      </s:sequence>
      </s:complexType>
    </s:element>
    </s:sequence>
    </s:complexType>

    EmployeeListDataset is the explicit object generated by the FORMAT 'CONCRETE' and EXPLICIT ON clauses in the EmployeeList SOAP service. In a later lesson, the wsimport application uses this information to generate a SOAP 1.1 client interface for this service.

  7. (optional) Restore the sample database (demo.db) to its original state by following the steps found here: Recreate the sample database (demo.db).

 See also