cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sergey Beryozkin" <sbery...@progress.com>
Subject Re: JAXRS - POST
Date Wed, 23 Dec 2009 12:34:33 GMT
Hi

> 
> Hi,
> 
> I tried to create a RestFul JSON service with CXF. The example works for GET
> method. When i try the same with POST method, i get ".No operation matching
> request path found" error message. 
> URL I hit is: http://localhost:8081/SampleRestProject/helloWorld/customers.
> Find below resource class and bean definition.
> 
> @Path("/")
> @Produces("application/json")
> public class HelloWorldImpl implements HelloWorld
> {
> 
> @POST
> @Produces("application/json")
> @Consumes("application/json,application/xml")


It should be @Consumes({"application/json", "application/xml"})

Also, pelase make sure ContentType of the HTTP request conatins either application/json or
application/xml and that it accepts
application/json


cheers, Sergey

> @Path("/customers")
> public Customer getCustomers() {
> Customer customer = new Customer();
> customer.setId(1);
> customer.setName("Padma");
> return customer;
> }
> 
> }
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <beans xmlns="http://www.springframework.org/schema/beans"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:jaxrs="http://cxf.apache.org/jaxrs"
> xsi:schemaLocation="
> http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans.xsd
> http://cxf.apache.org/jaxrs
> http://cxf.apache.org/schemas/jaxrs.xsd
> ">
> 
> <!-- do not use import statements if CXFServlet init parameters link to
> this beans.xml -->
> 
> <import resource="classpath:META-INF/cxf/cxf.xml" />
> <import
> resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml" />
> <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
> 
> <jaxrs:server id="helloWorldService" address="/helloWorld">
> <jaxrs:serviceBeans>
> <ref bean="helloWorld" />
> </jaxrs:serviceBeans>
> <jaxrs:extensionMappings>
> <entry key="json" value="application/json" />
> <entry key="xml" value="application/xml" />
> </jaxrs:extensionMappings>  
> 
> </jaxrs:server>
> 
> <bean id="helloWorld" class="com.tfs.pe.HelloWorldImpl" />
> 
> 
> </beans>
> 
> Please help.
> 
> Thanks
> Padma
> 
> -- 
> View this message in context: http://old.nabble.com/JAXRS---POST-tp26897610p26897610.html
> Sent from the cxf-dev mailing list archive at Nabble.com.
>

Mime
View raw message