I have an issue in my (spring boot) API where occasionally a SOAP service it calls will take over a minute to respond, resulting in a SocketTimeoutException. After a lot of searching I've narrowed the cause down to this bit of code:
@SuppressWarnings("unchecked")
public <T> T createWsService(Class<T> serviceClass, String url) {
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setServiceClass(serviceClass);
factory.setAddress(url);
LoggingInInterceptor loggingInInterceptor = new LoggingInInterceptor();
loggingInInterceptor.setPrettyLogging(true);
factory.getInInterceptors().add(loggingInInterceptor);
LoggingOutInterceptor loggingOutInterceptor = new LoggingOutInterceptor();
loggingOutInterceptor.setPrettyLogging(true);
factory.getOutInterceptors().add(loggingOutInterceptor);
return (T) factory.create();
}
When debugging through I can see the factory.create()
returns a proxy object but this is cast to the interface from the ws supplier. The proxy object contains a ClientImpl which I can see has a default synchronous timeout of 60000 (a minute).
I tried adding the following:
Map<String, Object> properties = new HashMap<>();
properties.put("cxf.synchronous.timeout", 1);
factory.setProperties(properties);
to set the property (using 1 as a test to check it works) but this just sets the property as an endpoint of the container object. There are no methods on the interface I need to use that let me set any properties.
I also tried casting the returned object to JaxWsClientProxy to set it myself but this didn't work despite it showing with that structure when debugging.
How can I increase the timeout here? I'm open to abandoning the JaxWsProxyFactoryBean approach in favour of something more flexible if that's what it takes but I'd prefer to keep changes to a minimum if possible.
Think I've found it, the property I needed is "javax.xml.ws.client.receiveTimeout"
instead of "cxf.synchronous.timeout"