How do I set the timeout for a JAX-WS webservice client?
I've used JAXWS-RI 2.1 to create an interface for my web service, based on a WSDL. I can interact with the web service no problems, but haven't been able to specify a timeout for sending requests to the web service. If for some reason it does not respond the client just seems to spin it's wheels forever. Hunting around has revealed that I should probably be trying to do something like this:
I also discovered that, depending on which version of JAXWS-RI you have, you may need to set these properties instead:
The problem I have is that, regardless of which of the above is correct, I don't know where I can do this. All I've got is a
Can anyone point me in the right direction?! |
|||||
|
I know this is old and answered elsewhere but hopefully this closes this down. I'm not sure why you would want to download the WSDL dynamically but the system properties:
should apply to all reads and connects using HttpURLConnection which JAX-WS uses. This should solve your problem if you are getting the WSDL from a remote location - but a file on your local disk is probably better! Next, if you want to set timeouts for specific services, once you've created your proxy you need to cast it to a BindingProvider (which you know already), get the request context and set your properties. The online JAX-WS documentation is wrong, these are the correct property names (well, they work for me).
Of course, this is a horrible way to do things, I would create a nice factory for producing these binding providers that can be injected with the timeouts you want. |
|||||||||||||||||||||
|
The properties in the accepted answer did not work for me, possibly because I'm using the JBoss implementation of JAX-WS? Using a different set of properties (found in the JBoss JAX-WS User Guide) made it work:
|
|||||||||
|
Here is my working solution :
|
|||
This worked for me. |
|||||||||||||
|
If you are using JAX-WS on JDK6, use the following properties:
|
||||
Not sure if this will help in your context... Can the soap object be cast as a BindingProvider ?
On the other hand if you are wanting to set the timeout on the initialization of the MyWebService object then this will not help. This worked for me when wanting to timeout the individual WebService calls. |
|||||
|
the easiest way to avoid slow retrieval of the remote WSDL when you instantiate your SEI is to not retrieve the WSDL from the remote service endpoint at runtime. this means that you have to update your local WSDL copy any time the service provider makes an impacting change, but it also means that you have to update your local copy any time the service provider makes an impacting change. When I generate my client stubs, I tell the JAX-WS runtime to annotate the SEI in such a way that it will read the WSDL from a pre-determined location on the classpath. by default the location is relative to the package location of the Service SEI
the wsldLocation attribute tells the SEI where is can find the WSDL, and the copy makes sure that the wsdl (and supporting xsd.. etc..) is in the correct location. since the location is relative to the SEI's package location, we create a new sub-package (directory) called wsdl, and copy all the wsdl artifacts there. all you have to do at this point is make sure you include all *.wsdl, *.xsd in addition to all *.class when you create your client-stub artifact jar file. (in case your curious, the @webserviceClient annotation is where this wsdl location is actually set in the java code
|
|||
protected by Community♦ Oct 3 '13 at 11:30
Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
Not the answer you're looking for? Browse other questions tagged java web-services soap timeout jax-ws or ask your own question.
I've used JAXWS-RI 2.1 to create an interface for my web service, based on a WSDL. I can interact with the web service no problems, but haven't been able to specify a timeout for sending requests to the web service. If for some reason it does not respond the client just seems to spin it's wheels forever. Hunting around has revealed that I should probably be trying to do something like this:
I also discovered that, depending on which version of JAXWS-RI you have, you may need to set these properties instead:
The problem I have is that, regardless of which of the above is correct, I don't know where I can do this. All I've got is a
Can anyone point me in the right direction?! |
|||||
|
I know this is old and answered elsewhere but hopefully this closes this down. I'm not sure why you would want to download the WSDL dynamically but the system properties:
should apply to all reads and connects using HttpURLConnection which JAX-WS uses. This should solve your problem if you are getting the WSDL from a remote location - but a file on your local disk is probably better! Next, if you want to set timeouts for specific services, once you've created your proxy you need to cast it to a BindingProvider (which you know already), get the request context and set your properties. The online JAX-WS documentation is wrong, these are the correct property names (well, they work for me).
Of course, this is a horrible way to do things, I would create a nice factory for producing these binding providers that can be injected with the timeouts you want. |
|||||||||||||||||||||
|
The properties in the accepted answer did not work for me, possibly because I'm using the JBoss implementation of JAX-WS? Using a different set of properties (found in the JBoss JAX-WS User Guide) made it work:
|
|||||||||
|
Here is my working solution :
|
|||
This worked for me. |
|||||||||||||
|
If you are using JAX-WS on JDK6, use the following properties:
|
||||
Not sure if this will help in your context... Can the soap object be cast as a BindingProvider ?
On the other hand if you are wanting to set the timeout on the initialization of the MyWebService object then this will not help. This worked for me when wanting to timeout the individual WebService calls. |
|||||
|
the easiest way to avoid slow retrieval of the remote WSDL when you instantiate your SEI is to not retrieve the WSDL from the remote service endpoint at runtime. this means that you have to update your local WSDL copy any time the service provider makes an impacting change, but it also means that you have to update your local copy any time the service provider makes an impacting change. When I generate my client stubs, I tell the JAX-WS runtime to annotate the SEI in such a way that it will read the WSDL from a pre-determined location on the classpath. by default the location is relative to the package location of the Service SEI
the wsldLocation attribute tells the SEI where is can find the WSDL, and the copy makes sure that the wsdl (and supporting xsd.. etc..) is in the correct location. since the location is relative to the SEI's package location, we create a new sub-package (directory) called wsdl, and copy all the wsdl artifacts there. all you have to do at this point is make sure you include all *.wsdl, *.xsd in addition to all *.class when you create your client-stub artifact jar file. (in case your curious, the @webserviceClient annotation is where this wsdl location is actually set in the java code
|
|||
protected by Community♦ Oct 3 '13 at 11:30
Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
Not the answer you're looking for? Browse other questions tagged java web-services soap timeout jax-ws or ask your own question.
最新文章
- Atitit.uke 团队建设的组织与运营之道attilax总结
- 解密FFmpeg播放track mode控制
- poj1144 求不同割点的个数
- Mac Pro 安装 cmake,报错 Warning: cmake-3.5.2 already installed, it's just not linked
- Activity(活动)-再讲
- CentOS怎样强制卸载PHP以及自定义安装PHP
- C/S打包(图文)
- Sublime Text汉化方法和注册码
- Spark之路 --- Scala IDE Maven配置(使用开源中国的Maven库)和使用
- Poco版信号槽
- [转] iOS TableViewCell 动态调整高度
- android用户界面之ScrollView教程实例汇总
- MapReduce 简单的全文搜索
- 学习笔记::LCT
- python面试题整合
- SVN、CVS、VSS区别
- Neo4j 安装插件APOC和GRAPH ALGORITHMS
- week4--系统调用的工作机制
- (转)看穿机器学习(W-GAN模型)的黑箱
- error_log
热门文章
- [UOJ#128][BZOJ4196][Noi2015]软件包管理器
- java面试题之hashcode相等两个类一定相等吗?equals呢?相反呢?
- bzoj1975: [Sdoi2010]魔法猪学院【k短路&;A*算法】
- charts 画折线图
- poj 3692 Kindergarten
- 【Eclipse】eclipse部署web项目至本地的tomcat但在webapps中找不到
- Codeforces Round #511 (Div. 2) C. Enlarge GCD
- 让win7任务条上的文件夹打开是c,d,e,f而不是库
- js上传文件研究
- linux命令stat,查看文件详细信息