Web Service Request Types

You can specify the type of client requests to send to the web server when creating a web client function or procedure. The TYPE clause of the CREATE PROCEDURE and CREATE FUNCTION statements formats requests before sending them to the web server.

Specifying an HTTP request format

Web client functions and procedures send HTTP requests when the specified format in the TYPE clause begins with an HTTP prefix.

For example, execute the following SQL statement in the web client database to create an HTTP procedure named PostOperation that sends HTTP requests to the specified URL:

CREATE PROCEDURE PostOperation(a INTEGER, b CHAR(128))
    URL 'HTTP://localhost:8082/dbname/SampleWebService'
    TYPE 'HTTP:POST';

In this example, requests are formatted as HTTP:POST requests, which would produce a request similar to the following:

POST /dbname/SampleWebService HTTP/1.0
ASA-Id: e88a416e24154682bf81694feaf03052
User-Agent: SQLAnywhere/16.0.0.3600
Accept-Charset: windows-1252, UTF-8, *
Date: Fri, 03 Feb 2012 15:02:49 GMT
Host: localhost:8082
Connection: close
Content-Type: application/x-www-form-urlencoded; charset=windows-1252
Content-Length: 12

a=123&b=data

Specifying a SOAP request format

Web client functions and procedures send HTTP requests when the specified format in the TYPE clause begins with a SOAP prefix.

For example, execute the following statement in the web client database to create a SOAP procedure named SoapOperation that sends SOAP requests to the specified URL:

CREATE PROCEDURE SoapOperation(intVariable INTEGER, charVariable CHAR(128))
    URL 'HTTP://localhost:8082/dbname/SampleSoapService'
    TYPE 'SOAP:DOC';

In this example, a SOAP:DOC request is sent to the URL when you call this procedure, which would produce a request similar to the following:

POST /dbname/SampleSoapService HTTP/1.0
ASA-Id: e88a416e24154682bf81694feaf03052
User-Agent: SQLAnywhere/16.0.0.3600
Accept-Charset: windows-1252, UTF-8, *
Date: Fri, 03 Feb 2012 15:05:13 GMT
Host: localhost:8082
Connection: close
Content-Type: text/xml; charset=windows-1252
Content-Length: 428
SOAPAction: "HTTP://localhost:8082/SoapOperation"

<?xml version="1.0"?>
<SOAP-ENV:Envelope
  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:m="HTTP://localhost:8082">
  <SOAP-ENV:Body>
    <m:SoapOperation>
      <m:intVariable>123</m:intVariable>
      <m:charVariable>data</m:charVariable>
    </m:SoapOperation>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

The procedure name appears in the <m:SoapOperation> tag within the body. The two parameters to the procedure, intVariable and charVariable, become <m:intVariable> and <m:charVariable>, respectively.

By default, the stored procedure name is used as the SOAP operation name when building a SOAP request. Parameter names appear in SOAP envelope tagnames. You must reference these names correctly when defining a SOAP stored procedure since the server expects these names in the SOAP request. The SET clause can be used to specify an alternate SOAP operation name for the given procedure. WSDLC can be used to read a WSDL from a file or URL specification and generate SQL stub functions or procedures. For all but the simplest cases (for example, a SOAP RPC call returning a single string value), it is recommended that function definitions be used rather than procedures. A SOAP function returns the full SOAP response envelope which can be parsed using OPENXML.