How to Set Timeout for JAX-WS WebService Call

前端 未结 6 1826
醉酒成梦
醉酒成梦 2020-12-14 09:30

I\'m working on a WebService Client and I want to set a Timeout for my WebService Call. I have tried different approaches but still I\'m not able to achieve this. I\'m using

6条回答
  •  南笙
    南笙 (楼主)
    2020-12-14 09:48

    You could try these settings (they are paired to be used in pairs)

    BindingProviderProperties.REQUEST_TIMEOUT
    BindingProviderProperties.CONNECT_TIMEOUT
    

    BindingProviderProperties should be from com.sun.xml.internal.WS.client

    Or the strings for JBoss:

    javax.xml.ws.client.connectionTimeout
    javax.xml.ws.client.receiveTimeout
    

    All properties to be put on getRequestContext() in milliseconds.

    (BindingProvider)wsPort).getRequestContext().put(BindingProviderProperties.REQUEST_TIMEOUT, yourTimeoutInMillisec);
    

    For JBoss specifically, you might want to use the property StubExt.PROPERTY_CLIENT_TIMEOUT from org.jboss.ws.core.StubExt. See this thread for details.

提交回复
热议问题