I am using WCF to connect to a business partner's web service. The web service does not have a defined fault contract - there are no <wsdl:fault>
elements in the WSDL.
When a fault occurs I get back a response like so (namespaces pruned for readability):
<s:Envelope>
<s:Body>
<Fault>
<faultcode>xxx</faultcode>
<faultstring>Business data error</faultstring>
<detail>
<Error>
<ErrorCode>xxx</ErrorCode>
<ErrorDescription>xxx</ErrorDescription>
</Error>
</detail>
</Fault>
</s:Body>
</s:Envelope>
In my code I can catch the exception like so:
try
{
proxy.DoWork();
}
catch(FaultException fex)
{
...
}
But because there is no defined FaultContract I can't use the generic-based FaultException
(like catch(FaultException<myFaultType>)
).
Long story short, I need to be able to examine the <ErrorCode>
and <ErrorDescription>
elements in the <Error>
element returned in the SOAP fault in the catch
above.
Thanks
You can use a example of the response to generate a schema with command xsd:
Then, you can generate the serealization classes with the same command:
Maybe you have to edit some attribute of the class foo.c, but I think this should be work.