Loading

How to retrieve the soap fault message returned by Web Service Consumer in Mule 4

Publish Date: Jul 25, 2025
Steps

GOAL

This article explains on how to retrieve the soap fault message returned by webservice consumer in Mule 4.x

PROCEDURE

In Mule 4.x, to obtain a soap fault when using webservice consumer message processor, following approach can be taken:

  • Create a Mule 4 error handler in the flow, within that select one of the handler "on-error-propagate" or "on-error-continue" depending on the logic you require.
  • Choose the error type as WSC:SOAP_FAULT
  • Inside the error handler, you can retrieve the SOAP fault data and set it to a payload or in the logger. 
Example flow

Below is a sample code that shows the above steps to set the payload to the value of the SOAP fault:
<error-handler>
    <on-error-continue enableNotifications="true" logException="true" doc:name="On Error Continue" type="WSC:SOAP_FAULT">
        <ee:transform doc:name="Transform Message" doc:id="f7ba699b-4c99-4c46-9449-7167fee98101" >
            <ee:message>
                <ee:set-payload ><![CDATA[%dw 2.0
                    output application/xml
                    ns ns0 http://mulesoft.org/tshirt-service
                    ns soap http://schemas.xmlsoap.org/soap/envelope/
                    ---
                    {
                        soap#Envelope: {
                        soap#Body: {
                            soap#Fault: {
                                    faultcode: error.errorMessage.payload.faultCode.prefix ++ ":"++ error.errorMessage.payload.faultCode.localPart,
                                    faultstring: error.description,
                                }   
                            }
                        }
                    }]]>
                </ee:set-payload>
            </ee:message>
        </ee:transform>
    </on-error-continue>
</error-handler>

Disclaimer: this is provided as a reference for your own usage and it's not part of the official Mule product so its use will be considered as a custom implementation made by the customer.

 

Knowledge Article Number

001114925

 
Loading
Salesforce Help | Article