我正在使用 ksaop2-android 生成我的 Web 服务,这是我使用的 wsdl:http ://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL
这是我的代码:
String serviceUrl = "http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL";
String methodName = "GetCityWeatherByZIP";
SoapObject request = new SoapObject("http://ws.cdyne.com/WeatherWS/",
methodName);
request.addProperty("ZIP", "64101");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER12);
envelope.dotNet = false;
envelope.setOutputSoapObject(request);
HttpTransportSE ht = new HttpTransportSE(serviceUrl);
try {
ht.call("http://wsf.cdyne.com/WeatherWS/Weather.asmx/GetCityWeatherByZIP", envelope);
if (envelope.getResponse() != null) {
SoapObject soapObject = (SoapObject) envelope.getResponse();
System.out.println(soapObject.getProperty("ResponseText"));
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (XmlPullParserException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
我可以通过这个网址得到正确的回复: http ://wsf.cdyne.com/WeatherWS/Weather.asmx/GetCityWeatherByZIP?ZIP=64101
但是,我的代码给了我这样的响应:
在我们的天气数据中找不到城市。请联系 CDYNE 了解更多详情。
似乎没有发送参数,哪一部分可能是错误的?