Quick Start to Using SAP Sybase IQ As an HTTP Web Server

This section illustrates how to start an SAP Sybase IQ HTTP web server, create a web service, and access it from a web browser. It does not illustrate SAP Sybase IQ web service features, such as SOAP over HTTP support and application development, to a full extent. Many SAP Sybase IQ web service features are available that are beyond the scope of this guide.

Perform the following tasks to create an SAP Sybase IQ HTTP web server and HTTP web service:

  1. Start the SAP Sybase IQ HTTP web server while loading an SAP Sybase IQ database.

    Run the following command at a command prompt:

    iqsrv16 -xs http(port=8082) iqdemo.db
    Note: Use the iqsrv16 command to start a database server that can be accessed on a network.

    The -xs http(port=8082) option instructs the server to listen for HTTP requests on port 8082. Use a different port number if a web server is already running on port 8082.

  2. Use the CREATE SERVICE statement to create a web service that responds to incoming web browser requests.

    1. Connect to the demo.db database using Interactive SQL by running the following command:

      dbisql -c "dbf=iqdemo.db;uid=<user_id>;pwd=<password>"
    2. Create a new web service in the database.

      Execute the following SQL statement in Interactive SQL:

      CREATE SERVICE SampleWebService
          TYPE 'web-service-type-clause'
          AUTHORIZATION OFF
          USER DBA
          AS SELECT 'Hello world!';

      Replace web-service-type-clause with the desired web service type. The HTML type clause is recommended for web browser compatibility. Other general HTTP web service type clauses include XML, RAW, and JSON.

      The CREATE SERVICE statement creates the SampleWebService web service, which returns the result set of the SELECT statement. In this example, the statement returns "Hello world!"

      The AUTHORIZATION OFF clause indicates that authorization is not required to access the web service.

      The USER DBA statement indicates that the service statement should be run under the DBA login name.

      The AS SELECT clause allows the service to select from a table or function, or view data directly. Use AS CALL as an alternative clause to call a stored procedure.

  3. View the web service in a web browser.

    On the computer running the SAP Sybase IQ HTTP web server, open a web browser, such as Internet Explorer or Firefox, and go to the following URL:

    http://localhost:8082/demo/SampleWebService

    This URL directs your web browser to the HTTP web server on port 8082. SampleWebService prints "Hello world". The result set output is displayed in the format specified by the web-service-type-clause from step 2.

Other Sample Resources

Samples are included in the %ALLUSERSPROFILE%\SybaseIQ\samples\SQLAnywhere\http directory.

Other examples might be available on CodeXchange at http://www.sybase.com/developer/codexchange.