title: How to use Mule schema-validation-filter for validating SOAP Request
body: <p>I was exploring Mule <strong>schema-validation-filter</strong> which is used to validate XML input against a xsd schema.... I have no Idea how to implement this <strong>schema-validation-filter</strong>... I thought of using it against a incoming SOAP request for a web service .. So, I have the following approach to validate a SOAP request :-</p>
  
  <pre><code> &lt;mulexml:schema-validation-filter name="Schema_Validation" schemaLocations="MainData.xsd" returnResult="true" doc:name="Schema Validation" /&gt;  
  
  &lt;flow name="ServiceFlow" doc:name="ServiceFlow"&gt;
  
  &lt;http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8082" path="mainData" doc:name="HTTP"/&gt;
  
     &lt;async doc:name="Async"&gt;
              &lt;mulexml:object-to-xml-transformer doc:name="Object to XML"/&gt;
              &lt;message-filter  doc:name="filter to validate xml against xsd" throwOnUnaccepted="true" &gt;
                  &lt;filter ref="Schema_Validation"/&gt;
              &lt;/message-filter&gt;
  
              &lt;logger message="Doneeeeee" level="DEBUG" doc:name="Logger"/&gt;
          &lt;/async&gt;  
  
  &lt;cxf:jaxws-service  validationEnabled="true" serviceClass="com.test.services.schema.maindata.v1.MainData"  doc:name="SOAP"/&gt;
  
  &lt;component class="com.test.services.schema.maindata.v1.Impl.MainDataImpl" doc:name="JavaMain_ServiceImpl"/&gt;
  
  &lt;/flow&gt; 
  </code></pre>
  
  <p>But whenever I test the service using SOAP UI I get the following exception :-</p>
  
  <pre><code>Root Exception stack trace:
  org.mule.api.routing.filter.FilterUnacceptedException: Message has been rejected by filter. Message payload is of type: DocumentImpl
      at org.mule.routing.MessageFilter.filterUnacceptedException(MessageFilter.java:96)
      at org.mule.processor.AbstractFilteringMessageProcessor.handleUnaccepted(AbstractFilteringMessageProcessor.java:58)
      at org.mule.processor.AbstractFilteringMessageProcessor.process(AbstractFilteringMessageProcessor.java:44)
      at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
      at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:58)
      at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
      at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
      at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:58)
      at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
      at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
      at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
      at org.mule.interceptor.AbstractEnvelopeInterceptor.process(AbstractEnvelopeInterceptor.java:51)
      at org.mule.processor.AsyncInterceptingMessageProcessor.processNextTimed(AsyncInterceptingMessageProcessor.java:118)
      at org.mule.processor.AsyncInterceptingMessageProcessor$AsyncMessageProcessorWorker$1.process(AsyncInterceptingMessageProcessor.java:189)
      at org.mule.processor.AsyncInterceptingMessageProcessor$AsyncMessageProcessorWorker$1.process(AsyncInterceptingMessageProcessor.java:182)
      at org.mule.execution.ExecuteCallbackInterceptor.execute(ExecuteCallbackInterceptor.java:16)
      at org.mule.execution.HandleExceptionInterceptor.execute(HandleExceptionInterceptor.java:30)
      at org.mule.execution.HandleExceptionInterceptor.execute(HandleExceptionInterceptor.java:14)
      at org.mule.execution.BeginAndResolveTransactionInterceptor.execute(BeginAndResolveTransactionInterceptor.java:54)
      at org.mule.execution.ResolvePreviousTransactionInterceptor.execute(ResolvePreviousTransactionInterceptor.java:44)
      at org.mule.execution.SuspendXaTransactionInterceptor.execute(SuspendXaTransactionInterceptor.java:50)
      at org.mule.execution.ValidateTransactionalStateInterceptor.execute(ValidateTransactionalStateInterceptor.java:40)
      at org.mule.execution.IsolateCurrentTransactionInterceptor.execute(IsolateCurrentTransactionInterceptor.java:41)
      at org.mule.execution.ExternalTransactionInterceptor.execute(ExternalTransactionInterceptor.java:48)
      at org.mule.execution.RethrowExceptionInterceptor.execute(RethrowExceptionInterceptor.java:28)
      at org.mule.execution.RethrowExceptionInterceptor.execute(RethrowExceptionInterceptor.java:13)
      at org.mule.execution.TransactionalErrorHandlingExecutionTemplate.execute(TransactionalErrorHandlingExecutionTemplate.java:109)
      at org.mule.execution.TransactionalErrorHandlingExecutionTemplate.execute(TransactionalErrorHandlingExecutionTemplate.java:30)
      at org.mule.processor.AsyncInterceptingMessageProcessor$AsyncMessageProcessorWorker.doRun(AsyncInterceptingMessageProcessor.java:181)
      at org.mule.work.AbstractMuleEventWork.run(AbstractMuleEventWork.java:39)
      at org.mule.work.WorkerContext.run(WorkerContext.java:286)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      at java.lang.Thread.run(Thread.java:724)
  </code></pre>
  
  <p>I tried to search over internet to find a suitable approach to <strong>validate the SOAP request</strong> and use this <strong>schema-validation-filter</strong> .. but didn't find a solution... Please help me and let me know is this the correct way I am doing to validate a SOAP Request ..  What type of data format does the filter expect ?? and how to make it working ?</p>
  
  <p><strong>Updated flow :-</strong></p>
  
  <pre><code>&lt;mulexml:schema-validation-filter name="Schema_Validation" schemaLocations="MainData.xsd" returnResult="true" doc:name="Schema Validation" /&gt;  
  
  &lt;flow name="ServiceFlow" doc:name="ServiceFlow"&gt;
  
  &lt;http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8082" path="mainData" doc:name="HTTP"/&gt;
  
  
              &lt;mulexml:object-to-xml-transformer doc:name="Object to XML"/&gt;
              &lt;message-filter  doc:name="filter to validate xml against xsd" throwOnUnaccepted="true" &gt;
                  &lt;filter ref="Schema_Validation"/&gt;
              &lt;/message-filter&gt;
  
  &lt;cxf:jaxws-service  validationEnabled="true" serviceClass="com.test.services.schema.maindata.v1.MainData"  doc:name="SOAP"/&gt;
  
  &lt;component class="com.test.services.schema.maindata.v1.Impl.MainDataImpl" doc:name="JavaMain_ServiceImpl"/&gt;
  
  &lt;/flow&gt; 
  </code></pre>
  
  <p>Updated the flow by removing async block ... but still gets the same exception :- <strong>Message has been rejected by filter. Message payload is of type: DocumentImpl</strong></p>