如何更改SOAPException ResponseCode

时间:2011-01-25 07:11:00

标签: c# asp.net web-services exception-handling soapexception

我正在使用SoapException来处理我的网络服务中的无效输入和所有其他类型的异常处理。它工作正常,我能够格式化并向客户返回适当的信息。我遵循类似于此处解释的方法 http://www.codinghorror.com/blog/2004/08/throwing-better-soap-exceptions.html

现在我想更改SoapException发生时返回的响应代码( ResponseCode:500 Internal Server Error )。

以下是我发现XML时我自己的自定义SoapException数据的默认响应代码。我想将ResponseCode更改为200 ..是否可能以及如何?

ResponseCode: 500 (Internal Server Error)  
Connection:Close  
Content-Length:494  
Cache-Control:private  
Content-Type:text/xml; charset=utf-8  
Date:Tue, 25 Jan 2011 06:59:30 GMT  
Server:ASP.NET Development Server/8.0.0.0  
X-AspNet-Version:2.0.50727

1 个答案:

答案 0 :(得分:2)

根据WS-I Basic简介,支持John Sauders的上述警告:

“R1126如果响应消息是SOAP Fault,则实例必须使用”500 Internal Server Error“HTTP状态代码。”

http://www.ws-i.org/Profiles/BasicProfile-1.0-2004-04-16.html#refinement16488480