When a web browser or client application makes a web service request to an SAP Sybase IQ web service, the request is processed and a result set is returned in the response. SAP Sybase IQ supports several web service types that provide control over the result set format and how result sets are returned. You specify the web server type with the TYPE clause of the CREATE SERVICE or ALTER SERVICE statement after choosing an appropriate web service type.
The following web service types are supported:
The XML formatting is the equivalent of using the FOR XML RAW clause in a SELECT statement, such as in the following SQL statement example:
SELECT * FROM table-name FOR XML RAW
This service type provides the most control over the result set. However, you must generate the response by writing the necessary markup (HTML, XML) explicitly within your stored procedure. You can use the SA_SET_HTTP_HEADER system procedure to set the HTTP Content-Type header to specify the MIME type, allowing web browsers to correctly display the result set.
This service is used by AJAX to make HTTP calls to web applications. For an example of the JSON type, see %ALLUSERSPROFILE%\SybaseIQ\samples\SQLAnywhere\HTTP\json_sample.sql.
The following example illustrates the creation of a general HTTP web service that uses the RAW service type:
CREATE PROCEDURE sp_echotext(str LONG VARCHAR) BEGIN CALL sa_set_http_header( 'Content-Type', 'text/plain' ); SELECT str; END; CREATE SERVICE SampleWebService TYPE 'RAW' AUTHORIZATION OFF USER DBA AS CALL sp_echotext ( :str );