我正在使用
apache CXF
实现 JAX-WS
。
我的 Web 服务是通过 spring
xml 配置使用 JaxWsProxyFactoryBean
: 进行配置的
<bean id="myWSClient" class="my.package.MyWSClient"
factory-bean="clientFactory"
factory-method="create" />
<bean id="clientFactory" class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
<property name="serviceClass" value="my.package.MyWSClient"/>
<property name="address" value="http://some.url"/>
</bean>
然后我通过以下方式注入它:
@Resource(name = "myWSClient")
MyWSClient myWSClient;
如何设法增加 MyWSClient 的
timeout
?
要使用
spring configuration
配置客户端超时,请使用以下命令:
<http-conf:conduit name="*.http-conduit">
<http-conf:client
ConnectionTimeout="600000"
ReceiveTimeout="600000"/>
</http-conf:conduit>
在此示例中,响应和连接超时设置为 600 秒。
参考:
您可以在 xml 配置中添加属性 javax.xml.ws.client.receiveTimeout。值以毫秒为单位。 300000 毫秒 = 5 分钟
<bean id="serviceServiceFactory" class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
<property name="serviceClass" value="pl.service.YourService"/>
<property name="address" value="http://address:port/ws/YourService"/>
<property name="properties">
<map>
<entry key="javax.xml.ws.client.receiveTimeout"><value>300000</value></entry>
</map>
</property>
</bean>