cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nishant Chandra <nishant.chan...@gmail.com>
Subject Re: REST
Date Fri, 18 Sep 2009 12:06:59 GMT
Indeed! Thanks. A typo caused me all the problems.

The other issue I am facing is the response xml which is empty.

<?xml version="1.0" encoding="UTF-8"
standalone="yes"?><reviewsCollection><reviews><review/></reviews></reviewsCollection>

Here is the class;

@XmlRootElement
public class ReviewsCollection {

	private Collection<Review> reviews;

	public ReviewsCollection() { }
	
	public ReviewsCollection(Collection<Review> reviews) {
		this.reviews = reviews;
	}

	@XmlElement(name="review")
    @XmlElementWrapper(name="reviews")
	public Collection<Review> getReviews() {
		return reviews;
	}
}

Nishant

On Fri, Sep 18, 2009 at 5:29 PM, Sergey Beryozkin <sberyozk@progress.com> wrote:
> I'm not sure but it looks like you might've imported @Get from some
> non-JAX-RS api package (as opposed to javax.ws.rs.GET) - can you verify it
> please ?
>
> Sergey
> ----- Original Message ----- From: "Nishant Chandra"
> <nishant.chandra@gmail.com>
> To: <users@cxf.apache.org>
> Cc: <sberyozk@progress.com>
> Sent: Friday, September 18, 2009 12:39 PM
> Subject: Re: REST
>
>
> Yes, I am deploying CRService webapp. Its context is
> "http://localhost/CRService"
>
> beans.xml has address="/CRService"
>
> I am afraid I dont understand your question. What typo are you talking
> about?
>
> Thanks,
> Nishant
>
> On Fri, Sep 18, 2009 at 5:04 PM, Sergey Beryozkin <sberyozk@progress.com>
> wrote:
>>
>> Hi
>>
>>> http://localhost/CRService/CRService/services/r/2
>>
>> do you have a web app called 'CRService' ?
>>>
>>> @Get
>>
>> is it a typo ? Do you actually @GET in your code ? For some reasons
>> ReviewsCollection is considered to be a subresource
>>
>> cheers, Sergey
>>
>>
>>
>> ----- Original Message ----- From: "Nishant Chandra"
>> <nishant.chandra@gmail.com>
>> To: <users@cxf.apache.org>
>> Sent: Friday, September 18, 2009 10:52 AM
>> Subject: REST
>>
>>
>>> HI,
>>>
>>> I am building a simple REST based application.
>>>
>>> Here is the impl class:
>>>
>>> @Path("/services/")
>>> @Produces("application/xml") public class ReviewServiceImpl implements
>>> ReviewService {
>>>
>>> @Get
>>> @Path("/r/{id}")
>>> public ReviewsCollection getReviews(String id) {
>>> System.out.println("Getreview called with param: " + id);
>>>
>>> Review review = new Review(1, "test review");
>>>
>>> List<Review> reviewList = new ArrayList<Review>();
>>> reviewList.add(review);
>>>
>>> return new ReviewsCollection(reviewList); }
>>> }
>>>
>>> Beans.xml
>>>
>>> <?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"
>>> xmlns:cxf="http://cxf.apache.org/core"
>>> 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
>>> http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd"
>>> default-lazy-init="false">
>>>
>>> <cxf:bus>
>>> <cxf:features>
>>> <cxf:logging/>
>>> </cxf:features>
>>> </cxf:bus>
>>>
>>> <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="reviewService" address="/CRService">
>>> <jaxrs:serviceBeans>
>>> <ref bean="reviewBean" />
>>> </jaxrs:serviceBeans>
>>> </jaxrs:server>
>>>
>>> <bean id="reviewBean" class="com.fr.impl.ReviewServiceImpl" />
>>> </beans>
>>>
>>> Hitting: http://localhost/CRService/CRService/services/r/2 returns 404.
>>>
>>> Log dump:
>>>
>>> ID: 3
>>> Address: /CRService/CRService/services/r/2
>>> Encoding:
>>> Content-Type:
>>> Headers: {connection=[Keep-Alive, TE],
>>> accept-language=[en-US,en;q=0.9], host=[localhost], te=[deflate, gzip,
>>> chunked, identity, trailers], user-agent=[Opera/9.64 (Windows NT 5.1;
>>> U; en) Presto/2.1.1], accept-encoding=[deflate, gzip, x-gzip,
>>> identity, *;q=0], Content-Type=[null], Accept=[text/html,
>>> application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg,
>>> image/gif, image/x-xbitmap, */*;q=0.1], accept-charset=[iso-8859-1,
>>> utf-8, utf-16, *;q=0.1]}
>>> Payload:
>>> --------------------------------------
>>> getreviews called with param:
>>> Sep 18, 2009 3:03:40 PM org.apache.cxf.jaxrs.utils.ResourceUtils
>>> checkMethodDispatcher
>>> WARNING: No resource methods found for resource class
>>> com.fr.impl.type.ReviewsCollection
>>> Sep 18, 2009 3:03:40 PM org.apache.cxf.jaxrs.JAXRSInvoker invoke
>>> SEVERE: No subresource locator found for path /
>>> Sep 18, 2009 3:03:40 PM
>>> org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper toResponse
>>> WARNING: WebApplicationException has been caught : no cause is available
>>> Sep 18, 2009 3:03:40 PM
>>> org.apache.cxf.interceptor.LoggingOutInterceptor$LoggingCallback
>>> onClose
>>> INFO: Outbound Message
>>> ---------------------------
>>> ID: 3
>>> Encoding:
>>> Content-Type: text/xml
>>> Headers: {Date=[Fri, 18 Sep 2009 09:33:40 GMT]}
>>> Payload:
>>> --------------------------------------
>>>
>>> The Id value comes out to be null. How do I get rid of the warnings
>>> and make this work?
>>>
>>> Nishant
>>
>
>
>
> --
> Nishant Chandra
> Hyderabad, India
> Cell : +91 9949828480
>



-- 
Nishant Chandra
Hyderabad, India
Cell : +91 9949828480

Mime
View raw message