Hello forum,
I have a custom ResponseExceptionMapper, which would construct appropriate
Exception instance from response InputStream (from response.getEntity()).
I registered the instance as one of the providers to WebClient but upon
request error, what I get is
"org.apache.cxf.jaxrs.client.ServerWebApplicationException".
I have a simplified version of my code below. If you could point out what
I'm doing wrong, I'd very much appreciate it.
Best regards.
CXF: 2.4.0
---------------------------------------------------------
public void test(String endpointBaseUrl) throws Exception {
ResponseExceptionMapper<Throwable> responseExceptionMapper = new
ResponseExceptionMapper<Throwable>() {
@Override
public Throwable fromResponse( Response r ) {
System.out.println("fromResponse called");
return new CustomException("status="+r.getStatus());
}
};
//ProviderFactory.getInstance().registerUserProvider(
responseExceptionMapper );
java.util.List providers = new java.util.ArrayList();
providers.add( new
org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider() );
providers.add( responseExceptionMapper );
try {
WebClient client = WebClient.create( endpointBaseUrl, providers
);
client = client.accept( "application/json" ).type(
"application/json" ).path( _username ).path( "authenticate"
).query("password", _password);
User user = client.get( User.class);
//assertNotNull( user );
fail();
} catch (CustomException e) {
// expected...
} catch (Exception e) {
fail();
}
}
---------------------------------------------------------
--
View this message in context:
http://cxf.547215.n5.nabble.com/WebClient-ResponseExceptionMapper-provider-mapper-is-not-being-called-tp5520604p5520604.html
Sent from the cxf-user mailing list archive at Nabble.com.