Hi
On 23/07/12 16:10, hom wrote:
Hi,

I've created a cxfrs route as described in
http://camel.apache.org/cxfrs.html (How to consume the REST request in
Camel). I am using SOAPUI to test the endpoint. The resource class is:

/@Path("/")
@Consumes({"application/xml","application/json"})
@Produces({"application/xml","application/json"})
public class Resource {

        @POST
        @Path("/doit/")
        @Consumes({"application/xml","application/json"})
        @Produces({"application/xml","application/json"})
     public DoItResponse doit(DoItRequest request){return null;};
}/

For XML everything works fine, but when I send a json request I always get:

<data contentType="text/plain" contentLength="555"><![CDATA[JAXBException
occurred : unexpected element (uri:"", local:"DoItRequest"). Expected
elements are
<{http://www.xyz.org/types}DoItRequest>,<{http://www.xyz.org/types}DoItResponse>,<{http://www.xyz.org/types}
ProviderError>. unexpected element (uri:"", local:"DoItRequest") ...

I set media type and access header to application/json, but it seems that
json is not recognized.
Any ideas?

The problem is most likely to do with the fact that DoItRequest is namespace-qualified (with @XmlRootElement or at the package level).
However a json sequence you are posting is most likely has no prefixes.
If you work with Jettison, then one way to do it is to provide a namespace map, however, as I said I think the sequence have no prefixes so there's no inbound info that can be used to map prefixes to namespaces.
Thus the better option is to use a transformation feature:
http://cxf.apache.org/docs/transformationfeature.html

having an 'inTransformElements' property to have a pair like "DoItRequest": "{http//mynamespace}DoItRequest" should do it

HTH, Sergey





--
View this message in context: 
http://camel.465427.n5.nabble.com/CXFRS-does-not-process-JSON-tp5716343.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Reply via email to