Reputation: 4551
I'm face with a situation where we cannot use schema to validate incoming request (basically schema is there but it accepts any String in request, wsdl designers have their own reasons to do that to accept request from different sources and flexibility). But when the request is received, I validate that the child element of request wrapper is what we expect (using XPath for that). Now if the child element is not what expected, I'd like to throw Soap Fault
with Client
code and may be include error message that schema validation failed, request doesn't contain valid element.
I'm using Mule 3.3 and doing my XPath
validation in <choice>
element and I want to throw exception in <otherwise>
block.
Soap Fault
manually in mule flow and outInterceptor
will solve the purpose as I'm not using schemaValidation
attribute of <cxf:proxyService>
.Here is part of my flow
<http:inbound-endpoint address="${service.address}" exchange-pattern="request-response">
<cxf:proxy-service wsdlLocation="classpath:service.wsdl" namespace="http://company.com/services/service" service="CompanyService" />
</http:inbound-endpoint>
<choice>
<when>.....</when>
<otherwise><!-- Here I want to throw Soap Fault ---></otherwise>
</choice>
<catch-exception-strategy>
<flow-ref name="generateErrorResponse" />
</catch-exception-strategy>
Upvotes: 3
Views: 3306
Reputation: 33413
Since you are using a cxf:proxy-service
you have complete control on the response. For example, if you add the following in your otherwise
block, you'll be able to create whatever SOAP fault you want:
<expression-component><![CDATA[
message.payload = '<soap:Fault xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'
+ '<faultcode>A code</faultcode><faultstring>A string</faultstring>'
+ '</soap:Fault>';
]]></expression-component>
Upvotes: 6