I'm trying to make an Android App that gets the weather based off a zipcode you enter, and that also displays the time in EST and GMT format. I am using webservices (WSDLs) and have the code written to access it, the code is below:
public void sendMessage(View view)
{
SOAP_ACTION = "http://ws.cdyne.com/WeatherWS/GetCityWeatherByZIP";
NAMESPACE = "http://ws.cdyne.com/WeatherWS/";
METHOD_NAME = "GetCityWeatherByZIP";
URL = "http://wsf.cdyne.com/WeatherWS/Weather.asmx?wsdl";
txtZIP = (EditText) findViewById(R.id.zipcode);
temp = (TextView) findViewById(R.id.displayTemp);
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
PropertyInfo property = new PropertyInfo();
{
property.name = "zipcode";
property.setNamespace(NAMESPACE);
property.type = PropertyInfo.STRING_CLASS;
property.setValue(txtZIP.getText().toString());
}
request.addProperty(property);
//request.addProperty("zipcode", txtZIP.getText().toString());
Toast.makeText(getApplicationContext(), "btnZIP pressed", Toast.LENGTH_LONG).show();
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER10);
envelope.setOutputSoapObject(request);
envelope.implicitTypes = true;
envelope.dotNet = true;
HttpTransportSE androidHTTP = new HttpTransportSE(URL, 600);
try {
Toast.makeText(getApplicationContext(), "In try statement", Toast.LENGTH_LONG).show();
androidHTTP.call(SOAP_ACTION, envelope);
// SoapPrimitive resp = (SoapPrimitive) envelope.getResponse();
SoapObject result = (SoapObject) envelope.bodyIn;
if(result != null)
{
Toast.makeText(getApplicationContext(), "In IF statement", Toast.LENGTH_LONG).show();
//temp.append("in IF statement, result not null");
} else {
Toast.makeText(getApplicationContext(), "In ELSE statement", Toast.LENGTH_LONG).show();
//temp.append("in IF statement, result IS null");
}
} catch (HttpResponseException e) {
Toast.makeText(getApplicationContext(), "No Response", Toast.LENGTH_LONG).show();
e.printStackTrace();
} catch (XmlPullParserException e){
Toast.makeText(getApplicationContext(), "XML Pull exe", Toast.LENGTH_LONG).show();
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
Now, my problem is that with the androidHTTP.call(SOAP_ACTION, envelope);
method, nothing is happening. I have Toast methods to show what is being executed, and the furthest I get is into the try block, but never into the if statement.
I have tried looking around seeing what might be the cause and a solution, but I can't seem to find anything for this specific problem. I've extended the time-out for the server to 600 and even made the implicitType to true, but nothing is working. I know I am using SoapEnvelope.VER10 for this method, but I have two other methods where I used VER11 and VER12 and there's no change. If anyone might have an idea as to what might be going on, I'd really appreciate the help. Also, the AndroidManifest.xml has the necessary uses-permission line to access the internet.
!!!! WORKING CONFIRMED !!!
main
middleman
Caller
I have simplified your caller code and I changed the name of the addproperty to ZIP which is what it looks like the input is called in the WSDL. Removed the brackets for the property calls removed Namespace which isnt needed as far as I can tell.