I have to consume to a third-party web service using SOAP. It was easy to get it to work with WCF, but now I have a problem with SOAP faults. The service sends me an incorrect SOAP fault:
<?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 the <faultcode>
must not have 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 can't change the original web service - but is there anything in WCF I can use to still handle these fault messages in some way without getting CommunicationException
all the time?