1

我正在开发 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。

4

1 回答 1

3

您必须在总线级别设置它。总线属性可以如下配置。您没有使用异步,因此不需要放置此属性。我也建议从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"));

于 2017-06-01T16:58:36.260 回答