Mike Summers
2012-01-24 19:58:03 UTC
I'm writing a test server that needs to emulate a 3rd party RESTful server,
I'm using Jersey to write the test server.
All of the requests are POST with application/xml payloads so I started off
with:
@Path("GetUserDetails")
@POST
@Consumes(MediaType.APPLICATION_XML)
public GetUserDetailsResp GetUserDetails(GetUserDetailsReq request) {
...
}
Jersey happily returns 400 when the XML is badly formatted
(GetUserDetailsReq is a JAXB object), which is not what I need. Rather I
need to return 200 and an XML error block.
I can get around the 400 by unmarshaling in the method and using an
@Provider/ExceptionMapper class, but that's clunky. Is there a declarative
way to specify to Jersey an alternative to returning the 400? Maybe a
variant on @Provider/ExceptionMapper?
TIA.
I'm using Jersey to write the test server.
All of the requests are POST with application/xml payloads so I started off
with:
@Path("GetUserDetails")
@POST
@Consumes(MediaType.APPLICATION_XML)
public GetUserDetailsResp GetUserDetails(GetUserDetailsReq request) {
...
}
Jersey happily returns 400 when the XML is badly formatted
(GetUserDetailsReq is a JAXB object), which is not what I need. Rather I
need to return 200 and an XML error block.
I can get around the 400 by unmarshaling in the method and using an
@Provider/ExceptionMapper class, but that's clunky. Is there a declarative
way to specify to Jersey an alternative to returning the 400? Maybe a
variant on @Provider/ExceptionMapper?
TIA.