• 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 ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

SOAPException: Error opening socket

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

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 java.io.ByteArrayInputStream;
import java.net.URL;
import java.security.Security;

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
System.setProperty(
"java.protocol.handler.pkgs",
"com.sun.net.ssl.internal.www.protocol");
Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
AxisProperties.setProperty(
"axis.socketSecureFactory",
"org.apache.axis.components.net.SunFakeTrustSocketFactory");

//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=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"> "
+ "<soap:Body>"
+ "<RecvMsg xmlns=\"http://tempuri.org/\">"
+ "<parmXML>"
+ parmXML[0]
+ "</parmXML>"
+ "</RecvMsg>"
+ "</soap:Body>"
+ "</soap:Envelope>";
System.out.println("Before connection 2");
javax.xml.parsers.DocumentBuilder builder =
XMLParserUtils.getXMLDocBuilder();
Document doc =
builder.parse(
new ByteArrayInputStream(InputXmlData[0].getBytes()));

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

Envelope msgEnvelope =
Envelope.unmarshall(doc.getDocumentElement());

//calling the webservice

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

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

Message receivePost = new Message();

receivePost.setSOAPTransport(transport);
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());
e.printStackTrace();
}
}
}

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: java.net.ConnectException: Connection timed out: connect; targetException=java.lang.IllegalArgumentException: Error opening socket: java.net.ConnectException: Connection timed out: connect]
[SOAPException: faultCode=SOAP-ENV:Client; msg=Error opening socket: java.net.ConnectException: Connection timed out: connect; targetException=java.lang.IllegalArgumentException: Error opening socket: java.net.ConnectException: Connection timed out: connect]
at org.apache.soap.transport.http.SOAPHTTPConnection.send(SOAPHTTPConnection.java:354)
at org.apache.soap.messaging.Message.send(Message.java:123)
at test.main(test.java:84)


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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic