Web Service Client - Construction Failing Due To Timeout (Proxy Issue)

纵饮孤独 提交于 2020-01-25 11:43:05

问题


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.



来源:https://stackoverflow.com/questions/30403771/web-service-client-construction-failing-due-to-timeout-proxy-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!