Hi Sergey, thanks for the awesome (and quick response). What you suggested worked great. I overrode this method:
@Override protected boolean isSupported(Class<?> type, Type genericType, Annotation[] annotations) { if(String.class.equals(type)) { return false; } else { return super.isSupported(type, genericType, annotations); } } And I was able to get at the body of the request as a String using the following service method: @POST @Path("/execute/{scriptName}") @Consumes({MediaType.APPLICATION_XML}) public Response executeDocumentPost( final @PathParam("scriptName") String scriptName, final String body { Now, I've modified it slightly, and it is not working. Instead of Content-Type: application/xml, I want to accept all content-types, and I want the InputStream instead of the String body. I also want to inject the context headers and uri info, so the new service method is like this: @POST @Path("/execute/{scriptName}") @Consumes({MediaType.WILDCARD}) public Response executeDocumentPost( final @PathParam("scriptName") String scriptName, final InputStream body, final @Context HttpHeaders httpHeaders, final @Context UriInfo uri) { This doesn't work, however. In the isSupported method, I am passed a MultiValuedMap as the type, so I modified the behavior slightly like this: if(String.class.equals(type) || type.isAssignableFrom(InputStream.class) || type.isAssignableFrom(MultivaluedMap.class) ) { return false; } else { return super.isSupported(type, genericType, annotations); } Now, my code returns false here, but it still gives me an error => No mapping found for MultiValuedMap input. Now, if I change the @Consumes annotation to explicitly accept MediaType.APPLICATION_XML, it works as expected: @Consumes({MediaType.WILDCARD, MediaType.APPLICATION_XML}) But this only works if I set the Content-Type: application/xml. If I want to upload JSON, for example, it won't work. Why doesn't the MediaType.WILDCARD seem to work here for other content types? Thanks in advance, Davis -----Original Message----- From: Sergey Beryozkin [mailto:sberyoz...@gmail.com] Sent: Thursday, December 01, 2011 5:43 AM To: users@cxf.apache.org Subject: Re: Question on Providers 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