How to handle the wrong SOAP error in WCF?

I need to use a third-party web service using SOAP. It was easy to get it working with WCF, but now I have a problem with SOAP errors. The service is sending me the wrong SOAP error:

<?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>

The error is that <faultcode>there should not be a namespace:

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/'.

I cannot change the original web service, but is there anything in WCF that I can use to handle these error messages in any way without receiving CommunicationExceptionall the time?

+3
source share
2 answers

Yes, but it's not quite elegant. See the code post inspector at the bottom of this forum post:

http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/435850aa-bf74-4158-a29a-256135207948

, , WCF.

+11

, System.Web.Services.SoapHttpClientProtocol , , WCF. - .Channels.ServiceChannel.HandleReply/System.ServiceModel. Channels.MessageFualt.CreateFault.

FWIW.

-1

Source: https://habr.com/ru/post/1733324/


All Articles