我必须使用SOAP消费到第三方Web服务。使用WCF很容易,但现在我遇到了SOAP错误。该服务发送我一个不正确的SOAP错误:如何在WCF中处理错误的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
?
谢谢你,那正是我需要的!它很优雅:) – chris166 2010-02-19 13:37:15