How to Set Timeout for JAX-WS WebService Call

前端 未结 6 1777
醉酒成梦
醉酒成梦 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:40

    Like kolossus said you should use:

    com.sun.xml.internal.ws.client.BindingProviderProperties     
    

    And String values are:

    com.sun.xml.internal.ws.connect.timeout
    com.sun.xml.internal.ws.request.timeout
    

    Although internal packages shouldn't be used, this is the only way if you work with default JDK6. So, in this case setting receive and connect timeout should be done with:

    bindingProvider.getRequestContext().put(BindingProviderProperties.REQUEST_TIMEOUT,requestTimeoutMs);
    
    bindingProvider.getRequestContext().put(BindingProviderProperties.CONNECT_TIMEOUT,connectTimeoutMs);
    

    But beware, constant values are different if you are using other JAXWS reference implementation, i.e. JAXWS-RT 2.1.4 BindingProviderProperties:

    com.sun.xml.ws.client.BindingProviderProperties
    

    you will have different String values for REQUEST_TIMEOUT and CONNECT_TIMEOUT:

    com.sun.xml.ws.request.timeout
    com.sun.xml.ws.connect.timeout
    

提交回复
热议问题