简体   繁体   English

设置超时以消耗Java实现类中的Web服务

[英]Setting timeout to consume web service in java implementation class

I have a JAX-WS webservice client. 我有一个JAX-WS Web服务客户端。 I tried to set the timeout property like this: 我试图这样设置超时属性:

Map<String, Object> requestContext = bp.getRequestContext();
requestContext.put(BindingProviderProperties.REQUEST_TIMEOUT, 20);
//I also tried using 
//"javax.xml.ws.client.receiveTimeout" in the place of REQUEST_TIMEOUT 
//It behaved the same way.
requestContext.put(BindingProviderProperties.CONNECT_TIMEOUT, 10000); 

For more details see the question How do I set the timeout for a JAX-WS webservice client? 有关更多详细信息,请参阅问题如何为JAX-WS Web服务客户端设置超时?

However, I'm not seeing the timeout occur. 但是,我看不到超时发生。 It should give a read timeout as the service we triggered is not providing a response in 20 milliseconds. 它应该给出读取超时,因为我们触发的服务在20毫秒内未提供响应。 We also tried to making the REQUEST_TIMEOUT value negative but it is giving the same response. 我们还尝试将REQUEST_TIMEOUT值设为负,但给出的响应相同。 From this I confirmed that the value set in request context is not specifying timeout to the service. 由此,我确认了在请求上下文中设置的值未指定服务超时。

Does anyone know why this setting isn't working and what I should be doing instead? 有谁知道为什么这个设置不起作用以及我应该怎么做?

The time out value can be increased by adding "responseTimeout" paramter to the service URL. 可以通过在服务URL中添加“ responseTimeout”参数来增加超时值。 Ex: http://localhost.int.com/service/TestQuery.svc?responseTimeout=10000 例如: http//localhost.int.com/service/TestQuery.svc?responseTimeout = 10000

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM