camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sergey Beryozkin <sberyoz...@gmail.com>
Subject Re: Camel CXFRS endpoint unable to produce JSON
Date Mon, 01 Jul 2013 16:00:31 GMT
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.
>



Mime
View raw message