title: Java Web service client can't connect to BPEL webservice when SoapUI can
body: <p>I am experiencing the following error and after extensive research on the matter with a few similar issues, none seem to help.</p>
  
  <p>My error:</p>
  
  <pre><code>    com.sun.xml.internal.ws.client.ClientTransportException: HTTP transport error: java.net.ConnectException: Connection refused: connect
      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 com.sun.proxy.$Proxy33.onboardPerson(Unknown Source)
      at com.paychex.corp.fileloader.FileloaderMain.callWebService(FileloaderMain.java:202)
      at com.paychex.corp.fileloader.FileloaderMain.main(FileloaderMain.java:104)
  Caused by: java.net.ConnectException: Connection refused: connect
      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:366)
      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:411)
      at sun.net.www.http.HttpClient.openServer(HttpClient.java:525)
      at sun.net.www.http.HttpClient.&lt;init&gt;(HttpClient.java:208)
      at sun.net.www.http.HttpClient.New(HttpClient.java:291)
      at sun.net.www.http.HttpClient.New(HttpClient.java:310)
      at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:987)
      at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:966)
      at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:841)
      at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1031)
      at com.sun.xml.internal.ws.transport.http.client.HttpClientTransport.getOutput(HttpClientTransport.java:109)
  </code></pre>
  
  <p>My client is generated from wsimport using the WSDL file that IS visible from the active service. Code connection sample: URL and service name, etc are correct, can't list for security</p>
  
  <pre><code>URL url = new URL("http://correctserviceurl?WSDL");
          QName qname = new QName("http://correct servicelocation","nameofService");
          CorporateEmployeeOnboardingService service = new CorporateEmployeeOnboardingService(url, qname);
  
          //CorporateEmployeeOnboardingService service = new CorporateEmployeeOnboardingService();
          CorporateEmployeeOnboardingProcess process = service.getICorporateEmployeeOnboardingProcess();
          OnboardRequestType onboardRequest = new OnboardRequestType();
  
  /**
           * TESTING SECTION FOR PROCESS CALL
           */
          //create necessary complex types:
          GregorianCalendar gregorianCalendar = new GregorianCalendar();
          DatatypeFactory datatypeFactory;
          datatypeFactory = DatatypeFactory.newInstance();
          XMLGregorianCalendar testDate = 
              datatypeFactory.newXMLGregorianCalendar(gregorianCalendar);
          testDate.setYear(1991);
          testDate.setMonth(4);
          testDate.setDay(3);
          AssignmentComplexType testAssignment = new AssignmentComplexType();
          testAssignment.setHiringManagerID("123445");
          //set person to send
          person.setSSN("333-33-3333");
          person.setFirstName("testFname");
          person.setLastName("testLname");
          person.setDOB(testDate);
          person.setHireDate(testDate);
          person.setAssignment(testAssignment);
          /**
           * end testing section of the person creation
           */
          onboardRequest.getPerson().add(person);//add a person to the array of people for the request
      ServiceResponse response = process.onboardPerson(onboardRequest);
  </code></pre>
  
  <p>As stated SoapUI can send this same test information and get a perfectly valid request from the service. All information the same. I have been digging around for awhile and confirmed that there is no proxy, both are same bit (32/64 in this case both 32), service name and WSDL are correct and objects are named properly, etc. I did further debugging trying to get around this awful error code that has seemingly no usable information and using wireshark compared the SoapUI request to the java request to find that SoapUI was using POST and the java client was using GET which has me leaning on this right now as the source of the generic refused connection error. </p>
  
  <p>The service is using BPEL to run and was created using BPEL so all code was basically generated. I will be looking at the Get/post find as of now but wanted to get this out there as I am doubtful it could be the cause.</p>
  
  <p>Any help is greatly appreciated. Let me know if I forgot any key information I might be able to share.</p>
  
  <h2>EDIT</h2>
  
  <p>I wanted to add that I am able to access the endpoint URL in the web browser from the machine that I am using to try and connect to the BPEL service. It seems the issue is solely with the client generated from the WSDL stubs I got using wsimport for the service's WSDL.</p>
  
  <h2>Edit 2: Development/Progress</h2>
  
  <p>The issue seems to be that the client is sending the response to local host even after setting up the qname to the correct address. I am now trying to figure out where this local host is being set. Any ideas on this development would be greatly appreciated.</p>