问题描述
限时送ChatGPT账号..我正在访问 SOAP 1.1 Web 服务,但它返回了一个错误.据我所知,Web 服务没有在 WSDL 中定义任何错误契约.我的 WCF 客户端将故障映射到 FaultException(而不是 FaultException
I'm accessing a SOAP 1.1 web service, and it's returning a fault. The web service does not define any fault contract in the WSDL as far as I can see. My WCF client maps the fault to a FaultException (rather than a FaultException<T>). This all makes sense. The problem is that the service is returning some useful diagnostic information in the detail element of the fault, which I'd like to access so that I can dump it to a trace log. It seems that FaultException does not provide any access to the detail element, presumably because without a fault contract it doesn't know what is in there.
但我不需要反序列化细节 XML - 只需将原始 XML 作为字符串就可以用于诊断目的.
But I don't need to deserialize the detail XML - just the raw XML as a string will do fine for diagnostic purposes.
在这种情况下,有没有办法从 WCF 客户端访问详细的 XML?
Is there any way to get access to the detail XML from a WCF client, in this scenario?
推荐答案
详见此处:http://www.theruntime/blogs/jacob/archive/2008/01/28/getting-at-the-details.aspx
您可以使用此解决方法获取详细信息:
you can use this workaround to obtain the details:
} catch (FaultException soapEx)
{
MessageFault mf = soapEx.CreateMessageFault();
if (mf.HasDetail)
{
XmlDictionaryReader reader = mf.GetReaderAtDetailContents();
...
}
}
这篇关于如何从 WCF 客户端访问 SOAP 1.1 故障详细信息(无故障合同)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论