Please be aware that the SAP SQL Anywhere Forum will be shut down on August 29th, 2024 when all it's content will be migrated to the SAP Community.

I've got a web service 'TestService' which calls a stored procedure 'TestProcedure'. I'd like to include some error handling (e.g. the web service is called with the wrong parameters).

But when I use the HTTP___RESPONSE_HEADER function to retrieve the HTTP status code, the result is empty. Am I missing something?

The client who sends the request receives the HTTP status code correctly, is just not possible to retrieve the value in the stored procedure.

Web service:


Stored procedure:

CREATE PROCEDURE "dba"."TestProcedure"() result (TestProcedureResult xml)
    declare sReponse xml;

    /* Set 'Bad Request' status */
    call sa_set_http_header('@HttpStatus','400');

    /* Set Content-Type to XML */
    call sa_set_http_header('Content-Type','application/xml');

    /* Write messages to console */ 
    message 'Status code: '||http_response_header('@HttpStatus') to console;
    message 'Content-Type: '||http_response_header('Content-Type') to console;

    set sReponse = xmlelement(name "Error",'This is not a valid request');
    select sReponse;       

In the console the following lines are displayed:

Status code:
Content-Type: application/xml

asked 31 Jan '14, 07:50

Patrick%20Eijkelhardt's gravatar image

Patrick Eijk...
accept rate: 0%

For those not familiar with this feature, the http_response_header() builtin function is used to query the outgoing header that will be sent in the response to the web service call.

However, I just checked the code and despite what the documentation says the http_response_header does not currently recognize the special @HttpStatus 'header' name ... so I'm not sure how it ever got into the documentation. Since I can see that this would be a useful feature, I'll see about getting this fixed in a future SP (aka EBF).

permanent link

answered 31 Jan '14, 09:23

Mark%20Culp's gravatar image

Mark Culp
accept rate: 41%

Mark, thanks for the response!

(31 Jan '14, 09:30) Patrick Eijk...
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 31 Jan '14, 07:50

question was seen: 2,339 times

last updated: 31 Jan '14, 09:30