lundi 23 février 2015

JaxWSPortProxyFactoryBean - Ignore invalid response Content-Type

I am using a port proxy generated by JaxWSPortProxyFactoryBean.


I gave it my WSDL file and it's reaching out to the service correctly as far as I can tell. I have another service configured in a similar way that is working.


The issue I'm having is that this particular service seems to be poorly implemented. When I send a request, it responds with a Content-Type of text instead of text/xml. Something is taking that response and throwing an exception because it isn't the content type it is expecting.


After some extensive googling on the matter, I found out about the HandlerResolver. I tried using that with a custom Handler:



public class ContentTypeHandler implements SOAPHandler<SOAPMessageContext> {
@Override public boolean handleMessage(SOAPMessageContext context) {
//many other things tried in here
Map<String, List<String>> theHeaders = new HashMap<String, List<String>>();
theHeaders.put("Accept", Collections.singletonList("application/x-gzip"));
context.put(MessageContext.HTTP_REQUEST_HEADERS, theHeaders);
}
}


I also set a breakpoint inside of the handler's close method. I can see the HTTP response headers and that the server is responding to me with a 200. So I'm reaching the server just fine, but it is sending the wrong content type. I cannot figure out where or how in my handler to change the expected content type.


I expected that the handleFault method of the handler would be called, which is where I would deal with that issue. But alas, that function is never even called. So something is blowing up before I have a chance to tell it not to.


Aucun commentaire:

Enregistrer un commentaire