Nav
You are viewing an older version of this topic. To go to a different version, use the version menu at the upper-right. +

To Display a Typed Fault

In this procedure, you make the ListInventory operation display the typed fault. For the tshirt2.wsdl file, there is just one typed fault named TshirtFault, which is mapped to every operation that the WSDL has: OrderTshirt, ListInventory, and TrackOrder.

APIkit for SOAP supports the following types of SOAP faults:

  • Soap Fault 1.1

  • Soap Fault 1.2

You can select either type using any WSDL file, even for those files that do not contain typed faults.

  1. In Studio, delete the Set Payload processor of the ListInventory:api-config flow.

  2. Search for fault in the palette, drag and drop SOAP Fault into the ListInventory:api-config flow.

  3. In the properties editor, select ListInventory from the Operation drop-down.

  4. Select or accept the default TshirtFault from the Fault Type drop-down.

  5. Add a Transform Message component before the SOAP Fault component.

  6. In the component properties, set up the following DataWeave code:

    
              
           
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    
    %dw 1.0
     %output application/xml
     %namespace ns0 http://mulesoft.org/tshirt-service
     %namespace soap http://www.w3.org/2003/05/soap-envelope
    ---
     soap#Fault: {
       faultcode: "soap:Server",
       faultstring: "The error details",
       detail: {
         ns0#TshirtFault: {
          errorStuff: 500
         }
       }
     }
  7. Save and rerun the project.

    Using the SoapUI client, run the ListInventory operation.

    The client returns the following envelope instead of the default fault:

    
              
           
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
       <soap:Body>
          <soap:Fault xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
             <faultcode>soap:Server</faultcode>
             <faultstring>The error details</faultstring>
             <detail>
                <ns0:TshirtFault xmlns:ns0="http://mulesoft.org/tshirt-service">
                   <errorStuff>500</errorStuff>
                </ns0:TshirtFault>
             </detail>
          </soap:Fault>
       </soap:Body>
    </soap:Envelope>

We use cookies to make interactions with our websites and services easy and meaningful, to better understand how they are used and to tailor advertising. You can read more and make your cookie choices here. By continuing to use this site you are giving us your consent to do this.

+