2010-02-18 71 views
3

我必须使用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

回答

-1

我相信老派的System.Web.Services.SoapHttpClientProtocol类比WCF System.ServiceModel.Channels.ServiceChannel.HandleReply/System.ServiceModel更能容忍未达到鼻烟或标准故障.Channels.MessageFualt.CreateFault。

FWIW。