Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

SOAPException: Error opening socket

Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I am trying to call a https web service from behind a proxy using Java client on Apache Axis.
Below is the code which i have written till now:


import org.apache.axis.AxisProperties;
import org.apache.soap.Envelope;
import org.apache.soap.messaging.Message;
import org.apache.soap.transport.SOAPTransport;
import org.apache.soap.util.xml.XMLParserUtils;
import org.w3c.dom.Document;

public class test {

public static void main(String[] args) {

try {
//code for passing the proxy
System.setProperty("http.proxySet", "true");
System.setProperty("http.proxyUser", "user name");
System.setProperty("http.proxyPassword", "password of user");
System.setProperty("http.proxyHost", "hostid");
System.setProperty("http.proxyPort", "port");
System.out.println("Before connection");
String endPoint = "https://siteurl";

//code for setting the fake trust factory so that SSL site does not find problem with Security Cerificate

//xml data for input to web-Service method
String[] parmXML = new String[1];
parmXML[0] =
"<View>Global Compliance Data</View>"
+ "<System>Global Compliance</System>"
+ "<Type>XML</Type>"
+ "<user>username provided</user>"
+ "<password>password provided</password>"
+ "<URL>https://siteurl</URL>;"
+ "<Param>RDVUPG30</Param>"
+ "<Param></Param>"
+ "<Param></Param>"
+ "<Param></Param>";

//making the Soap header required by web service
String[] InputXmlData = new String[1];
InputXmlData[0] =
" <soap:Envelope xmlns:xsi=\"\" xmlns:xsd=\"\" xmlns:soap=\"\"> "
+ "<soap:Body>"
+ "<RecvMsg xmlns=\"\">"
+ "<parmXML>"
+ parmXML[0]
+ "</parmXML>"
+ "</RecvMsg>"
+ "</soap:Body>"
+ "</soap:Envelope>";
System.out.println("Before connection 2");
javax.xml.parsers.DocumentBuilder builder =
Document doc =
new ByteArrayInputStream(InputXmlData[0].getBytes()));

System.out.println("Before connection 3_1" + doc.toString());

Envelope msgEnvelope =

//calling the webservice

Message msg = new Message();
System.out.println("Before connection 3");
URL url = new URL("https://siteurl");

msg.send(url, "", msgEnvelope);
//urn is soapAction, url is the target URL
SOAPTransport transport = msg.getSOAPTransport();

Message receivePost = new Message();

Envelope receiveEnvelope = receivePost.receiveEnvelope();

System.out.println("Before connection 5");
System.out.println("after connection");
} catch (Exception e) {
System.out.println("caught exception in block");
System.out.println("Destinations:" + e.toString());

I am getting the following error msg:

Before connection
Before connection 2
Before connection 3_1[Document soap:Envelope]
Before connection 3
caught exception in block
Destinations:[SOAPException: faultCode=SOAP-ENV:Client; msg=Error opening socket: Connection timed out: connect; targetException=java.lang.IllegalArgumentException: Error opening socket: Connection timed out: connect]
[SOAPException: faultCode=SOAP-ENV:Client; msg=Error opening socket: Connection timed out: connect; targetException=java.lang.IllegalArgumentException: Error opening socket: Connection timed out: connect]
at org.apache.soap.transport.http.SOAPHTTPConnection.send(
at org.apache.soap.messaging.Message.send(
at test.main(

Please guide me where i am missing.

Also if the security Certificate is absolutely required, then i have got the Security Certificate for the https webservice. Could anybody guide me how use it within my java client.

Any help would be greatly appreciated.
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic