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

SAP Sybase SQL Anywhere 16.0 » 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.


This lesson assumes that you have set up a web server as instructed in lesson 1. See Lesson 1: Setting up a web server to receive SOAP requests and send SOAP responses.

This lesson assumes that you have set up a web client as instructed in lesson 2. See Lesson 2: Setting up a web client to send SOAP requests and receive SOAP responses.

This lesson assumes that you have the roles and privileges listed in the Privileges section at the start of this tutorial: Tutorial: Using SQL Anywhere to access a SOAP/DISH service.

  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">123456789</Session>

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:

Fahrenheit   Celsius
        212       100


Here is another sample call to the SOAP web service that will convert a temperature in Fahrenheit degrees to Celsius degrees.

CALL FahrenheitToCelsius(32);

The following result set is generated in Interactive SQL:

Fahrenheit   Celsius
         32         0

 See also