Reputation: 73
I have a soap client developed using apache camel cxf component The client's service that we are invoking takes too much time to respond and I was asked to increase the timeout of the invocation
I tried to use a custom cxfEndpointConfigurer for the cxf ToEndPoint as following : cxf://http://localhost:6025/MyMockService?cxfEndpointConfigurer=#MyCxfConfigurer&dataFormat=MESSAGE&portName=%7Bhttp%3A%2F%2Forg.tempuri%7DMyServiceSoap11&serviceName=%7Bhttp%3A%2F%2Forg.tempuri%7DMyServiceService
and here is the code bellow :
public class TemplateEndpointConfigurer implements CxfEndpointConfigurer {
@Override
public void configure(AbstractWSDLBasedEndpointFactory factoryBean) {
// Do nothing here
}
@Override
public void configureClient(Client client) {
final HTTPConduit conduit = (HTTPConduit) client.getConduit();
final HTTPClientPolicy policy = new HTTPClientPolicy();
policy.setConnectionTimeout(30000);
policy.setReceiveTimeout(300000);
policy.setConnection(ConnectionType.CLOSE);
conduit.setClient(policy);
}
@Override
public void configureServer(Server server) {
// TODO Auto-generated method stub
}
}
But I still get a timeout error after 60000ms which is the cxf default
do you have any idea how I can set successfully set this timeout ?
Thank you very much
Upvotes: 0
Views: 1955
Reputation: 96
The same issue had occurred to me and i was able to fix it by setting the Client.REQUEST_CONTEXT
header as below:
This can be done in a processor/bean defined in the route before calling the web service :
public void setWebServiceTimeout(Exchange exchange) {
Map<String, Object> requestContext = new HashMap<String, Object>();
HTTPClientPolicy clientPolicy = new HTTPClientPolicy();
clientPolicy.setReceiveTimeout(300000);
requestContext.put(HTTPClientPolicy.class.getName(), clientPolicy);
exchange.getIn().setHeader(Client.REQUEST_CONTEXT , requestContext);
}
Upvotes: 1