Reputation: 297
I am using ksaop2-android to generate my web service, and here is the wsdl i use: http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL
This is my code:
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();
}
I can get correct response by this url: http://wsf.cdyne.com/WeatherWS/Weather.asmx/GetCityWeatherByZIP?ZIP=64101
However, my code give me the response like this:
City could not be found in our weather data. Please contact CDYNE for more Details.
It seems the argument was not been sent, which part could be wrong?
Upvotes: 1
Views: 2262
Reputation: 16364
SoapObject request = new SoapObject(NAMESPACE, METHOD);
request.addProperty("ZIP", "64101");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER12);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try {
androidHttpTransport.call(SOAP_ACTION, envelope);
.....
} catch (Exception e) {
e.printStackTrace();
}
where
SOAP_ACTION = "http://ws.cdyne.com/WeatherWS/GetCityForecastByZIP";
URL = "http://wsf.cdyne.com/WeatherWS/Weather.asmx";
METHOD = "GetCityForecastByZIP";
NAMESPACE = "http://ws.cdyne.com/WeatherWS/";
Upvotes: 2
Reputation: 174
try this:
ht.call("http://ws.cdyne.com/WeatherWS/GetCityWeatherByZIP", envelope);
instead of:
ht.call("http://wsf.cdyne.com/WeatherWS/Weather.asmx/GetCityWeatherByZIP", envelope);
Upvotes: 0