Php 使用KSOAP2(Android)发送参数时出现错误
我对KSOAP2的使用感到非常厌倦:我正在搜索一天的解决方案,但什么都找不到 我有一个简单的PHP Web服务,它来自教程中的示例:GetSumOfTwoInts。它接受两个Int参数并返回它们的和 我可以在PHP和Java中调用此Web服务,它工作得很好,但当我使用KSAOP2调用它时,总是会出现相同的错误:Php 使用KSOAP2(Android)发送参数时出现错误,php,android,web-services,ksoap2,Php,Android,Web Services,Ksoap2,我对KSOAP2的使用感到非常厌倦:我正在搜索一天的解决方案,但什么都找不到 我有一个简单的PHP Web服务,它来自教程中的示例:GetSumOfTwoInts。它接受两个Int参数并返回它们的和 我可以在PHP和Java中调用此Web服务,它工作得很好,但当我使用KSAOP2调用它时,总是会出现相同的错误: SoapFault - faultcode: 'SOAP-ENV:Server' faultstring: 'Procedure 'GetSumOfTwoInts' not presen
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_操作,信封);”
这很奇怪,因为我用webservice做了其他尝试,它不带参数,而且运行良好。。。。当我需要参数时,它就不起作用了
我需要你的帮助!!!:)
试用
pi.setType(Integer.class);
您是否尝试使用
request.addProperty(名称、值)
w/o显式设置类型来添加参数?
pi.setType(Integer.class);