2017-06-01 45 views
0

我正在開發cxf客戶端。我從wsdl生成存根並從那裏開發代碼。我的代碼是類似的東西如何在cxf靜默代碼中設置屬性maxConnection

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。

回答

1

您必須在公交級別進行設置。總線屬性可以像下面這樣配置。你不使用異步,所以不需要把這個屬性。 此外,我會建議創建客戶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"));

+0

謝謝。但我不使用異步。您的示例僅適用於異步。它是否適用於同步通話? – David

+0

是的它適用於同步以及不要將其設置爲false。 –

+0

再次感謝。你說「只是不要把它設置爲假」。你的意思是bus.setProperty(AsyncHTTPConduit.USE_ASYNC,Boolean.TRUE); – David

相關問題