Discussion:
JAX-RS Client proxy response is null after conversion to WebClient
Veit Guna
2015-01-26 12:10:58 UTC
Permalink
Hi.

Is it expected behavior, that after a JAX-RS client proxy request has been made, accessing the response via converted WebClient returns null?

My code:

Client client = WebClient.client(clientProxy);
System.out.println("client response: " + client.getResponse());
WebClient webClient = WebClient.fromClient(client);
System.out.println("webclient response. " + webClient.getResponse());

Outputs:

client response: ***@20e14502
webclient response. null

I also encountered, that after an entity has been returned by the client proxy invocation, accessing the response stream via Client returns an empty stream.
Using:

InputStream inputStream = response.readEntity(InputStream.class);

I figured out, that enabling client response buffering does the trick in this case:

WebClient.getConfig(store).getResponseContext().put("buffer.proxy.response", "true");

But I'm wondering, if that is the right usage of the "user" client API. Since the constant belonging to that property key is private
in ClientProxyImpl (BUFFER_PROXY_RESPONSE).

I'm using CXF 3.0.4-SNAPSHOT.

Thanks.
Veit
Sergey Beryozkin
2015-01-26 13:05:01 UTC
Permalink
Hi
Post by Veit Guna
Hi.
Is it expected behavior, that after a JAX-RS client proxy request has been made, accessing the response via converted WebClient returns null?
Client client = WebClient.client(clientProxy);
System.out.println("client response: " + client.getResponse());
WebClient webClient = WebClient.fromClient(client);
System.out.println("webclient response. " + webClient.getResponse());
webclient response. null
IMHO it is reasonable. During the conversion only those properties are
copied that are needed for the subsequent invocations.
Post by Veit Guna
I also encountered, that after an entity has been returned by the client proxy invocation, accessing the response stream via Client returns an empty stream.
InputStream inputStream = response.readEntity(InputStream.class);
WebClient.getConfig(store).getResponseContext().put("buffer.proxy.response", "true");
But I'm wondering, if that is the right usage of the "user" client API. Since the constant belonging to that property key is private
in ClientProxyImpl (BUFFER_PROXY_RESPONSE).
JAX-RS Response has a standard method for buffering but in case of the
CXF proxy API, yes, this property needs to be set if the buffering is
required. I'll update the wiki docs...

Cheers, Sergey
Post by Veit Guna
I'm using CXF 3.0.4-SNAPSHOT.
Thanks.
Veit
Loading...