How to put time restriction on web service function call?

Add the following 2 imports

import com.sun.xml.ws.developer.JAXWSProperties;
import javax.xml.ws.BindingProvider;

Just add this before the function call where you call web service.


((BindingProvider)port).getRequestContext()
.put(JAXWSProperties.CONNECT_TIMEOUT, 100);
((BindingProvider)port).getRequestContext()
.put(JAXWSProperties.REQUEST_TIMEOUT, 100);