Reputation: 1295
I am using the following code to access the webservice
public SoapObject getWeather() throws Exception
{
SoapObject request = new SoapObject("http://www.freewebservicesx.com", "GetCurrentGoldPrice");
//request.addProperty("PlaceName", city);
request.addProperty("Username","myusername");
request.addProperty("Password","pass");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
// It seems that it is a .NET Web service because it doesn't work without next line
envelope.dotNet = true;
HttpTransportSE transport = new HttpTransportSE("http://www.freewebservicesx.com/GetGoldPrice.asmx");
transport.call("http://freewebservicesx.com/GetCurrentGoldPrice", envelope);
return (SoapObject) envelope.getResponse();
}
public List<CharSequence> getWeatherForecast()
{
SoapObject obj = null;
try {
obj = getWeather();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
//error is being thrown here
Log.e("error",e.getMessage());
}
SoapObject details = (SoapObject) obj.getProperty("GetCurrentGoldPriceResult");
List<CharSequence> list = new ArrayList<CharSequence>(details.getPropertyCount());
for (int i = 0; i < details.getPropertyCount(); i++) {
Object property = details.getProperty(i);
if (property instanceof SoapObject) {
SoapObject weather = (SoapObject) property;
String day = weather.getProperty("string").toString();
String min = weather.getProperty("string").toString();
//String max = weather.getProperty("MaxTemperatureF").toString();
Log.v("ts is whait ai am ",day);
list.add(day + " :: " + min);
}
}
return list;
}
http://www.freewebservicesx.com/GetGoldPrice.asmx?op=GetCurrentGoldPrice contains the details of the service. I get a failed binder transaction eror.
04-07 11:10:01.405: W/System.err(651): SoapFault - faultcode: 'soap:Server' faultstring: 'System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.ArgumentNullException: Value cannot be null.
Upvotes: 0
Views: 2111
Reputation: 149
Please change the line:
envelope.dotNet = "true";
to
envelope.dotNet = "false";
because "true" is always send a null value to webserver,so set a false..
and other thing.. in your code
request.addProperty("Username","myusername");
request.addProperty("Password","pass");
Check your parameter name (Username,Password) on both client and server side webservice that must be same, it means it's case sensitive.
I hope code help you.
Upvotes: 1