If you use the following code, it will show you more details about exception:
if (resp.generatedFault()) { Fault fault = resp.getFault(); call.setFullTargetObjectURI(targetObjectURI); throw new SOAPException(fault.getFaultCode(), fault.getFaultString()); } -- wei -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 11, 2003 9:16 AM To: [EMAIL PROTECTED] Subject: Beginner question Hi, I have experience with Java and XML, but am pretty new to SOAP and WSDL. I've been able to invoke the demo web services provided at xmethods.com using the Java client code provided with no problem. I've been trying to invoke the Unisys Weather web service using the Currency Exchange Service code as a starting point, with no success. After checking to see whether a fault was generated, my code throws a java.lang.Exception. After doing some research on WSDL, I believe part of the problem may be due to the Unisys Weather web service not being encoded. I've included my code below. If anyone would be willing to tell me where I've gone wrong, I'd really appreciate it. Thanks, - Mike. // // sample client for the Unisys Weather service // 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 UnisysWeatherClient { public static String getWeather (URL url, String zipCode) throws Exception { Call call = new Call (); // Set encoding style. Use the standard SOAP encoding String encodingStyleURI = Constants.NS_URI_SOAP_ENC; call.setEncodingStyleURI(encodingStyleURI); // Set service locator parameters call.setTargetObjectURI ("http://www.unisys.com/WebServices/GetWeatherText"); call.setMethodName ("GetWeatherText"); // Create the input parameter vector Vector params = new Vector (); params.addElement (new Parameter("ZipCode", String.class, zipCode, null)); call.setParams (params); // Invoke the service ... Response resp = call.invoke (url,""); // ... and evaluate the result if (resp.generatedFault ()) { throw new Exception(); } else { // Call was succesfull. Extract response parameter and return Parameter result = resp.getReturnValue (); String weather = (String) result.getValue(); return weather; } } // Driver to illustrate invocation of service public static void main(String[] args) { try { URL url=new URL("http://weather.unisysfsp.com/PDCWebService/WeatherServices.asmx"); String zipCode = args[0]; String weather = getWeather(url,zipCode); System.out.println(weather); } catch (Exception e) {e.printStackTrace();} } }