Bug when sending parameters with KSOAP2 (Android)
I'm very bored with the using of KSOAP2 : i'm searching a solution for 1 day and I can't find anything...
I have a simple PHP Webservice that I took from example in tutorial : GetSumOfTwoInts. It takes two Int in parameters and return their sum.
I can call this webservice in PHP and in Java, it works good, but when I call it with KSAOP2 I have always the same error :
SoapFault - faultcode: 'SOAP-ENV:Server' faultstring: 'P开发者_运维知识库rocedure 'GetSumOfTwoInts' not present' faultactor: 'null' detail: null
Here, my code :
public void onCreate( Bundle icicle )
{
super.onCreate(icicle);
TextView tv = new TextView(this);
setContentView(tv);
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
PropertyInfo pi = new PropertyInfo();
pi.setName("Operand1");
pi.setValue(40);
pi.setType(int.class);
request.addProperty(pi);
PropertyInfo pi2 = new PropertyInfo();
pi2.setName("Operand2");
pi2.setValue(6);
pi2.setType(int.class);
request.addProperty(pi2);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try
{
androidHttpTransport.call(SOAP_ACTION, envelope);
String result = envelope.bodyIn.toString();
Toast.makeText(this, result, 10000).show();
Log.v("TEST", result);
}
catch(Exception e)
{
e.printStackTrace();
Log.v("TEST1", e.toString());
}
}
ANd the error occured at this line : "androidHttpTransport.call(SOAP_ACTION, envelope);"
It's very strange, because I maked other attemps, with webservice which don't take parameters and it works good.... It just when I need parameters that it doesn't work....
I Need Your Help!!! :)
pi.setType(int.class);
Try use
pi.setType(Integer.class);
精彩评论