
CXF客户端默认ReceiveTimeout响应超时时间为60s,ConnectionTimeout连接超时时间为30s。(单位毫秒)
可采用以下两种方式配置超时时间:
Spring + CXF
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:http-conf="http://cxf.apache.org/transports/http/configuration" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.0.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd "> <http-conf:conduit name="{WSDL Namespace}portName.http-conduit"> <http-conf:client ConnectionTimeout="10000" ReceiveTimeout="30000"/> </http-conf:conduit>
</beans>
|
Java Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
private UNICServicePortType () { JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); factory.setServiceClass(UNICServicePortType.class); factory.setAddress(wsUrl); Object obj = factory.create(); UNICServicePortType portProxy = (UNICServicePortType) obj; org.apache.cxf.endpoint.Client proxy = ClientProxy.getClient(portProxy); HTTPConduit conduit = (HTTPConduit) proxy.getConduit(); HTTPClientPolicy policy = new HTTPClientPolicy(); policy.setConnectionTimeout(10000); policy.setReceiveTimeout(30000); conduit.setClient(policy); return portProxy; }
|
参考
http://www.jianshu.com/p/2f746a74b9fe
http://cxf.apache.org/docs/client-http-transport-including-ssl-support.html#ClientHTTPTransport(includingSSLsupport)-Authentication
近期评论