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

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


Lesson 3: Sending a SOAP request and receiving a SOAP response

In this lesson, you call the wrapper procedure created in the previous lesson, which sends a SOAP request to the web server that you created in lesson one. For more information about setting up a web client to send the SOAP requests described in this lesson, see Lesson 2: Setting up a web client to send SOAP requests and receive SOAP responses.

 Send a SOAP request
  1. Connect to the client database in Interactive SQL if it is not already open from lesson two.

    dbisql -c "UID=DBA;PWD=sql;SERVER=ftc_client"
  2. Enable logging of SOAP requests and responses.

    Execute the following SQL statements in Interactive SQL:

    CALL sa_server_option('WebClientLogFile', 'soap.txt');
    CALL sa_server_option('WebClientLogging', 'ON');

    These calls allow you to examine the content of the SOAP request and response. The requests and responses are logged to a file called soap.txt.

  3. Call the wrapper procedure to send a SOAP request and receive the SOAP response.

    Execute the following SQL statement in Interactive SQL:

    CALL FahrenheitToCelsius(212);

    This call passes a Fahrenheit value of 212 to the FahrenheitToCelsius procedure, which passes the value along with two customized SOAP headers to the FToC procedure. Both client-side procedures are created in the previous lesson.

The FToC web service procedure sends the Fahrenheit value and the SOAP headers to the web server. The SOAP request contains the following.

    <Authentication xmlns="SecretAgent" mustUnderstand="1">
      <userName alias="99">
    <Session xmlns="SomeSession">

The FtoC procedure then receives the response from the web server which includes a result set based on the Fahrenheit value. The SOAP response contains the following.

    <Authentication xmlns="SecretAgent" alias="99" mustUnderstand="1">
      <tns:FtoCServiceResult xsi:type='xsd:string'>
        &lt;tns:rowset xmlns:tns=&quot;http://localhost:8082/ftc&quot;&gt;&#x0A; 

The content of <SOAP-ENV:Header> is returned in inoutheader.

If you examine the SOAP response, you can see that the result set was encoded in the response by the FToCService web service. The result set is decoded and returned to the FahrenheitToCelsius procedure. The result set looks like the following when a Fahrenheit value of 212 is passed to the web server:

<tns:rowset xmlns:tns="http://localhost:8082/ftc"> 

The SELECT statement in the FahrenheitToCelsius procedure uses the OPENXML function to parse the SOAP response, extracting the Celsius value defined by the tns:answer structure.

The following result set is generated in Interactive SQL:

temperature Celsius
212 100
 See also