The context
 I've written a RESTful web service with CXF which has to process and
returns either XML or JSON. 
  My configuration-file contains JAXB- and a JSON-provider to add e.  g. 
validation against a schema, dropping/adding namespaces and so on. 
 
  The class is annotated with the according "@consumes", "@produces"  and 
content-types  ("{MediaType.APPLICATION_XML,MediaType.APPLICATION_JSON}"). 
The problem:
 There is a strange behavior I fail to fix: If I test it with a JSON message
(and "content-type: application/JSON"), CXF will process it but return an
XML-message (together with "content-type: application/XML").
 
  (I also managed to have it the other way round - request with XML,  but 
response was JSON. Apparently it can be provoked by changing orders  of  the
content-types in the annotations - and/or the order of the  providers in the
configuration-file - I cannot confirm that.) 
My guess...
 ... is that the JSON provider does not receive the request (or passes it
on). The request eventually goes on to the XML provider, which processes it
instead (or additionally). Hence there is only the XML-payload +
"content-type: application/XML" in the response. 
  However I cannot see why; searching on the forum (like  this post
<http://cxf.547215.n5.nabble.com/Getting-JSON-instead-of-XML-at-marshalling-step-td565312.html>
 
) and the web did not help. 
 
  *What could be the issue?* I'm running out of ideas for this, so *I 
appreciate any hints and pointers.* 
My current configuration/setup
  I'm using  
   
CXF 2.7.11 (3.0.0 lead to the same results)   
JDK 1.7   
Tomcat-7.0.53   
SoapUI 5.0.0 for testing  
 
  Here are the according sections of the source- and  configuration-files: 
 AccountApiV1.java: 
   
 beans.xml: 
   




--
View this message in context: 
http://cxf.547215.n5.nabble.com/Question-Getting-XML-instead-of-JSON-wrong-JAXB-JSON-provider-setup-tp5745600.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to