我需要使用SOAP调用第三方网络服务。使用WCF很容易实现,但是现在我遇到了SOAP故障问题。该服务向我发送了一个不正确的SOAP故障信息:
<?xml version="1.0" encoding="utf-8" ?>
<SOAP-ENV:Envelope
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<SOAP-ENV:faultcode>14</SOAP-ENV:faultcode>
<SOAP-ENV:faultstring>Unknown Function</SOAP-ENV:faultstring>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
错误在于
<faultcode>
元素不能有命名空间:System.ServiceModel.CommunicationException : Server returned an invalid
SOAP Fault. Please see InnerException for more details.
----> System.Xml.XmlException : Start element 'faultcode' from namespace
'' expected. Found element 'SOAP-ENV:faultcode' from namespace
'http://schemas.xmlsoap.org/soap/envelope/'.
我无法更改原始Web服务 - 但是在WCF中是否有任何东西可以使用,以便以某种方式处理这些故障消息而不会一直收到CommunicationException
?