%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"
}
Prevent the SOAP Fault
After resolving the generated SOAP fault, add the Transform Message component to the flow and specify a message in DataWeave to respond to the request and implement the operation. In the DataWeave code, use the proper namespace
to avoid a fault code at the beginning of the response to the request.
The Transform Message component works on the process side after you reach the endpoint defined in the WSDL. This action triggers the execution of the main flow of the Mule application, which calls the backend flow.
-
In Studio, in the OrderTshirt:\soapkit-config flow, open the Transform Message component.
The Transform Message properties window displays the generated DataWeave code.
-
Modify the DataWeave code as follows:
-
Save and rerun the project.
-
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>