开发者社区> 问答> 正文

spring webservicetemplate访问webservice怎么设置超时时间?

客户端使用webservicetemplate访问,调用

marshalSendAndReceive(String uri, Object requestPayload, WebServiceMessageCallbak requestCallback)

方法,怎么样设置超时时间?

展开
收起
小旋风柴进 2016-03-05 09:09:30 3334 0
1 条回答
写回答
取消 提交回答
  • 你这样设置就行

    <?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:osgi="http://www.springframework.org/schema/osgi"    
        xmlns:p="http://www.springframework.org/schema/p" 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.xsd    
             http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.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"    
        default-autowire="byName">    
            <!-- 默认conduit, 链接超时10秒,读超时30秒 -->    
        <http-conf:conduit name="*.http-conduit">    
            <http-conf:client ConnectionTimeout="10000" ReceiveTimeout="30000"/>    
        </http-conf:conduit>    
            
        
        <!-- 针对单个Ws服务设置超时时间 -->    
        <jaxws:client id="maOnlineWS"    
            serviceClass="com.sdo.ma.ws.api.service.online.IMaOnlineWS"    
            address="${ma-onlie.service.url}/OnlineService" />    
        <http-conf:conduit name=".*/OnlineService">    
             <http-conf:client ConnectionTimeout="10000" ReceiveTimeout="10000"/>    
        </http-conf:conduit>     
      
          <!--未设置超时时间,则会采用默认超时策略-->    
            <jaxws:client id="InstOnlineWS"    
            serviceClass="com.sdo.ma.ws.api.service.online.IInstOnlineWS"    
            address="${ma-onlie.service.url}/InstOnlineService" />    
    <beans>   
    2019-07-17 18:52:53
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
云栖社区特邀专家徐雷Java Spring Boot开发实战系列课程(第20讲):经典面试题与阿里等名企内部招聘求职面试技巧 立即下载
微服务架构模式与原理Spring Cloud开发实战 立即下载
阿里特邀专家徐雷Java Spring Boot开发实战系列课程(第18讲):制作Java Docker镜像与推送到DockerHub和阿里云Docker仓库 立即下载

相关实验场景

更多