一个问题,我必须向客户端发送一条SOAP消息,并且在该消息中我还必须向他发送一个HTTP状态码500,现在有没有办法看到我依赖发送代码了,这是代码:
try
{
SOME CODE
}
catch (Exception ex)
{
if (ora_trn != null) ora_trn.Rollback();
WriteErrors.WriteToLogFile("WS.LOAD_DOK-OracleException", ex.ToString());
errorMessage = ex.Message;
//Error exception
soapEnvelop.LoadXml(@"<soap:Envelope xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema""><soap:Body><soap:Fault><faultcode>500</faultcode><faultstring>Internal Server Error</faultstring><detail><Response_status>1</Response_status><Description>" + ex.Message + "</Description></detail></soap:Fault></soap:Body></soap:Envelope>");
base.Context.Response.StatusCode = 500;
return soapEnvelop;
}
好的,现在我在这里记录整个错误消息:WriteErrors.WriteToLogFile("WS.LOAD_DOK-OracleException", ex.ToString());
通过此操作,我更改了状态代码:base.Context.Response.StatusCode = 500;
然后我将消息返回给客户:return soapEnvelop;
现在,我知道他通过以下方式获取SOAP消息:return soapEnvelop;但我也想知道他是否得到了代码500,是否有办法将结果写入文本文件或查看此代码:base.Context.Response.StatusCode = 500;是否依靠工作?
谢谢!