Contact Us 1-800-596-4880

Return a Valid SOAP Response After a Fault

After you resolve the SOAP fault, add Transform Message on the OrderTshirt:\soapkit-config flow and author DataWeave that returns a valid payload instead of another fault. Use the correct namespace so the response matches the WSDL contract and avoids leading fault codes. Transform Message runs after the WSDL endpoint dispatches into your main flow and any backend calls.

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

    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 SoapUI, 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>