Android的ksoap2参数问题 [英] Android ksoap2 parameter issues
本文介绍了Android的ksoap2参数问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想一个参数传递给我的服务,code同时运行,但服务没有收到的参数?呼叫的作品,我只需添加则变量拿回来,得到它回来时,我发现web服务从未收到了!
感谢您的帮助。
最后弦乐SOAP_ACTION =http://NathofGod.com/GetCategoryById;
最后弦乐METHOD_NAME =GetCategoryById;
最后弦乐NAMESPACE =http://NathofGod.com/;
最终字符串URL =http://10.0.2.2:4021/Service1.asmx;SoapObject要求=新SoapObject空间(namespace,METHOD_NAME); 的PropertyInfo PI1 =新的PropertyInfo();
pi1.setName(名称);
pi1.setValue(名称);
pi1.setType(为String.class);
pi1.setNamespace空间(namespace);
request.addProperty(PI1); SoapSerializationEnvelope信封=新SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = TRUE;
envelope.setOutputSoapObject(请求); HttpTransportSE康恩=新HttpTransportSE(URL); 尝试
{
conn.call(SOAP_ACTION,信封);
SoapObject响应=(SoapObject)envelope.getResponse();
} 赶上(例外五)
{
e.printStackTrace();
}
解决方案
不知道为什么不工作,但我记得使用它与
request.addProperty(名,MY_NAME);
和它工作得很好,否则你可能会想检查服务器端...
I am trying to pass a parameter to my service, the code runs but the service never receives the parameters?? The call works, I simply add the variable then get it back, when getting it back I discover the webservice never received it!
Thanks for your help
final String SOAP_ACTION = "http://NathofGod.com/GetCategoryById";
final String METHOD_NAME = "GetCategoryById";
final String NAMESPACE = " http://NathofGod.com/";
final String URL = "http://10.0.2.2:4021/Service1.asmx";
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
PropertyInfo pi1 = new PropertyInfo();
pi1.setName("name");
pi1.setValue("the name");
pi1.setType(String.class);
pi1.setNamespace(NAMESPACE);
request.addProperty(pi1);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE conn = new HttpTransportSE(URL);
try
{
conn.call(SOAP_ACTION, envelope);
SoapObject response = (SoapObject)envelope.getResponse();
}
catch(Exception e)
{
e.printStackTrace();
}
解决方案
not sure about why is not working, but I remember using it with
request.addProperty("name", "my_Name");
and it worked fine, otherwise you may wanna check the server side...
这篇关于Android的ksoap2参数问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文