我必须使用SOAP来使用第三方web服务。让它与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
?
发布于 2010-02-19 03:53:55
是的,但它并不是很优雅。请参阅此论坛帖子底部的消息检查器代码:
http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/435850aa-bf74-4158-a29a-256135207948
基本上,您可以接收传入的消息并对其进行修改,以便WCF可以处理它。
发布于 2010-04-07 02:54:31
我相信与WCF System.ServiceModel.Channels.ServiceChannel.HandleReply / System.ServiceModel.Channels.MessageFualt.CreateFault.相比,老式的System.Web.Services.SoapHttpClientProtocol类对不符合标准的错误更能容忍。
FWIW。
https://stackoverflow.com/questions/2287635
复制相似问题