NetTalk Central
NetTalk Web Server => Web Server - Ask For Help => Topic started by: peterH on November 16, 2011, 06:27:48 AM
-
Hi,
I've written a soap server and I'd like to change the server response code in certain situations.
Instead of returning
HTTP/1.1 200 OK
I would like to return e.g.
HTTP/1.1 500 ERROR
Where and how would I do that?
Thanks
Peter
-
Hi Peter,
>> ... certain situations.
The exact situation will matter a lot as to where exactly you do stuff - ie are you coming from a NetWebPage, a NetWebBrowse - and so on.
I think the method you're interested in is p_web.SendError.
This is prototyped as
NetWebServerWorker.SendError PROCEDURE (long p_ErrorNumber, string p_ErrorString, string p_ErrorDescription)
so for example you can do a
p_web.SendError(500,'Internal Server Error','The server is kaput!')
Some common response codes are;
! "200" ; OK
! "201" ; Created
! "202" ; Accepted
! "204" ; No Content
! "301" ; Moved Permanently
! "302" ; Moved Temporarily
! "304" ; Not Modified
! "400" ; Bad Request
! "401" ; Unauthorized
! "403" ; Forbidden
! "404" ; Not Found
! "500" ; Internal Server Error
! "501" ; Not Implemented
! "502" ; Bad Gateway
! "503" ; Service Unavailable
On the subject of error 500 - that's considered to be a very bad "generic" error, although lots of SOAP servers use it. It's much better to have an error in the 400 range if the request itself is invalid.
cheers
Bruce
-
Hi Bruce,
You're right, I did get the idea of using error 500 from looking at other soap servers around.And I take your advice, it's not the right thing to do. After all I do return a meaningful error message so using 500 is misleading to say the least.
Thank you
Peter