title: JAX WS com.sun.xml.internal.ws.client.ClientTransportException: HTTP transport error: java.net.ConnectException: Connection refused
body: <p>I am new to JAX-WS. I am trying to access a web service on a remote machine within the company.</p>
  
  <p>I used  wsimport tool to generate JAVA classes from the WSDL resource which is present on our intranet. Java files have been successfully created.</p>
  
  <p>I tried sending a request through SOAPUI, I get a valid response. But when I try to run my code it throws Connection refused.</p>
  
  <p>Here is my code.</p>
  
  <pre><code>URL url = new URL("https://xmattersqa.com/api/services/xmatters-4.1.7?wsdl");
  
  QName qname = new QName("http://www.xmatters.com/webservices/schema#4.1.7", "xmatters-   4.1.7");
  
  FindWhoIsOnDuty f = new FindWhoIsOnDuty();  
  Xmatters417 cdoubleprime = new Xmatters417(url,qname);
  
  Xmatters417PortType port = cdoubleprime.getXmatters417SOAP11PortHttp();
  
  FindWhoIsOnDutyReturn fresponse = port.findWhoIsOnDuty("fmsopsqa","fmsopsqa", "", "", "",   "Default Company", "Test Grp 1","23/02/2013 0:00:00 AM", "24/02/2013 0:00:00 AM", false);
  </code></pre>
  
  <p>Later I tried adding this piece of code , and it still doesnt work.</p>
  
  <pre><code>Authenticator.setDefault(new ProxyAuthenticator("fmsopsqa","fmsopsqa"));
  System.setProperty("http.proxHost","sprdxmaws401.corp.net");
  System.setProperty("http.proxyPort", "8081");
  </code></pre>
  
  <p>This is what I get</p>
  
  <pre><code>com.sun.xml.internal.ws.client.ClientTransportException: HTTP transport error:    java.net.ConnectException: Connection refused
  at      com.sun.xml.internal.ws.transport.http.client.HttpClientTransport.getOutput(HttpClientTransport.java:121)
  at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.process(HttpTransportPipe.java:142)
  at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.processRequest(HttpTransportPipe.java:83)
  at com.sun.xml.internal.ws.transport.DeferredTransportPipe.processRequest(DeferredTransportPipe.java:105)
  at com.sun.xml.internal.ws.api.pipe.Fiber.__doRun(Fiber.java:587)
  at com.sun.xml.internal.ws.api.pipe.Fiber._doRun(Fiber.java:546)
  at com.sun.xml.internal.ws.api.pipe.Fiber.doRun(Fiber.java:531)
  at com.sun.xml.internal.ws.api.pipe.Fiber.runSync(Fiber.java:428)
  at com.sun.xml.internal.ws.client.Stub.process(Stub.java:211)
  at com.sun.xml.internal.ws.client.sei.SEIStub.doProcess(SEIStub.java:124)
  at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:98)
  at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:78)
  at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:107)
  at $Proxy32.findWhoIsOnDuty(Unknown Source)
  at FindDuty.main(FindDuty.java:76)
  Caused by: java.net.ConnectException: Connection refused
  at java.net.PlainSocketImpl.socketConnect(Native Method)
  at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
  at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
  at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
  at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:432)
  at java.net.Socket.connect(Socket.java:529)
  at java.net.Socket.connect(Socket.java:478)
  at sun.net.NetworkClient.doConnect(NetworkClient.java:163)
  at sun.net.www.http.HttpClient.openServer(HttpClient.java:388)
  at sun.net.www.http.HttpClient.openServer(HttpClient.java:523)
  at sun.net.www.http.HttpClient.&lt;init&gt;(HttpClient.java:227)
  at sun.net.www.http.HttpClient.New(HttpClient.java:300)
  at sun.net.www.http.HttpClient.New(HttpClient.java:317)
  at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:970)
  at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:949)
  at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:836)
  at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1014)
  at com.sun.xml.internal.ws.transport.http.client.HttpClientTransport.getOutput(HttpClientTransport.java:109)
  </code></pre>
  
  <p>Service Endpoint links seem to be set correctly.</p>
  
  <pre><code>@WebServiceClient(name = "xmatters-4.1.7", targetNamespace = "http://www.xmatters.com/webservices/schema#4.1.7", wsdlLocation = "https://xmattersqa.com/api/services/xmatters-4.1.7?wsdl")
  </code></pre>