HttpWebRequest 捕获响应即使 500 内部服务器错误详细信息

时间:2020-12-21 13:33:18

标签: c# web-services soap webresponse

当错误答案 (500) 来自 Soap Web Services 时,我想查看错误详细信息。我可以使用soap工具,我可以使用soap工具执行此过程并查看错误详细信息。但是在 c# 中使用 WebResponse 类,我看不到错误详细信息。

你有关于这个主题的任何信息吗?

Soap UI 工具响应标头原始 soap tool response header raw soap tool error detail

WebResponse 异常 enter image description here

问候。

1 个答案:

答案 0 :(得分:0)

我终于得出了正确的结论。而且,我想分享一下有人可能需要它的想法。

catch (WebException ex)
{
    string exMessage = ex.Message;

    if (ex.Response != null)
    {
        using (var responseReader = new StreamReader(ex.Response.GetResponseStream()))
        {
            exMessage = responseReader.ReadToEnd();
        }
    }
}

错误详情:

<块引用>

err_details

祝大家新年快乐!