主要在客户端调用时设置 :
- 在使用WebService的时候,我们可能需要一个备份的WebService服务器.一旦主服务器down了,我们可以使用备份的服务器.那么这里就需要对客服端连接服务器的时间做一个修改.
- 在Spring+CXF的WebService环境下,客户端有两个时间属性是可配置的,分别是ConnectionTimeout和ReceiveTimeout.
- ConnectionTimeout--WebService以TCP连接为基础,这个属性可以理解为tcp的握手时的时间设置,超过设置的时间长则认为是连接超时.以毫秒为单位,默认是30000毫秒,即30秒.
- ReceiveTimeout -- 这个属性是发送WebService的请求后等待响应的时间,超过设置的时长就认为是响应超时.以毫秒为单位,默认是60000毫秒,即60秒.
- beans.xml 设置的例子:
- <?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="{http://impl.service.product.super.com/}ProjectService.http-conduit">
- <http-conf:client ConnectionTimeout="10000" ReceiveTimeout="20000"/>
- </http-conf:conduit>
- </beans>
- 这里需要注意的有几个地方:
- 1:需要指定http-conf名称空间 xmlns:http-conf=http://cxf.apache.org/transports/http/configuration
- 2:指定模式位置: http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
- 3:http-conf:conduit中的name属性,指定设置生效的服务,如例子中,只对服务名为{http://impl.service.product.sww.com/}ProjectService的服务生效.
- 使用下面的设置则会对所有服务生效
- <http-conf:conduit name="*.http-conduit">
- <http-conf:client……>
- </http-conf:conduit>
- 更详细的配置请参考CXF官方文档:
- http://cwiki.apache.org/CXF20DOC/client-http-transport-including-ssl-support.html
`2.代码编写:
private static void recieveTimeOutWrapper(Object o)
{
Conduit conduit = (ClientProxy.getClient(o).getConduit());
HTTPConduit hc = (HTTPConduit)conduit;
HTTPClientPolicy client = new HTTPClientPolicy();
client.setReceiveTimeout(1000 * 60 * 5); // 5分钟超时时间。 该时间为响应超时。
// client.setConnectionTimeout(1000 * 45); // 45秒的连接超时。
hc.setClient(client);
}
recieveTimeOutWrapper(o) 包装每一个服务
相关推荐
使用cxf+spring框架开发webservice的客户端与服务端代码,用于连接两个项目
Springboot整合CXF发布Web service和客户端调用(用户和密码验证)打开及用
CXF WebService整合Spring代码(包含服务,客户端两个工程 和 文档) 需要视频的话,留邮箱
使用cxf和spring开发基于https的webservice服务端以及客户端样例
webservice客户端,框架为CXF,整合spring
Spring+CXF实现WebService,包含了服务端和客户端的代码。
ibatis+spring+cxf+mysql搭建webservice的客户端,文章地址在http://blog.csdn.net/cenyi2013/article/details/17315755. 服务端源码的下载地址在http://download.csdn.net/detail/cenyi2012/6712729
Spring+CXF+tomcat开发webservice,包含服务端和客户端,导入myeclipse就可以用。帮助大家搭建webservice框架,实现webservice功能。
这个代码例子是为了调用CXF提供的WS服务,所以先要下载“CXF和Spring结合的例子”,并将服务器(tomcat)运行起来,在利用本客户端测试,本客户端是根据服务端发布的WSDL文件,用wsdl2java直接生成java代码,加入到...
Apache Cxf WebService整合Spring 处理Map、非javabean式的复合类等CXF无法自动转化的类型 CXF为服务器端和客户端添加自定义拦截器进行权限检查验证并且控制台打印日志
CXF+Spring+Hibernate实现WebService,实现的方法比较简单,只有一个增加的方法,没有用到Struts 有服务端代码和客户端测试代码
testWebService 是webservice的服务端 zxntest 是webservice 的客户端(很大一部分jar包无效) http://localhost:8080/testWebService/webservice/webservice?wsdl 测试路径
cxf调用webservice,客户端最少jar包,只需4个,告别找jar包的繁琐
该客户端jar包,支持多种形式发布的webservice接口。 经测试 xfire发布、cxf发布、spring配置、jdk发布的webservice接口,都可以使用成功。
基于CXF的WebService服务端和客户端示例,CXF+Spring,希望能为WebService开发者提供帮助。WebService,CXF,Spring.
cxf webservice 实例(包括服务端及客户端代码),亲测可用,项目采用spring与cxf结合的,附件解压后看到两个项目,分部是服务端项目和客户端项目,启动tomcat服务器部署后,通过客户端右键运行java 的 mian方法代码...
springboot+webservice搭建webservice服务端及使用java客户端两种方式进行调用webservice接口
spring整合cxf实现restful的webservice服务,代码分为服务端和客户端两个模块;服务端为接口,客户端为接口调用。
CXF 是实现webService ,包括服务端和客户端,还有与spring的结合