Reputation: 21
I am using web service consumer and calling a soap service and it will return below soap fault incase of number of hits reaches more than the limit. When the soap fault is caught in the error handler under the type WSC:SOAP_FUALT, I want to read the faultstring and if it is "Maximum request limit reached, please try again later.", I dont want to consider it as failure and point the payload for retry.
So please let me know how to extract the fault string inorder to put a check on it.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<soapenv:Fault>
<faultcode>Internal Server Error</faultcode>
<faultstring>Maximum request limit reached, please try again later.</faultstring>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
Upvotes: 0
Views: 862
Reputation: 3315
The soap fault message returned by Web Service Consumer is stored within the errorMessage
field in the error
of the flow.
So you can use error.errorMessage.payload.Envelope.Body.Fault.faultstring
to access that string in your error handler block, and use it in the when
condition of the error handler itself to execute that handler when this message matches the required criteria. For example:
XML Code:
<on-error-continue enableNotifications="true"
logException="true" doc:name="On Error Continue"
doc:id="38283c80-4c20-46da-85e3-f47d5d5755b7" type="WSC:SOAP_FUALT"
when="#[(error.errorMessage.payload.Envelope.Body.Fault.faultstring default '') startsWith ('Maximum request limit reached')]">
<logger message="Error message caught by the error handler: #[error.errorMessage.payload.Envelope.Body.Fault.faultstring]" level="INFO" doc:name="Logger" doc:id="1f329e43-d401-412f-9479-f58bef4089c4" />
</on-error-continue>
Upvotes: 1
Reputation: 25837
You can use a simple DataWeave expression to extract the string:
%dw 2.0
output application/java
---
payload.Envelope.Body.Fault.faultstring
Output:
Maximum request limit reached, please try again later.
Upvotes: 0