Mule: apply filters and transformers according to HTTP method with REST router (and error handling) <p>I am struggling a little to satisfy my use-case with the Mule REST module. I'd like to have different transformations according to templateUri and HTTP method.</p> <p>Here is my configuration:</p> <pre><code> &lt;flow name="http-interface"&gt; &lt;http:inbound-endpoint address="http://localhost:8555" exchange-pattern="request-response"/&gt; &lt;rest:router templateUri="/schedule"&gt; &lt;rest:post&gt; &lt;mxml:schema-validation-filter schemaLocations="xsd/scheduler.xsd" returnResult="true"/&gt; &lt;mxml:jaxb-xml-to-object-transformer jaxbContext-ref="jaxb-context"/&gt; &lt;vm:outbound-endpoint path="addjob"/&gt; &lt;/rest:post&gt; &lt;/rest:router&gt; &lt;choice-exception-strategy&gt; &lt;catch-exception-strategy when="exception.causedBy(org.mule.api.routing.filter.FilterUnacceptedException)"&gt; &lt;logger level="ERROR" message="FilterUnacceptedException #[message]"/&gt; &lt;set-payload value="An error occurred while validating request. Please check the XML payload"/&gt; &lt;set-property propertyName="http.status" value="400"/&gt; &lt;/catch-exception-strategy&gt; &lt;catch-exception-strategy when="exception.causedBy(java.lang.NullPointerException)"&gt; &lt;logger level="ERROR" message="NullPointerException #[message]"/&gt; &lt;set-payload value="An error occurred while validating request. Please check the XML payload"/&gt; &lt;set-property propertyName="http.status" value="400"/&gt; &lt;/catch-exception-strategy&gt; &lt;/choice-exception-strategy&gt; &lt;/flow&gt; </code></pre> <p>When invalid XML is posted to the endpoint, I am getting a NullPointerException in NestedProcessorChain.processWithExtraProperties. Hence the nasty catch for this exception (not ideal).</p> <p>My IDE gives schema validation errors both for rest:router in flow and the mxml filter/transformer in the rest:post element. I can remove the first by putting rest:router inside the inbound-endpoint. Results are the same, and most examples don't have this</p> <p>I tried moving the filter/transformation to a separate flow on a VM endpoint. Validation is clean, but then I can't figure out how to get the HTTP error code and response back to the client.</p> <p>Any help much appreciated, Alfie.</p>