Should my WCF webservice return a 500 or 200 http code (soap fault / functional return message)
after reading the SOA开发者_Python百科P 1.1 specs, it states that a SOAP Fault should return a http 500 errorcode when communication goes over a http binding, so when a SoapException is thrown, WCF returns a http 500 error code.
Now, I'm looking for some best practices to when return a functional soap error message and when to return a SOAP Fault.
What would you guys return when a functional error occurred while processing the message because of the input message contains some functional errors, a 500 SOAP Fault or a 200 Soap response containing some error message ?
http://www.ws-i.org/Profiles/BasicProfile-1.1-2006-04-10.html#HTTP_Server_Error_Status_Codes:
3.4.7 HTTP Server Error Status Codes
HTTP uses the 5xx series of status codes to indicate failure due to a server error.
R1126: An INSTANCE MUST return a "500 Internal Server Error" HTTP status code if the response envelope is a Fault.
UPDATE:
What would you guys return when a functional error occurred while processing the message because of the input message contains some functional errors, a 500 SOAP Fault or a 200 Soap response containing some error message ?
If the input message is invalid and prevents your service from doing its intended job, then yes - this clearly constitutes an exception, so I would return a SOAP fault in this case (something like FaultException<InvalidInputParameters>
).
And I would let WCF handle all the necessary gory details of whether or not and when to return what http error code, if necessary. WCF already does all of that for you - you just throw a SOAP fault in your service code and that's all there is for you.
精彩评论