Hi Tomasz
=============
> Hi Sergey,
>
> WebApplicationException comes from AbstractClient.readBody(), inside catch:
>
> MessageBodyReader mbr =
> ProviderFactory.getInstance(inMessage).createMessageBodyReader(
> try {
> return mbr.readFrom(cls, type, anns, contentType, new MetadataMap<String,
> Object>(r.getMetadata(), true, true), conn.getInputStream());
> } catch (Exception ex) {
> throw new WebApplicationException();
> }
>
> Few lines before is the status checked, in some cases (204) simply null is
> returned. So yes, client tries to read the body.
>
> I use CXF in cooperation with Spring, so I'm not sure, what exactly should
> I answer, so I will simply attach part o stacktrace:
> javax.ws.rs.WebApplicationException
> at
> org.apache.cxf.jaxrs.client.AbstractClient.readBody(AbstractClient.java:391)
> at
> org.apache.cxf.jaxrs.client.ClientProxyImpl.handleResponse(ClientProxyImpl.java:444)
> at
> org.apache.cxf.jaxrs.client.ClientProxyImpl.doChainedInvocation(ClientProxyImpl.java:428)
> at
> org.apache.cxf.jaxrs.client.ClientProxyImpl.invoke(ClientProxyImpl.java:171)
> at $Proxy88.update(Unknown Source)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at
> org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
> at
> org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:198)
> at $Proxy95.update(Unknown Source)
> (lower in stacktrace is no important stuff)
>
> I tried the trick with IN interceptor and different phases, did not work...
> Which phase you think it should be? I tried to debug this, the status is
> taken from HttpURLConnection, can it be really overridden?
>
>
I'm fixing that right now, it's unfortunate HttpUrlConnection is used to
check the status there given that few lines earlier the status is taken from
the message. In 2.3.4 you'll be able to override the status.
The direct HttpUrlConnection dependency itself will be removed once the
async http conduit gets supported.
I think you can try the following at the moment. I can see the proxies are
injected from Spring, but the actual code where the invocations are made can
be handled like this:
@Resource
BookService proxy;
try {
return proxy.getIt();
} catch (WebApplicationException ex) {
Response response = WebClient.client(proxy).getResponse();
if (response.getStatus() == 200) {
return null;
}
throw ex;
}
Will it work for you ?
Sergey
> Thanks
>
> ====
>
> Greets
> > Tomasz
> >
>