Ksoap 在 java webservice 中发送空请求
我的简单应用程序没有向我的简单 Web 服务发送任何请求
package com.demo;
import javax.jws.WebService;
@WebService
public class hello {
public String hai(String name)
{
return "Hello"+name;
}
}
,我的 Android 应用程序代码是
public void onClick(View arg0) {
// TODO Auto-generated method stub
Toast.makeText(this, "success", Toast.LENGTH_LONG).show();
try {
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
//parameters.addProperty("name","muthu");
PropertyInfo username=new PropertyInfo();
username.name="name";
username.type=PropertyInfo.STRING_CLASS;
request.addProperty(username,"welcome");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapPrimitive resultsRequestSOAP = (SoapPrimitive) envelope.getResponse();
Toast.makeText(this, resultsRequestSOAP.toString(), Toast.LENGTH_LONG).show();
}
catch (Exception e) {}
}
}
Web 服务在返回值时工作正常。我可以毫无问题地收到一个值。但是当我的请求返回到我的 Android 客户端时,它总是显示为 null(或)空。
我正在使用 ksoap:
ksoap2-android-assembly-2.5.7-jar-with-dependencies.jar
服务器:
Glassfish 3.1 in eclipse
请帮助我!
My simple application didn't send any request to my simple web service
package com.demo;
import javax.jws.WebService;
@WebService
public class hello {
public String hai(String name)
{
return "Hello"+name;
}
}
and my android app code is
public void onClick(View arg0) {
// TODO Auto-generated method stub
Toast.makeText(this, "success", Toast.LENGTH_LONG).show();
try {
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
//parameters.addProperty("name","muthu");
PropertyInfo username=new PropertyInfo();
username.name="name";
username.type=PropertyInfo.STRING_CLASS;
request.addProperty(username,"welcome");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapPrimitive resultsRequestSOAP = (SoapPrimitive) envelope.getResponse();
Toast.makeText(this, resultsRequestSOAP.toString(), Toast.LENGTH_LONG).show();
}
catch (Exception e) {}
}
}
The web service is working fine when it returns values. I can receive a value without any problem. But my request show always null(or)empty when it return back to my android client side.
I am using ksoap:
ksoap2-android-assembly-2.5.7-jar-with-dependencies.jar
Server:
Glassfish 3.1 in eclipse
Please help me!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许您可以查看这个Android 兼容的 Java Webservice 客户端代码生成器
May be you can look into this Android compatible Java Webservice client code generator