%dw 2.0
output application/xml
ns ns0 http://mulesoft.org/tshirt-service
ns soap http://schemas.xmlsoap.org/soap/envelope/
---
{
soap#Fault: {
faultcode: "soap:Server",
faultstring: "The error details",
detail: {
ns0#TshirtFault: {
errorStuff: 500
}
}
}
}
Display a Typed Fault
Make the ListInventory operation display the typed fault. The tshirt2.wsdl file includes the TshirtFault typed fault, which is mapped to the WSDL operations:
-
OrderTshirt -
ListInventory -
TrackOrder
APIkit for SOAP supports the following types of SOAP faults:
-
Soap Fault 1.1
-
Soap Fault 1.2
You can select either type by using any WSDL file, even for files that do not contain typed faults.
-
In Anypoint Studio, search for fault in the command palette.
Multiple
SOAP Faultcomponents can appear. -
Drag
SOAP Faultto theListInventory:api-configflow.If Operation Unavailable message appears, cancel the operation and select another
SOAP Faultcomponent. -
Repeat these steps until you find a version match.
-
In the properties editor, in Module Configuration, select
soapkit-config. -
In Operation, select
ListInventory. -
In Fault, select
Fault. -
Save the properties.
-
Select the
Transform Messagecomponent. -
Modify the DataWeave code as follows:
-
Save the project and run it again.
Using SoapUI, run the
ListInventoryoperation.The client returns the following envelope instead of the default fault:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <soap:Fault> <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>



