|
From: Bill B. <bb...@re...> - 2008-07-11 22:17:05
|
I'm confused on what you're trying to do. You're creating a
ClientResponse on the serverside? Why? Why do you need a custom
ClientResponse object? ClientResponse should only be used with a client
interface.
Adam Jordens wrote:
> Currently running beta5 and have run into a bit of an issue surrounding
> a resource that returns a ClientResponse with a /303 – See Other/
> response code and the appropriate /Location: /header.
>
> Essentially I’m trying to implement a POST then GET.
>
> @POST
> @ConsumeMime("application/xml")
> @ProduceMime(“*/*”)
> @Path("/search")
> public ClientResponse<Long> createSearch(ExtQuery query)
> {
> ...
> return new
> CustomClientResponse(Response.seeOther(uri).entity(specimenSearch.getId()).build());
> }
>
> CustomClientResponse is just an implementation of a /ClientResponse
> /that effectively wraps the status, entity and headers from a normal
> Response.
>
> What I’m hoping to be able to do is 2 things:
>
> * Use the client-side framework to invoke this createSearch() and
> have access to the returning ClientResource. I could either look
> at the headers for the redirected location or just grab the entity
> and invoke a GET on another resource.
> * Use a web browser and POST to /search and have the browser
> automatically redirect with a GET request to the /303 – See Other/
> resource.
>
>
> Strangely enough, I’ve been able to make get them both working (/not
> having the @ProduceMime(“*/*”) was causing some grief/).
>
> To get things working I had to do a minor patch to the /MethodInjectorImpl/.
>
> *Added *(/to MethodInjectorImpl.java.invoke()/):
> if (method.getReturnType().equals(ClientResponse.class))
> {
> ClientResponse clientResponse = (ClientResponse) rtn;
> ResponseImpl response = new ResponseImpl();
> response.setEntity(rtn);
> response.setStatus(clientResponse.getStatus());
> response.setMetadata(clientResponse.getHeaders());
> return response;
> }
>
> Previously it looked like it was just creating a normal Response that
> wrapped the ClientResponse but didn’t inherit any of its status or headers.
>
> At this stage, the client-side framework is able to POST to /search and
> get back the appropriate ClientResponse, and the web browser was able to
> POST to /search and get redirected to the appropriate resource. Success!
>
>
> Now my biggest question is around whether or not these types of
> operations should be supported?
>
>
>
> Thanks,
> Adam
>
>
> ------------------------------------------------------------------------
>
> -------------------------------------------------------------------------
> Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
> Studies have shown that voting for your favorite open source project,
> along with a healthy diet, reduces your potential for chronic lameness
> and boredom. Vote Now at http://www.sourceforge.net/community/cca08
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Resteasy-developers mailing list
> Res...@li...
> https://lists.sourceforge.net/lists/listinfo/resteasy-developers
--
Bill Burke
JBoss, a division of Red Hat
http://bill.burkecentral.com
|