Search code examples
javawsdlwebservice-client

WSDLException ... An error occurred trying to resolve schema ... Connection timed out: connect


First of all, my error is almost identical to what is reported in this question: WSDLException : An error occurred trying to resolve schema referenced at

Here is a snippet of my stack dump:

javax.wsdl.WSDLException: WSDLException (at /definitions/types/xs:schema/xs:schema): faultCode=OTHER_ERROR: An error occurred trying to resolve schema referenced at 'http://www.w3.org/2005/05/xmlmime', relative to 'http://server.subdom.domain.com:13080/SM/7/Common.xsd'.: java.net.ConnectException: Connection timed out: connect] MDC{}
2015-05-24 14:36:33,751 ERROR (c.d.g.w.c.ContexteApplicatif.contextInitialized) [main] catching MDC{}
javax.xml.rpc.ServiceException: Error processing WSDL document: 
javax.wsdl.WSDLException: WSDLException (at /definitions/types/xs:schema/xs:schema): faultCode=OTHER_ERROR: An error occurred trying to resolve schema referenced at 'http://www.w3.org/2005/05/xmlmime', relative to 'http://server.subdom.domain.com:13080/SM/7/Common.xsd'.: java.net.ConnectException: Connection timed out: connect
      at org.apache.axis.client.Service.initService(Service.java:250) ~[axis-1.4.jar:?]

This occurs in my embedded Tomcat server running from within Eclipse. It is running on a Windows machine and there is an httpProxy at the system level. However, the URL is an internal address for which no proxy is needed. Anyhow, I implemented programmatically a proxy with the following code just before the reference to the WSDL file:

System.setProperty("http.proxySet", "true");
System.setProperty("http.proxyHost", "proxyhost.subdom.domain.com");
System.setProperty("http.proxyPort", "8080");
System.setProperty("https.proxyHost", "proxyhost.subdom.domain.com");
System.setProperty("https.proxyPort", "8080");

And now I am getting an HTTP 502 error which indicate a bad gateway. So, I suppose this solution is the wrong one since I shouldn't need a proxy in first place. I can access the page from within a browser, indistinctly if I enable or disable the proxy settings. In addition, there is a script to configure the proxy and if I use the proxy host shown above and hardcode it in my browser instead of "system proxy" or "automatic setting" I cannot access the page.

To summarize, it behaves like there is like it needs a proxy setup, however it doesn't. The problem is elsewhere and I have no idea how I can make significant progress to debug this problem.

Any hints? Something with Tomcat? Something with Eclipse?

I haven't tried yet on a standalone Tomcat server since my code is not yet ready for deployement.

NOTE: BTW, I tried the command from the quoted post and I am getting the same error as well. Connect timed out without system properties defined for the proxy and 502 code otherwise. At the same time, if I am launching the Web Service Explorer from Eclipse I am perfectly able to access the webservice and invoke operations.

Further investigation: I decided to use WireShark to see what is going on with the request and it appears both HTTP requests (the wsdl and the common types definitions) were fulfilled without a glitch and no connection timed out at all, not a single error. I can see the XML in WireShark and the HTTP status is 200 OK and everything is perfectly fine at this level.

So, what is going on here? I have the same problem on a Linux server while the message is a bit different. What wsdl2java is doing to believe there was a problem and abort?


Solution

  • After further investigation and testing with Axis2 and CXF, I finally found the problem, thanks to the CXF's version of the wsdl2java script which is giving a bit more details.

    First of all, the original solution proposed was almost correct. I actually need to add all the proxy information, however I also needed to specify the non-proxy hosts otherwise I am getting the 502 error. The messages from the Axis script were not very detailed about the offending request, while CXF's version was very clear and enabled me to finally solve my problem.

    So, in addition, if you modify the wsdl2java script, add -Dhttp.nonProxyHosts=... in addition to other options. The same thing if you need to specify a proxy programmatically.