Lesson 1: Setting up a web server to receive RAW requests and send RAW responses

In this lesson, you set up a SQL Anywhere web service server running a web service that tests the MIME-type setting of a web client.

 Set up a database server for receiving RAW requests and sending RAW responses
  1. Run the following command to create a SQL Anywhere database:

    dbinit echo
  2. Start the network database server using the following command:

    dbsrv12 -xs http(port=8082) -n echo echo.db

    This command indicates that the HTTP web server should listen on port 8082 for requests. Use a different port number if 8082 is disallowed on your network.

  3. Connect to the database server in Interactive SQL using the following command:

    dbisql -c "UID=DBA;PWD=sql;SERVER=echo"
  4. Create a new SOAP service to accept incoming requests.

    Execute the following SQL statement in Interactive SQL:

    CREATE SERVICE EchoService
    TYPE 'RAW'
    USER DBA
    AUTHORIZATION OFF
    SECURE OFF
    AS CALL Echo(:valueAsXML);

    This statement creates a new SOAP service named EchoService that generates a RAW type as output. It calls a stored procedure named Echo when a web client sends a request to the service. You create the Echo procedure in the next step.

  5. Create the Echo procedure to handle incoming requests. This procedure returns the body of the request.

    Execute the following SQL statements in Interactive SQL:



    CREATE PROCEDURE Echo( text LONG VARCHAR )
    BEGIN
        DECLARE body LONG VARCHAR;
        SET body = isnull( http_variable('text'), http_variable('body') );
        IF body IS NULL THEN
            SELECT 'failed';
        ELSE
            SELECT body;
        END IF;
    END;
 See also