The client is unable to connect to the server at the TCP/IP level. Are you behind a
firewall that requires you to use an HTTP proxy to connect to the outside?
Scott Nichol
Do not send e-mail directly to this e-mail address,
because it is filtered to accept only mail from
specific mail lists.
----- Original Message -----
From: "Shaoguang Cong" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, August 03, 2004 5:15 PM
Subject: SOAPException: Error opening socket: Connection timed out:
I'm getting the following error when trying to run the sample client attached and got
the exceptions with no idea about what could be the real problem. Thanks for any help.
-Shao
[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.rpc.Call.invoke(Call.java:248)
at com.uhc.ubh.facets.util.CurrencyExchange.getRate(CurrencyExchange.java:46)
at com.uhc.ubh.facets.util.CurrencyExchange.main(CurrencyExchange.java:21)
import java.io.*;
import java.net.*;
import java.util.*;
import org.apache.soap.util.xml.*;
import org.apache.soap.*;
import org.apache.soap.rpc.*;
public class CurrencyExchange {
public static void main(String[] args) {
try {
String url = new String("http://services.xmethods.net:80/soap");
String country1= "us";
String country2= "taiwan";
float rate = getRate(url, country1, country2);
System.out.println(rate);
} catch (Exception ex)
{
ex.printStackTrace();
}
}
public static float getRate (String url, String country1, String country2) throws
Exception {
Call call = new Call();
// Service uses standard SOAP encoding
String encodingStyleURI = Constants.NS_URI_SOAP_ENC;
call.setEncodingStyleURI(encodingStyleURI);
// Set service locator parameters
call.setTargetObjectURI("urn:xmethods-CurrencyExchange");
call.setMethodName("getRate");
call.setTimeout(600);
// Create input parameter vector
Vector params = new Vector();
params.addElement(new Parameter("country1", String.class, country1, null));
params.addElement(new Parameter("country2", String.class, country2, null));
call.setParams(params);
// Invoke the service ....
Response resp = call.invoke(new java.net.URL(url), "");
// ... and evaluate the response
if (resp.generatedFault()) {
throw new Exception();
}
else {
// Call was successful. Extract response parameter and return result
Parameter result = resp.getReturnValue();
Float rate = (Float) result.getValue();
return rate.floatValue();
}
}
}