This is bizarre...Can you please double check the custom code you may have and see if "application/xml" is 'hiding somewhere' ? Can you do a sanity check and confirm it is this endpoint which is being invoked after all ?
Any chance you can attach a working route (test) to JIRA ?

Cheers, Sergey

On 01/07/13 17:19, ajaysam wrote:
application/xml always works..
even if i am saying Produces json i still get output as xml




On Mon, Jul 1, 2013 at 12:01 PM, Sergey Beryozkin-3 [via Camel] <
ml-node+s465427n5735049...@n5.nabble.com> wrote:

So, if you replace all of @Produces("application/json") with
@Produces("application/xml")

and do

curl -HAccept:application/xml ...

then it works ?

Sergey

On 01/07/13 16:40, ajaysam wrote:

I am sending the request through curl - it is setting Accept header as
shown
below

curl -HAccept:application/json

http://pocman2.nsp.stf.bms.com:8080/CXF_REST-0.0.1-SNAPSHOT/webservices/Hello/SilpaY

Hello is the path to refer to resource class

We are stuck in this project and any help will be appreciated.

At high level this is what the project is about
1. Camel exposes a REST endpoint thru CXFRS - this part works
2. We get the request data in POJO format - camel makes SOAP call to
another
web service passing this POJO
3. We get the response back  from that service
4. Response POJO needs to be converted to JSON

As of now as a workaround in last step - we are using marshal step of
camel
to explicitly convert from POJO to JSON - and that works - but we dont
want
to do it that way

We thought just doing return Response.ok(resp).build(); from Processor
should work

We did all the configuration required as explained in article

Our resource class says @Produces MediaType.Application_JSON
Also provided the json provider to cxfrs configuration

Now what else needs to be done?


Can i send the application-context.xml file and Resource file to you
somehow..maybe i m missing something fundamental


attached is the xml section

- <util:list id="jsonTypes">
    <value>application/json</value>
    </util:list>
- <bean id="cxfJaxrsJsonProvider"
class="org.apache.cxf.jaxrs.provider.json.JSONProvider">
    <property name="namespaceMap" ref="jsonNamespaceMap" />
    <property name="produceMediaTypes" ref="jsonTypes" />
    </bean>
    <bean id="restResource" class="com.bms.web.HelloResource" />
- <jaxrs:server id="restService" staticSubresourceResolution="true">
- <jaxrs:serviceBeans>
    <ref bean="restResource" />
    </jaxrs:serviceBeans>
- <jaxrs:providers>
    <ref bean="cxfJaxrsJsonProvider" />
    <bean class="org.apache.cxf.jaxrs.provider.JAXBElementProvider" />
    </jaxrs:providers>
    </jaxrs:server>

   <bean id="restRespProcessor" class="com.bms.web.RESTResponseProcessor"
/>

<cxf:rsServer id="HelloRsServer"
serviceClass="com.bms.web.HelloResource"
loggingFeatureEnabled="true" />

<camelContext xmlns="http://camel.apache.org/schema/spring";>


     <route id="restToSoap" streamCache="true">
      <from
uri="cxfrs://bean://HelloRsServer?bindingStyle=SimpleConsumer"
/>
      <log message="**************** Got ${headers}" />
      <log message="**************** Got Body 111 : ${body}" />
      <to uri="bean:reqProcessor" />
      <log message="**************** Got Headers 222 : ${headers}" />
      <log message="**************** Got Body 333 : ${body}" />
      <to uri="cxf:bean:target_hello"/>
      <log message="**************** Got Body 444 : ${body}" />
      <to uri="bean:restRespProcessor" />
      <log message="**************** Got Body 555 : ${body}" />
    </route>

      </camelContext>

the the response processor does this

MessageContentsList msgList =
(MessageContentsList)exchg.getIn().getBody();

GetReferenceDataResponse resp = (GetReferenceDataResponse)
msgList.get(0);
exchg.getOut().setBody(Response.ok(resp).build());


Resource File is

@Path("/Hello")
@Produces({"application/json"})
public class HelloResource {
public HelloResource() {}

@GET
@Path("/{referenceTypeName}")
//@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
@Produces({MediaType.APPLICATION_JSON})
public Response getMessage(
@PathParam("referenceTypeName") String name, @QueryParam("")
ReferenceDataRequest query) {
System.out.println("Hello, i am here !!! In HelloResource .......
updated
7.1.13");

               return null;
}
}




--
View this message in context:
http://camel.465427.n5.nabble.com/Camel-CXFRS-endpoint-unable-to-produce-JSON-tp5734967p5735046.html

Sent from the Camel - Users mailing list archive at Nabble.com.





------------------------------
  If you reply to this email, your message will be added to the discussion
below:

http://camel.465427.n5.nabble.com/Camel-CXFRS-endpoint-unable-to-produce-JSON-tp5734967p5735049.html
  To unsubscribe from Camel CXFRS endpoint unable to produce JSON, click
here<http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5734967&code=YWpheS5zYW1hbnRAZ21haWwuY29tfDU3MzQ5Njd8LTIxMTkyODAxMA==>
.
NAML<http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>





--
View this message in context: 
http://camel.465427.n5.nabble.com/Camel-CXFRS-endpoint-unable-to-produce-JSON-tp5734967p5735050.html
Sent from the Camel - Users mailing list archive at Nabble.com.



--
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com

Reply via email to