on 2014 Jan 31 7:50 AM
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
Request clarification before answering.
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).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
82 | |
29 | |
9 | |
8 | |
7 | |
7 | |
7 | |
6 | |
6 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.