I successfully work with a third-party soap service. I added a service link to a soapy web service that automatically generated classes.
If an error occurs, the soap response is returned as follows:
<SOAP-ENV:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> <SOAP-ENV:Body> <SOAP-ENV:Fault> <faultcode>SOAP-ENV:Client</faultcode> <faultstring xsi:type="xsd:string">Error while reading parameters of method 'Demo'</faultstring> <detail xsi:type="xsd:string">Invalid login or password. Connection denied.</detail> </SOAP-ENV:Fault> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
I can catch the error, but not extract the item. I tried the following code:
catch (FaultException ex) { MessageFault msgFault = ex.CreateMessageFault(); var elm = msgFault.GetDetail<string>();
However, these are Errors with the following as a detail node is not an object:
Expecting element 'string' from namespace 'http://schemas.datacontract.org/2004/07/MyDemoNamespace'.. Encountered 'Text' with name '', namespace ''.
This is a third-party API, so I cannot change the answer.
John
source share