Android ksoap2参数问题
我试图将参数传递给我的服务,代码运行但服务从未收到参数?调用有效,我只需添加变量然后将其取回,当取回它时,我发现网络服务从未收到它!
感谢您的帮助
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();
}
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();
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
不确定为什么不起作用,但我记得使用它
并且工作正常,否则你可能想检查服务器端......
not sure about why is not working, but I remember using it with
and it worked fine, otherwise you may wanna check the server side...
这行代码是我的问题!!!
删除它
This line of code was my issue!!!
REMOVE IT
尝试按照说明进行调试在维基上。
Try to debug it following the instructions on the wiki.
我稍微清理了一下代码并将其放入一个函数中。我不确定是否有什么不同,但这段代码可以工作。感谢您的回复。
public SoapObjectsoap() 抛出 IOException、XmlPullParserException
{
I cleaned up the code a little and put it in a function. I'm not sure if something is different but this code works. Thanks for the responses.
public SoapObject soap() throws IOException, XmlPullParserException
{
最终字符串 NAMESPACE = " http://NathofGod.com/";
更改为
删除空白并按照请求 XML 上的方式创建命名空间。请注意,它也区分大小写。
final String NAMESPACE = " http://NathofGod.com/";
Change to
Remove the empty space and make then namespace as it is on your request XML. Please note that it is case sensitive as well.