cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Padmam <padmavath...@infosys.com>
Subject Re: JAXRS - POST
Date Wed, 23 Dec 2009 16:05:36 GMT

Thanks Sergey...

Can you also tell me how to access this from a Client?
I created following class and when tried to access it threw 405 exception:

public class Client {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		HelloWorld helloWorld =
WebClient.create("http://localhost:8081/SampleRestProject/helloWorld/customers").accept("application/json").get(HelloWorld.class);
	}	
}

Thanks
Padma

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.
>



-- 
View this message in context: http://old.nabble.com/JAXRS---POST-tp26897610p26904019.html
Sent from the cxf-dev mailing list archive at Nabble.com.


Mime
View raw message