Search code examples
ssljax-wswebservice-client

Connection timed out trying to call asmx https web service from JAX-WS


I'm trying to call an external web service whose endpoint is beyond https.

We are trying to make the call with JAX-WS (Oracle standard implementation from Java EE 6).

From SoapUI after setting the proxy it works correctly, but from our code we get this stack trace:

[11/13/12 12:46:55:389 CET] 00000024 SystemErr R javax.xml.ws.WebServiceException: java.net.ConnectException: Connection timed out: no further information
[11/13/12 12:46:55:405 CET] 00000024 SystemErr R at org.apache.axis2.jaxws.ExceptionFactory.createWebServiceException(ExceptionFactory.java:175)
[11/13/12 12:46:55:405 CET] 00000024 SystemErr R at org.apache.axis2.jaxws.ExceptionFactory.makeWebServiceException(ExceptionFactory.java:70)
[11/13/12 12:46:55:405 CET] 00000024 SystemErr R at org.apache.axis2.jaxws.ExceptionFactory.makeWebServiceException(ExceptionFactory.java:128)
[11/13/12 12:46:55:405 CET] 00000024 SystemErr R at org.apache.axis2.jaxws.core.controller.impl.AxisInvocationController.execute(AxisInvocationController.java:586)
[11/13/12 12:46:55:405 CET] 00000024 SystemErr R at org.apache.axis2.jaxws.core.controller.impl.AxisInvocationController.doInvoke(AxisInvocationController.java:130)
[11/13/12 12:46:55:405 CET] 00000024 SystemErr R at org.apache.axis2.jaxws.core.controller.impl.InvocationControllerImpl.invoke(InvocationControllerImpl.java:93)
[11/13/12 12:46:55:405 CET] 00000024 SystemErr R at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.invokeSEIMethod(JAXWSProxyHandler.java:364)
[11/13/12 12:46:55:405 CET] 00000024 SystemErr R at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.invoke(JAXWSProxyHandler.java:185)

We don't know why we obtain a connection timeout, because from SoapUI everything is ok...

Here's the code we are using:

ResultBlock rb = null;
Matching stub=new Matching();
MatchingSoap soapPort = stub.getMatchingSoap();
BindingProvider provider = (BindingProvider) soapPort;
Map<String, Object> context = provider.getRequestContext();
if(!"".equals("cvsa"))//Conf.getPROXY_URL()
{
    System.getProperties().get("http.proxyPort");
    //Authenticator.setDefault(new ProxyAuthenticator("user", "password")); 
    System.getProperties().put("proxySet", "true");
    System.setProperty("http.proxyHost", "proxy.xxxxx.xxxx.xx"); 
    System.setProperty("http.proxyPort", "3128"); 
}
context.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "https://xxx.xxx.xxx.xxx/OnlineMatchingCore/OnlineMatching.asmx" );
//context.put(JAXWSProperties.HTTP_CLIENT_STREAMING_CHUNK_SIZE, 8192);
System.out.println(provider.getEndpointReference().toString());
// Authenticator.setDefault(new ProxyAuthenticator("USER", "PASSWORD"));


// Security.setProperty("ssl.SocketFactory.provider", "com.ibm.jsse2.SSLSocketFactoryImpl");
// Security.setProperty("ssl.ServerSocketFactory.provider", "com.ibm.jsse2.SSLServerSocketFactoryImpl");

String result = soapPort.match(controlXml, batchXml, "USER", "PASSWORD");

I saw lot of threads on the internet about problems like this, but I couldn't find any solution:

I don't know what to try, my idea is that I'm missing something about telling java the webservice is on https...


Solution

  • Did you try setting the https proxy, instead of http proxy?

    System.setProperty("https.proxyHost", "proxy ip");
    System.setProperty("https.proxyPort", "port");