File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes Why is CONNECT_TIMEOUT defined in BindingProviderProperties? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Why is CONNECT_TIMEOUT defined in BindingProviderProperties?" Watch "Why is CONNECT_TIMEOUT defined in BindingProviderProperties?" New topic
Author

Why is CONNECT_TIMEOUT defined in BindingProviderProperties?

Meghana Reddy
Ranch Hand

Joined: Jan 29, 2002
Posts: 76
Hi

JAX-WS wsimport generates a Service sub-class as below:



Now I use this code as in my web service client class as follows:



Now my question is - what is the point of setting, CONNECT_TIMEOUT in the above code,
since the Service class which opens the java.net.URLConnection to fetch the WSDL from the remote host, had already done so?
What I want to do is set a connection time out when the Service class attempts to get the WSDL.

Please don't tell me to modify the generated Service sub class constructor because, I don't like the idea of modifying a generated class.

Thanks
Meghana


Meghana Reddy
Meghana Reddy
Ranch Hand

Joined: Jan 29, 2002
Posts: 76
Anyone?
Abhijit Durge
Greenhorn

Joined: Oct 31, 2012
Posts: 9
Hi

Would like to know why would you require a connect timeout when the WSDL is at a file location.

--
Regards,
Abhijit
Meghana Reddy
Ranch Hand

Joined: Jan 29, 2002
Posts: 76
For the sake of argument, lets assume we are loading the WSDL dynamically from a URL.
Abhijit Durge
Greenhorn

Joined: Oct 31, 2012
Posts: 9
Meghana Reddy wrote:
public static void main(String a[]) {
orderService = new OrderProcess(); //Service sub-class is instantiated which immediately tries to connect to the WSDL URL.
// We don't have the opportunity to let the JAX-WS RI to use the connection timeout.


since the Service class which opens the java.net.URLConnection to fetch the WSDL from the remote host, had already done so?
What I want to do is set a connection time out when the Service class attempts to get the WSDL.


As with the snippet in your post, not able to see where the URL objects openConnection() or openStream() method is being called or URLConnection is being used. Please share the associated generated stub.



Meghana Reddy wrote:
Now my question is - what is the point of setting, CONNECT_TIMEOUT in the above code,


This is used when webservice client sends requests(executes a method) to the webService.

--
Regards,
Abhijit.
Meghana Reddy
Ranch Hand

Joined: Jan 29, 2002
Posts: 76
Here is the actual generated code that loads the WSDL from URL.



Meghana Reddy
Ranch Hand

Joined: Jan 29, 2002
Posts: 76
Abhijit Durge wrote:
This is used when webservice client sends requests(executes a method) to the webService.


Are you sure? I think when the web service client sends requests , the "com.sun.xml.internal.ws.request.timeout" (which is the BindingProvider.REQUEST_TIMEOUT) setting controls this.
Abhijit Durge
Greenhorn

Joined: Oct 31, 2012
Posts: 9
Meghana Reddy wrote:
baseUrl = com.order.process.gen.OrderService_Service.class.getResource(".");
//Here is where the CONNECT_TIMEOUT comes into picture
//since metro uses JDK's URLConnection class to obtain the WSDL.
//Since this is a generated class, we don't want to modify this and set a CONNECT_TIMEOUT here
url = new URL(baseUrl, "http://r8kmrzv:8080/orderweb/orderservice?wsdl");


1) Good to see now you are loading the WSDL from http instead of file.
2) Setting the following system properties will help you to provide timeouts when accessing the WSDL
sun.net.client.defaultConnectTimeout
sun.net.client.defaultReadTimeout

Meghana Reddy wrote:
Are you sure? I think when the web service client sends requests , the "com.sun.xml.internal.ws.request.timeout" (which is the BindingProvider.REQUEST_TIMEOUT) setting controls this.



Hope this gives you a better picture between the two:
CONNECT_TIMEOUT: It is the time taken to establish a (socket) connection
REQUEST_TIMEOUT: Maximum time between establishing a connection and receiving data from the connection.

--
Regards,
Abhijit.
Meghana Reddy
Ranch Hand

Joined: Jan 29, 2002
Posts: 76
I still didn't get the exact answer for my question.

AFAIK, the system properties will set the connect timeout at the system level which I don't want. I want to set the connect timeout for that specific URLConnection.

I understand the connect and request time outs.

// This is what I want which is what the service class will do when trying to fetch the WSDL from a URL but before we have a chance to get the port.
CONNECT_TIMEOUT: It is the time taken to establish a (socket) connection

// I'm not concerned about this. Because I can set this after obtaining the port and before invoking the business web service method.
REQUEST_TIMEOUT: Maximum time between establishing a connection and receiving data from the connection.

shyam ji gautam
Ranch Hand

Joined: Sep 17, 2011
Posts: 49
Hi Meghna ;

Shyam from bangalore; I am also faving the same problem . so finally where youy put the conection time out and receive time out in your code . means
what is exact place to put the conection time out and receive timeout .

puting this after getting port is write ?


- Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why is CONNECT_TIMEOUT defined in BindingProviderProperties?