I have a listener listening for soap request:
<flow name="application-main">
<http:listener config-ref="storis-httpListenerConfig"
path="${application.path}">
<http:response
statusCode="#vars.httpStatus default 200">
<http:body>#payload</http:body>
<http:headers>#attributes.protocolHeaders default {}</http:headers>
</http:response>
<http:error-response
statusCode="#vars.httpStatus default 500">
<http:body>#payload</http:body>
<http:headers>#attributes.protocolHeaders default {}</http:headers>
</http:error-response>
</http:listener>
<apikit-soap:router
config-ref="application-soapkit-config">
<apikit-soap:message>#payload</apikit-soap:message>
<apikit-soap:attributes>#[
%dw 2.0
output application/java
---
{
headers: attributes.headers,
method: attributes.method,
queryString: attributes.queryString
}]
</apikit-soap:attributes>
</apikit-soap:router>
</flow>
I have a validation check in the main flow, like following
<validation:is-null
message="UUID cannot be null or empty string"
value="#vars.application.UUID" doc:name="Validation" />
Then I have error handler handling the validation error:
<on-error-propagate enableNotifications="true"
logException="true" type="VALIDATION:NOT_NULL">
<ee:transform
xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd"
doc:id="cdafca59-789a-4ed5-873b-f593dedf12c5"
doc:name="Validation Error">
<ee:message>
<ee:set-payload><![CDATA[%dw 2.0
output application/java
ns soap http://schemas.xmlsoap.org/soap/envelope
---
{
body: {
soap#Fault: {
faultcode: "soap:Server",
faultstring: "VALIDATION FAILED"
}
} write "application/xml"
}]]></ee:set-payload>
</ee:message>
<ee:variables>
<ee:set-variable variableName="httpStatus"><![CDATA[400
]]></ee:set-variable>
</ee:variables>
</ee:transform>
<logger level="INFO" doc:name="Logger" doc:id="1f617926-b084-4cd6-86b5-cf8864219963" message="After Validation error handling: #payload"/>
</on-error-propagate>
I saw the error handling payload but it is not thrown to the client, the response client got is still the request. Can't figure out why the error payload is not returning back to the calling client.
You cannot set a payload with On Error Propagate , if you want your payload to be sent to your client you have to go with on error continue and set an error payload there.