Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JAX-WS SOAP Service freezes when server does not responses

I have implemented SOAP client from wsdl schema using JAX-WS wsgen tool.
This was done under Windows 32bit JDK 1.6.0_45, JAX-WS RI 2.1.6, Generated source version: 2.1


When service is does not responses, my code just hangs when trying to call Service constructor.

I have spent quite a long time looking for solution. I have found out:
1) Adding timeout system properties like:

sun.rmi.transport.connectionTimeout=50
sun.rmi.transport.tcp.handshakeTimeout=50
sun.rmi.transport.tcp.responseTimeout=50
sun.rmi.transport.tcp.readTimeout=50
sun.net.client.defaultConnectTimeout=50
sun.net.client.defaultReadTimeout=50
timeout=50

2) Adding timeout properties to RequestContext of BindingProvider:

port = service.getExampleServicePort();
        BindingProvider prov = (BindingProvider) port;
        prov.getRequestContext().put("com.sun.xml.internal.ws.request.timeout", requestTimeout);
        prov.getRequestContext().put("com.sun.xml.ws.request.timeout", requestTimeout);
        prov.getRequestContext().put("com.sun.xml.internal.ws.connect.timeout", connectTimeout);
        prov.getRequestContext().put("com.sun.xml.ws.connect.timeout", connectTimeout);

The problem is, that code freezes before I can get a port, particularly when I call the constructor of generated service class, which extends javax.xml.ws.Service :

   service = new ExampleService(url, new QName("http://query.services.example.com/", "ExampleService")); 
//freezes here

Here is the constructor which causes a problem:

/**
 * This class was generated by the JAX-WS RI.
 * JAX-WS RI 2.1.6 in JDK 6
 * Generated source version: 2.1
 * 
 */
@WebServiceClient(name = "ExampleService", targetNamespace = "http://query.services.example.com/", wsdlLocation = "http://myservicehost/services/Query.asmx?WSDL")
public class ExampleService
    extends Service
{

    public ExampleService(URL wsdlLocation, QName serviceName) {
        super(wsdlLocation, serviceName);
    }

    //....
}

Finally, this method of Service just hangs

protected Service(java.net.URL wsdlDocumentLocation, QName serviceName) {
        delegate = Provider.provider().createServiceDelegate(wsdlDocumentLocation,
                serviceName,
                this.getClass());
    }

How can I prevent my ExampleService from freezing when service does not respond (without using another libraries like Apache Axis or JBoss WS)?

Thanks!

like image 647
Artems Avatar asked Jan 22 '26 05:01

Artems


1 Answers

I believe same answer applies to your problem - save WSLD document locally.

like image 159
Arunas Junevicius Avatar answered Jan 23 '26 20:01

Arunas Junevicius