You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Rob <ro...@atos.net> on 2014/07/17 12:33:45 UTC

CXF Schema Validation with a Custom Response

Hi
I'm trying to employ schema validation on a camel route which uses
cxf:cxfEndpoint:

	<cxf:cxfEndpoint id="serviceMgtEndpointMain_v2"
		address="/{{mainPath}}/v2" serviceClass="com.myCompany.v2.ServicesSoap">
		<cxf:properties>
			<entry key="schema-validation-enabled" value="${mainSchemaValidation}" />
		</cxf:properties>
	</cxf:cxfEndpoint>

What I need to do is create a custom response using the error message as
part of the reply but I need to be able to set the Exchange body after
getting the error message. ie I have a ResultSet in my xsd which would have
the description set using the validation error message.

I have tried using <onException> only this doesn't catch it as the error
seems to be thrown during the cxf phase and is not within the route.  I have
investigated the use of interceptors but it looks rather complex for my
needs and experience.

If there are any alternatives or explanations on how I might use
interceptors for this that would be appreciated.  I am using camel version
2.12.2 and apache cxf version 2.7.8.




--
View this message in context: http://camel.465427.n5.nabble.com/CXF-Schema-Validation-with-a-Custom-Response-tp5753958.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: CXF Schema Validation with a Custom Response

Posted by Andrew Thorburn <nz...@gmail.com>.
Assuming that your schema is not embedded in the WSDL, but in separate XSD
files, you should look at the Validator Component:
http://camel.apache.org/validation.html

As in the example there, you can just catch a
org.apache.camel.ValidationException
(or, more specifically, a org.apache.camel.SchemaValidationException), and
use that to get what failed. It's not perfect, but it may work for your
needs.

- Andrew


On Thu, Jul 17, 2014 at 10:33 PM, Rob <ro...@atos.net> wrote:

> Hi
> I'm trying to employ schema validation on a camel route which uses
> cxf:cxfEndpoint:
>
>         <cxf:cxfEndpoint id="serviceMgtEndpointMain_v2"
>                 address="/{{mainPath}}/v2"
> serviceClass="com.myCompany.v2.ServicesSoap">
>                 <cxf:properties>
>                         <entry key="schema-validation-enabled"
> value="${mainSchemaValidation}" />
>                 </cxf:properties>
>         </cxf:cxfEndpoint>
>
> What I need to do is create a custom response using the error message as
> part of the reply but I need to be able to set the Exchange body after
> getting the error message. ie I have a ResultSet in my xsd which would have
> the description set using the validation error message.
>
> I have tried using <onException> only this doesn't catch it as the error
> seems to be thrown during the cxf phase and is not within the route.  I
> have
> investigated the use of interceptors but it looks rather complex for my
> needs and experience.
>
> If there are any alternatives or explanations on how I might use
> interceptors for this that would be appreciated.  I am using camel version
> 2.12.2 and apache cxf version 2.7.8.
>
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/CXF-Schema-Validation-with-a-Custom-Response-tp5753958.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>