使用 KSOAP2 发送参数时的错误 (Android)
我对 KSOAP2 的使用感到非常厌倦:我正在搜索解决方案 1 天,但我找不到任何东西...
我有一个简单的 PHP Web 服务,它是从教程中的示例中获取的:GetSumOfTwoInts。它需要两个 Int 参数并返回它们的和。
我可以在 PHP 和 Java 中调用这个 Web 服务,它工作得很好,但是当我用 KSAOP2 调用它时,我总是遇到同样的错误:
SoapFault - faultcode: 'SOAP-ENV:Server' faultstring: 'Procedure 'GetSumOfTwoInts' not present' faultactor: 'null' detail: null
这里,我的代码:
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());
}
}
并且错误发生在这一行:“androidHttpTransport.call(SOAP_ACTION, 信封) );”
这很奇怪,因为我做了其他尝试,使用不带参数的网络服务并且运行良好......只是当我需要参数时它不起作用......
我需要你的帮助! :)
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: 'Procedure '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!!! :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使用
Try use