2

I`m trying to test connection timeout property for jaxws client which is deployed on IBM Websphere Application Server 8.5. I set timeout properties the following way:

((BindingProvider) port).getRequestContext().
           put(com.ibm.wsspi.webservices.Constants.RESPONSE_TIMEOUT_PROPERTY, "30");
((BindingProvider) port).getRequestContext().
           put(com.ibm.wsspi.webservices.Constants.CONNECTION_TIMEOUT_PROPERTY, "15";

RESPONSE_TIMEOUT_PROPERTY works fine.

But I have no idea how to test CONNECTION_TIMEOUT_PROPERTY. If webservice is not available during creating an instance of Service I get the following exception:

javax.xml.ws.WebServiceException: The following WSDL exception occurred: 
            WSDLException: faultCode=WSDL4JWrapper : : javax.wsdl.WSDLException: 
            WSDLException: faultCode=WSDL4JWrapper : :
            java.net.ConnectException: Connection refused: connect

If webservice is not available during creating port(invoking getPort(...) method) I get the following exception:

javax.xml.ws.WebServiceException: 
            java.net.ConnectException: HTTP ( 404 ) Not Found address :
            http://myhost:myport/WsServer/helloService

Exceptions are thrown immediately. I suppose I do something wrong. Any pointers would be helpful.

John Smith
  • 56
  • 1
  • 5

1 Answers1

1

There needs to be a socket open on the server to accept the connection.

Try something like the following

public static void main(String[] args) {
    int port = Integer.parseInt(args[0]);
    try (ServerSocket serviceStub = new ServerSocket(port)) {
            while (true) {
                serviceStub.accept();
                System.out.println("Something connected");
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {

        }
}

Run this on the server (with whatever port you need). It will accept a connection but will never do anything which ought to simulate your timeout.

Generally, anything that listens on a port and does nothing should fit the bill.

Sarah Phillips
  • 923
  • 11
  • 30
  • Sarah, thanks for your answer. I test your solution. Request was completed by response timeout. I have made thread dumps. Web container's thread was running executing method `java/net/SocketInputStream.socketRead0(Native Method)` – John Smith Jun 22 '15 at 14:56
  • Ah, ok. Maybe what you need is here. http://stackoverflow.com/questions/100841/artificially-create-a-connection-timeout-error – Sarah Phillips Jun 24 '15 at 07:47