1

I am developing cxf client. I generate stub from wsdl and develope code from there. My code is something like that

URL WSDL_LOCATION = new URL(targetURL);
CustomerWS_Service CustomerWSService = new CustomerWS_Service (WSDL_LOCATION);
CustomerWS customerWS = CustomerWSService.getCustomerWSPort();

Now, i want to set some property to the connection:

max_total_connection: maximum number of connections allowed
max_connection_per_host: maximum number of connections allowed for a given host config

Some research tell me to set those properties in HttpUrlConnection. But i dont know how to do that Or atleast how to have HttpUrlConnection obj from the code.

David
  • 3,538
  • 9
  • 39
  • 50

1 Answers1

3

You have to set this at Bus level. Bus properties can be configured as like below. You are not using async so don't need to put this property. Also I would recommend to create client from JaxWsClientFactoryBean SpringBus bus = new SpringBus(); bus.setProperty(AsyncHTTPConduit.USE_ASYNC, Boolean.TRUE); bus.setProperty("org.apache.cxf.transport.http.async.SO_KEEPALIVE",Boolean.TRUE); bus.setProperty("org.apache.cxf.transport.http.async.SO_TIMEOUT",Boolean.FALSE); bus.setProperty("org.apache.cxf.transport.http.async.MAX_CONNECTIONS","totalConnections")); bus.setProperty("org.apache.cxf.transport.http.async.MAX_PER_HOST_CONNECTIONS","connectionsPerHost"));

Vijendra Kumar Kulhade
  • 2,217
  • 3
  • 15
  • 25
  • Thanks. But i dont use async. Your sample is for async only. Does it work with sync call? – David Jun 01 '17 at 20:03
  • 1
    Yes It works for sync as well just don't set that to false. – Vijendra Kumar Kulhade Jun 01 '17 at 20:51
  • Thanks again. You say "just don't set that to false". Do you mean bus.setProperty(AsyncHTTPConduit.USE_ASYNC, Boolean.TRUE); – David Jun 01 '17 at 21:22
  • Oh My Bad I meant set it to false.`bus.setProperty(AsyncHTTPConduit.USE_ASYNC, Boolean.FALSE);` Basically CXF gives preference to async but at the same time it takes the configuration for sync client also in the same way. – Vijendra Kumar Kulhade Jun 02 '17 at 16:47