You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Uma <um...@ioko.com> on 2011/03/30 11:28:34 UTC
How to setup Custom Validation Event Handler COnfiguration in CXF
spring xml
Hi,
I am using below xsd to validate incomming http(s) request . I have
configured it in cxf spring xml.
classpath:/schemas/schema1.xsd
I have written CustomValidationEventHandler class. How to configure this cxf
spring xml?
--
View this message in context: http://cxf.547215.n5.nabble.com/How-to-setup-Custom-Validation-Event-Handler-COnfiguration-in-CXF-spring-xml-tp4271097p4271097.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: How to setup Custom Validation Event Handler COnfiguration in
CXF spring xml
Posted by Uma <um...@ioko.com>.
Thanks a lot for your help Sergey..
--
View this message in context: http://cxf.547215.n5.nabble.com/How-to-setup-Custom-Validation-Event-Handler-COnfiguration-in-CXF-spring-xml-tp4271097p4271326.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: How to setup Custom Validation Event Handler COnfiguration in CXF
spring xml
Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
Ok, so everything is working now then, great.
You can throw WebApplicationException from the CustomValidationHandler :
Response r =
Response.status(requiredStatus).type("text/plain").entity(exceptionMessage).build();
throw new WebApplicationException(r);
Cheers, Sergey
On Wed, Mar 30, 2011 at 11:07 AM, Uma <um...@ioko.com> wrote:
> Hi Sergey,
>
> Thanks for the reply.
>
> I added below property to the section.
>
>
> And I wrote CustomerValidationEventHanlder Class. I want to give specific
> error message to the client..So i wrote Cutomer validation handler class.As
> of now schema is validating the request and giving "SAXParseException:
> cvc-enumeration-valid" errror.
>
>
>
> Dont worry about the schema.Its working now..(My previous email thread
> -issue is working now) . Schema is validating the request and giving the
> error ...( with linked exception:
> [org.xml.sax.SAXParseException: cvc-enumeration-valid: Value 'Plg' is not
> facet-valid with respect to enumeration '[Stopped, Paused, Playing]'. It
> must be a value from the enumeration.]..).
>
> Please find the custom event handler class:
> public class CustomValidationEventHandler implements ValidationEventHandler
> {
>
> @Override
> public boolean handleEvent(ValidationEvent ve) {
>
> if (ve.getSeverity() == ve.FATAL_ERROR || ve .getSeverity() ==
> ve.ERROR) {
> ValidationEventLocator locator = ve.getLocator();
> //print message from valdation event
> System.out.println("Message is " + ve.getMessage());
> //output line and column number
> System.out.println("Column is " + locator.getColumnNumber() + " at
> line number " + locator.getLineNumber());
> }
> return true;
> }
>
> }
>
> Please find the cxf-spring config xml below:
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> classpath:/schemas/schema1.xsd
>
>
>
>
>
>
> --
> View this message in context:
> http://cxf.547215.n5.nabble.com/How-to-setup-Custom-Validation-Event-Handler-COnfiguration-in-CXF-spring-xml-tp4271097p4271149.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>
Re: How to setup Custom Validation Event Handler COnfiguration in
CXF spring xml
Posted by Uma <um...@ioko.com>.
Hi Sergey,
Thanks for the reply.
I added below property to the section.
And I wrote CustomerValidationEventHanlder Class. I want to give specific
error message to the client..So i wrote Cutomer validation handler class.As
of now schema is validating the request and giving "SAXParseException:
cvc-enumeration-valid" errror.
Dont worry about the schema.Its working now..(My previous email thread
-issue is working now) . Schema is validating the request and giving the
error ...( with linked exception:
[org.xml.sax.SAXParseException: cvc-enumeration-valid: Value 'Plg' is not
facet-valid with respect to enumeration '[Stopped, Paused, Playing]'. It
must be a value from the enumeration.]..).
Please find the custom event handler class:
public class CustomValidationEventHandler implements ValidationEventHandler
{
@Override
public boolean handleEvent(ValidationEvent ve) {
if (ve.getSeverity() == ve.FATAL_ERROR || ve .getSeverity() ==
ve.ERROR) {
ValidationEventLocator locator = ve.getLocator();
//print message from valdation event
System.out.println("Message is " + ve.getMessage());
//output line and column number
System.out.println("Column is " + locator.getColumnNumber() + " at
line number " + locator.getLineNumber());
}
return true;
}
}
Please find the cxf-spring config xml below:
classpath:/schemas/schema1.xsd
--
View this message in context: http://cxf.547215.n5.nabble.com/How-to-setup-Custom-Validation-Event-Handler-COnfiguration-in-CXF-spring-xml-tp4271097p4271149.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: How to setup Custom Validation Event Handler COnfiguration in CXF
spring xml
Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
On Wed, Mar 30, 2011 at 10:28 AM, Uma <um...@ioko.com> wrote:
> Hi,
>
> I am using below xsd to validate incomming http(s) request . I have
> configured it in cxf spring xml.
>
> classpath:/schemas/schema1.xsd
>
>
>
> I have written CustomValidationEventHandler class. How to configure this
> cxf
> spring xml?
>
>
>
You have to explicitly configure
org.apache.cxf.jaxrs.provider.JAXBElementProvider (in the jaxrs:providers
section) and set a 'validationHandler' property on it. I'm also going to
look at the schemas you attached
Sergey
>
> --
> View this message in context:
> http://cxf.547215.n5.nabble.com/How-to-setup-Custom-Validation-Event-Handler-COnfiguration-in-CXF-spring-xml-tp4271097p4271097.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>