|
From: Adam J. <Ada...@ge...> - 2008-07-11 22:30:42
|
Heh. I was wondering if I was going to confuse anyone.
Essentially what I want to do is have the value of a Response (with a status
of 303) returned to the caller of the client framework.
>From what I had seen (and read?), if the client framework caller wanted
access to the actual response itself, it needed to be actually returned as a
ClientResponse. Am I mistaken?
The interaction is as follows:
Client A (via ClientFramework) POSTS to the '/searches/' resource and gets a
ClientResponse (or Response) back with a status code and ideally an entity.
Client B (via Web Browser) POSTS to '/searches/' and gets redirected to the
target of the Location header.
Does that make any more sense?
As for the CustomClientResponse, it's nothing more than a dummy
implementation of the ClientResponse interface to save me from doing a new
ClientResponse(response.getEntity(), response.getStatus(), etc.).
It's probably ignorable.
Regards,
Adam
On 11/07/08 3:16 PM, "Bill Burke" <bb...@re...> wrote:
> 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()).bu
>> ild());
>> }
>>
>> 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
|