Hi On 01/12/11 03:24, Davis Ford wrote:
Hi, I have a question on providers. The code base I'm working on uses a subclass of AegisElementProvider. I'm trying to add a new method to a service class where this provider is in play. I want a very simple resource that allows one to POST any free-form XML document...like this:@Path("/foo") @Consumes(MediaType.APPLICATION.XML) public Response postXml(String body) { ... } ...and call it like this from curl: curl -d "<xml>foo</xml>" -H "Content-Type: application/xml" -X POST "http://host/path/foo" Unfortunately, the same service has another method on it that accepts a JAXB/typed XML document with namespaces, etc. When I post to my method above, the Provider first gets the request, and tries to marshall it into some Java type, and the request fails -- seems it expecting a specific xsi:type
In this case it is still an AegisElementProvider that picks up the payload because at the moment it supports all the types, even primitive ones such as String (I guess Aegis will wrap/unwrap them somehow).
Does that other method you are referring to (or some other method in the service class) rely on Aegis DataBinding ? Or is it all JAXB ? AFAIK Aegis can handle JAXB annotations but if it is just JAXB then depending on JAXBProvider can be better in which case you'll get a String provider copying the input xml as String.
If you do need to use AegisElementProvider then the simplest thing to do is to override isSupported method in your subclass and return false for String.class, true - for others and that should do it
HTH, Sergey
WARN 2011-12-01 01:49:46,640 [TypeUtil] xsi:type was not specified for top-level element xml WARN 2011-12-01 01:49:46,648 [WebApplicationExceptionMapper] WebApplicationException has been caught : No mapping found for XML input. So, my question is this: is there some way to easily bypass this Provider for this method, so I can post any content I want as application/xml and have it just converted to a String -- bypassing the whole JAXB process altogether?
-- Sergey Beryozkin Talend Community Coders http://coders.talend.com/ Blog: http://sberyozkin.blogspot.com
