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.

Is there a way to throw Soap Fault manually in mule flow and

How to add custom fault string. I'm not sure if an outInterceptor will solve the purpose as I'm not using schemaValidation attribute of <cxf:proxyService>.

Thank you David. You're a rescuer. Is this technique a workaround for throwing exception? Will it be same thing if I use some template like Velocity or Freemarker to make response?
–
LearnerJan 17 '13 at 19:47

This technique gives you full control on the fault code and string: if you throw an exception, you'll only be able to control the fault string. And yes, you can use any technology you want to build the response for a cxf:proxy-service.
–
David DossotJan 17 '13 at 19:57

if you throw an exception, you'll only be able to control the fault string. How can I do that in mule flow without writing custom java component?
–
LearnerJan 17 '13 at 20:01