Monday, May 22, 2017

SOAP Fault

WCF serializes the exception in SOAP fault because exception are not allowed to be passed by WCF.

SOAP  fault are in XML format and platform independent. Soap fault contains

1. Fault Code
2. Fault Reason
3. Detail Element etc.

Detail element can be used to include any custom xml.

SOAP are formatted based  on SOAP 1.1. and 1.2
To view SOAP fault messages we need to enable message logging.
See How to enable Message Logging

You can see SOAP 1.1  fault message in .svcLog at the path what we have given in webconfig file.

If we have includeExceptionDetailInFault is set to false than the fault message for Calculator service would be like that

If includeExceptioDetailInFault is true than the fault message would be like that

You can see SOAP 1.2 messages after changing the binding to wsHttpBinding.

After changing the binding, SOAP message will not show you the exact reason of exception, as depicted in above picture. Even includeExceptionDetainInFault is true.

By default security is on here you can see log message after only setting the security to None. What log message is appear on browser may be different for SOAP fault. In case of of wsHttpBinding  and with security it shows the correct message on browser but doesn't show correct error message in SOAP fault until unless you set Security to None in host app.config file even you have set includeExceptionDetainInFault to true.

After setting the Security to None the message would be like that.

If include includeExceptionDetailInFaults is false and  Security is None than below SOAP 12. would received

No comments: