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:

CREATE SERVICE "TestService" TYPE 'RAW' AUTHORIZATION OFF USER "dba" METHODS 'GET' AS call TestProcedure();

Stored procedure:

CREATE PROCEDURE "dba"."TestProcedure"() result (TestProcedureResult xml)
begin
    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;       
end;

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...
56225
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
22.9k9129269
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

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "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:

×104
×29
×13

question asked: 31 Jan '14, 07:50

question was seen: 642 times

last updated: 31 Jan '14, 09:30