如何在客户端控制webservice调用的timeout

2025-01-07 03:30:11
推荐回答(2个)
回答1:

1,在CXF生成的stub的客户端,方式如下(CXF2.1.1):
SimpleServiceService srv = new SimpleServiceService();
SimpleService servicePort = srv.getSimpleServicePort();

//timeout setting
Client cl = ClientProxy.getClient(servicePort);

HTTPConduit http = (HTTPConduit) cl.getConduit();

HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
httpClientPolicy.setConnectionTimeout(10000);
httpClientPolicy.setReceiveTimeout(1000);
http.setClient(httpClientPolicy);

servicePort.concatenate("111", "2222");
其中SimpleServiceService是自动生成的stub类.

回答2:

要看是哪种的客户端了

~~~~~~~