[mule-user] Schema Validation Filter

394 views
Skip to first unread message

Ben Leedham

unread,
Feb 22, 2012, 6:25:35 AM2/22/12
to us...@mule.codehaus.org
Hi,

I'm using Mule Studio to set up a simple flow. The whole flow works apart from my schema validation filter. I have an HTTP inbound endpoint which I am posting XML to. I then want that XML validated by the schema validation filter.

Initially the flow was just stopping dead at the schema validation filter, so I did some digging and ended up creating a global schema validation filter and adding it as a ref to a message filter and telling it to throwOnUnaccepted so I could get an exception, like this:


<message-filter throwOnUnaccepted="true" doc:name="Schema Validation">
<filter ref="Schema_Validation"/>
</message-filter>

This is good as I actually get an error now, which is:


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:99)
at org.mule.processor.AbstractFilteringMessageProcessor.handleUnaccepted(AbstractFilteringMessageProcessor.java:62)
at org.mule.processor.AbstractFilteringMessageProcessor.process(AbstractFilteringMessageProcessor.java:48)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)


So I have a couple of questions. What payload type is the schema validation filter expecting? and how do I set that debug logging level?

All this is run within Mule Studio, no external install of Mule.

Thanks. --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email

Ben Leedham

unread,
Feb 22, 2012, 6:25:37 AM2/22/12
to us...@mule.codehaus.org
Come on guys. This is a really simple question, What payload type does the schema validation filter expect?

I wouldn't be asking it if the documentation was better. The schema validation filter documentation essentially says, it validates schemas.

This is a really simple use case, accept an XML message and validate that message against a schema.

If this is so hard to do in Mule why would I want to use it?

For people to choose to use Mule they need to evaluate it, it's fine not having documentation that is brilliant if you have a user forum that answers peoples questions.

I posted this last week and it got archived, I posted it again on Monday in the new forum and still no response.

it doesn't make Mule look great. --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email

David David

unread,
Feb 23, 2012, 5:42:37 AM2/23/12
to us...@mule.codehaus.org
Hi,

I am evaluating Mule Studio and have the same requirement. I agree with Ben that the documentation is a little weak in this area - some examples would be nice.

I would have thought that schema validation would be well documented.

Anybody got an answer to Ben's original post? --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email

philip parker

unread,
Feb 23, 2012, 7:06:37 AM2/23/12
to us...@mule.codehaus.org
Hi David/Ben,

I've got the schema validation working with an xml string.

Im my example I used a file poller then converted the bytes in a string, in the case of an exception (xml does not pass) you will need exception handling, does this answer your question?

Mule config:

xml:

name
phil
name2

xsd:

Phil --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email

Ben Leedham

unread,
Feb 23, 2012, 8:29:37 AM2/23/12
to us...@mule.codehaus.org
Hi Phillip,

I've tried doing as you suggested, in fact I had tried it before. I get exactly the same error. the odd thing being that I have now configured an error flow ref to pass the erroring message to onUnaccepted.

If I tell the Schema Validation Filter to returnResult the error endpoint gets a message containing a DocumentImpl. If I uncheck the returnResult, the Schema Validation Filter still errors but my error endpoint gets a message containing a String.

All very confusing. --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email

Pablo Kraan

unread,
Feb 23, 2012, 9:32:03 AM2/23/12
to us...@mule.codehaus.org
Regarding the returnResult flag: the schema validation filter needs to create a xml document in order to validate the message. When returnResult is true, that document is returned as the new payload, that avoids an extra parsing of the xml.
Regarding the rejection of your message: the rejection could be caused because the schema validation is "working" and the provided XML is not valid. If you set the log level to DEBUG, then there should be a log line like this "SchemaValidationFilter rejected a message because it apparently failed to validate against the schema". To know how to change the log level, take a look at:

Regards,
             Pablo

Mike Schilling

unread,
Feb 23, 2012, 1:55:24 PM2/23/12
to us...@mule.codehaus.org, Ben Leedham
The schema validation filter accepts pretty much any type you'd like to give it:
  • DOM node
  • DOM4J document
  • byte array
  • string
  • input stream
  • and a few more

A bad input type would throw an exception saying the payload can't be converted to XML, so I don't think that's your problem.  The message is actually failing validation. For more detailed information, you can set logging for the org.mule.module.xml.filters.SchemaValidationFilter class to DEBUG.

Mike

Ben Leedham

unread,
Feb 28, 2012, 6:37:41 AM2/28/12
to us...@mule.codehaus.org

Ben Leedham

unread,
Feb 28, 2012, 6:37:44 AM2/28/12
to us...@mule.codehaus.org
Thank you. I have added the debug logging to the app and I now get an Excpetion like:

DEBUG SchemaValidationFilter - SchemaValidationFilter rejected a message because it apparently failed to validate against the schema.

Excellent. I can now look at why it isn't validating. I do think it is quite strange though that this is the first Exception I get in Debug. I would have thought the fact the original Exception was telling me it wasn't the correct payload type meant that this new Exception was swallowed in the Exception stack.

That doesn't appear to be the case however, to me it would make more sense to stick out the actual Exception even in INFO mode. To have to turn debugging on just to get a simple Exception isn't very good, I understand the merit of debug logging when diagnosing issues, but this is the sort of Exception you would want to get instant info on in live, where debug won't be turned on. --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email
Reply all
Reply to author
Forward
0 new messages