我正在开发cxf客户端。我从wsdl生成存根并从那里开发代码。我的代码是那样的
URL WSDL_LOCATION = new URL(targetURL);
CustomerWS_Service CustomerWSService = new CustomerWS_Service (WSDL_LOCATION);
CustomerWS customerWS = CustomerWSService.getCustomerWSPort();
现在,我想为连接设置一些属性:
max_total_connection: maximum number of connections allowed
max_connection_per_host: maximum number of connections allowed for a given host config
一些研究告诉我在HttpUrlConnection中设置这些属性。但我不知道该怎么做或至少如何从代码中获取HttpUrlConnection obj。
答案 0 :(得分:2)
您必须在总线级别设置此项。总线属性可以配置如下。您没有使用异步,因此不需要放置此属性。
我也建议从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"));