5 Replies Latest reply on Mar 9, 2007 2:58 PM by jemodurn

    lower timeout in accessing a web service

    sigitm

      Hi,
      I'm using this code to connect to a web service:

      URL url = new URL("http://www.mysite.org/WebService?wsdl");
      
      QName qname = new QName("http://www.mysite.org/","WebService");
      
      ServiceFactoryImpl factory = new ServiceFactoryImpl();
      Service service = factory.createService(url, qname);
      
      WebServiceEndpoint endpoint = (WebServiceEndpoint) service.getPort(WebServiceEndpoint.class);



      But if the web service is down, this client blocks for about 5 minutes waiting for the web service... till it gives the following exception:

      org.jboss.ws.metadata.wsdl.WSDLException: java.net.ConnectException: Connection timed out: connect


      Is there a way to decrease the connection timeout?

      Thanks.

        • 1. Re: lower timeout in accessing a web service
          sigitm

          Don't you know how to lower the connection timeout? :(
          Please!!

          • 2. Re: lower timeout in accessing a web service
            thomas.diesler

            Not for the wsdl request, but the client should have the wsdl locally anyway. After all it is the abstract contract shared by both parties.

            Also have a look at

            http://jira.jboss.org/jira/browse/JBWS-1410

            • 3. Re: lower timeout in accessing a web service
              jemodurn

              JBWS-1410 is working for JAX-RPC but it is not working for JAX-WS. Is there a jira for this?


              Here is a test case:

              modify the JSR181WebServiceJSETestCase in the jbossws-1.2.0 samples can reproduce the problem.

              public void testWebService() throws Exception
               {
               URL wsdlURL = new File("resources/jaxws/samples/jsr181pojo/META-INF/wsdl/TestService.wsdl").toURL();
               QName qname = new QName("http://org.jboss.ws/samples/jsr181pojo", "TestService");
               Service service = Service.create(wsdlURL, qname);
               port = (EndpointInterface)service.getPort(EndpointInterface.class);
              
               ((Stub) port)._setProperty(StubExt.PROPERTY_CLIENT_TIMEOUT, String
               .valueOf(500));
              
               Object retObj = port.echo(new String[]{});
               assertNotNull(retObj);
               assertEquals(0, ((String[])retObj).length);
               }



              Testcase: testWebService took 1.672 sec
               Caused an ERROR
              $Proxy17
              java.lang.ClassCastException: $Proxy17
               at org.jboss.test.ws.jaxws.samples.jsr181pojo.JSR181WebServiceJSETestCase.testWebService(JSR181WebServiceJSETestCase.java:72)
               at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
               at junit.extensions.TestSetup$1.protect(TestSetup.java:23)
               at junit.extensions.TestSetup.run(TestSetup.java:27)


              • 4. Re: lower timeout in accessing a web service
                jemodurn

                I saw a post on JAX-WS: http://forums.java.net/jive/message.jspa?messageID=109927

                will this work with jbossws 1.2.0?

                ((BindingProvider)port).getRequestContext().put(StubExt.PROPERTY_CLIENT_TIMEOUT, new Integer(500));
                


                • 5. Re: lower timeout in accessing a web service
                  jemodurn

                  I tried this code to lower the JAX-WS client's connection timeout and it works beautifully

                  ((BindingProvider)port).getRequestContext().put(StubExt.PROPERTY_CLIENT_TIMEOUT, new Integer(500));
                  

                  Issue resolved.