SOAPException: Error opening socket: Connection timed out:
"Shaoguang Cong" <[email protected]> Tue, 3 Aug 2004 16:15:38 -0500
| Newsgroups | gmane.text.xml.soap.devel |
|---|---|
| Message-ID | <007601c4799f$068ecf80$103d070a@000D60478325> |
I'm getting the following error when trying to run the sample client and got the exceptions with no idea about what could be the real problem. The client code is attached. 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();
}
}
}