Web Service Client - Construction Failing Due To T

2019-09-18 18:26发布

问题:

I have a webservice in Java 1.6 that extends javax.xml.ws.Service. The WSDL URL is located at an HTTPS endpoint and I am behind a corporate proxy (NTLM I believe). I have the proxy host, port, username, and password. I have verified that I can access the WSDL using curl if I specify the proxy in my .curlrc file. When the constructor is called it will eventually timeout with the error:

javax.xml.ws.WebServiceException: Failed to access the WSDL at: https://www.blah.com/myservice.asmx?wsdl. It failed with: Connection timed out.

The call that fails is:

public MyService_Service() {
    // this call to super is the one that times out
    super(__getWsdlLocation(), MYSERVICE_QNAME);
}

I have tried the following but none of the solutions work.

  • Client Webservice in java - proxy authentication
  • Java Web Service client basic authentication

What can I do to call the web service from behind a proxy?

回答1:

I was able to get this to work by adding the following code before the server instantiation:

System.setProperty("proxyHost", "myproxy.com");
System.setProperty("proxyPort", "8080");

Strangely this worked when I tested it by setting the VM options -DproxyHost and -DproxyPort so then searched for how to set it programmatically.