aspose file tools*
The moose likes Web Services and the fly likes SOAPException: Error opening socket Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "SOAPException: Error opening socket" Watch "SOAPException: Error opening socket" New topic
Author

SOAPException: Error opening socket

abhi gupta
Greenhorn

Joined: Dec 15, 2005
Posts: 20
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.
 
Don't get me started about those stupid light bulbs.
 
subject: SOAPException: Error opening socket
 
Similar Threads
Secured Websevice in Applet
Want to understand SOAP Exception's meaning?
binding dataTable problem
Proxy error : 10016
java.net.SocketException on Java Web Start