Quantcast

XML Validation... getting to the error messages using Camel

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

XML Validation... getting to the error messages using Camel

Robert J. Liguori
I'm using Spring DSL with a camel route to validate XML messages:

        <to uri="validator:file:schemas/schema_name.xsd"/>

How do I get to the error messages for invalid XML files that do not
pass validation?

Thanks!

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: XML Validation... getting to the error messages using Camel

David J. M. Karlsen
It will throw an ValidationException - see the docs for the component.
Den 4. sep. 2011 21:48 skrev "Robert J. Liguori" <[hidden email]>
følgende:
> I'm using Spring DSL with a camel route to validate XML messages:
>
> <to uri="validator:file:schemas/schema_name.xsd"/>
>
> How do I get to the error messages for invalid XML files that do not
> pass validation?
>
> Thanks!
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How do I get the exception information that is caught in Spring DSL routes?

Robert J. Liguori
In reply to this post by Robert J. Liguori
How do I get the exception information that is caught in Spring DSL
routes?

For, example, when I'm using the validation component, the exception
routes the invalid XML to the specified endpoint:

            ...
           <doCatch>
               
<exception>org.apache.camel.ValidationException</exception>
                <to uri="mock:invalid"/>
            </doCatch>
            ...

That's cool, but I want to see what the exception was... how do I get
to it?  Note that I'm new to Spring and Camel.

Thanks,
Robert
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How do I get the exception information that is caught in Spring DSL routes?

Claus Ibsen-2
On Thu, Sep 8, 2011 at 7:01 PM, Robert J. Liguori <[hidden email]> wrote:

> How do I get the exception information that is caught in Spring DSL
> routes?
>
> For, example, when I'm using the validation component, the exception
> routes the invalid XML to the specified endpoint:
>
>            ...
>           <doCatch>
>
> <exception>org.apache.camel.ValidationException</exception>
>                <to uri="mock:invalid"/>
>            </doCatch>
>            ...
>
> That's cool, but I want to see what the exception was... how do I get
> to it?  Note that I'm new to Spring and Camel.
>

The exception is stored as a property on the Exchange.
In java code its like this:

Exception cause = exchange.getProperty(Exchange.EXCEPTION_CAUGHT,
Exception.class);




> Thanks,
> Robert
>



--
Claus Ibsen
-----------------
FuseSource
Email: [hidden email]
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/
Loading...