Contact Free trial Login

To Prevent the SOAP Fault

In this procedure, you resolve the SOAP fault you generated. You add the Transform Message component to the flow and specify a message in DataWeave for responding to the request, effectively implementing the operation. In the DataWeave code, you use the proper namespace to avoid a faultcode at the beginning of the response to the request.

The Transform Message component works on the process side after you hit the endpoint defined in the WSDL. This action triggers execution of the main flow of the Mule application, which then calls the backend flow.

  1. In Studio, in the OrderTshirt:\soapkit-config flow, click the Transform Message component to open it.

    The Transform Message properties window displays the generated DataWeave code.

  2. Modify the DataWeave code as follows:

    %dw 2.0
    output application/java
    ns ns0 http://mulesoft.org/tshirt-service
    ---
    {
        body: {
            ns0#OrderTshirtResponse: {
                orderId: "I got a request from " ++ (payload.body.ns0#OrderTshirt.name default "")
            }
        } write "application/xml"
    }
  3. Save and rerun the project.

  4. In the SoapUI client, resubmit the request to generate a SOAP fault.

    The output changes to a valid response:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Body>
      <ns0:OrderTshirtResponse xmlns:ns0="http://mulesoft.org/tshirt-service">
         <orderId>I got a request from John</orderId>
      </ns0:OrderTshirtResponse>
   </soap:Body>
</soap:Envelope>

Was this article helpful?

💙 Thanks for your feedback!

Edit on GitHub