如何在 cxf cilent 代码中设置 属性 maxConnection

how to set property maxConnection in cxf cilent code

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

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