Nav

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 soap:Server faultcode at the beginning of the response to the request.

The Transform Message component works on the process side after the endpoint defined in the WSDL has been hit, triggering the main flow of the Mule application to execute, which then calls the backend flow.

  1. Remove the Set Payload element from the flow OrderTshirt:api-config.

  2. Drag a Transform Message component from the Mule palette to replace Set Payload.

    Leave the Source section of the APIkit backend flow empty.

    apikit-for-soap-e8679
  3. Select the Transform Message component.

    The user interface displays the input and output for the current operation, OrderTshirt as input, and OrderTshirtResponse as output.

  4. In the properties editor, specify the payload as follows:

    
              
           
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    
    %dw 1.0
    %output application/xml
    %namespace ns0 http://mulesoft.org/tshirt-service
    ---
    {
      ns0#OrderTshirtResponse: {
        orderId: "I got a request from "
        ++ payload.ns0#OrderTshirt.name
      }
    }
    apikit-for-soap-475c0
  5. Save and rerun the project.

  6. In the SoapUI client, repeat the request.

    The output changes to a valid response:


       
    
1
2
3
4
5
6
7
<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>