1.下载导入 ksoap2-android-assembly-3.0.0-RC.4-jar-with-dependencies.jar
2.请求数据,在子线程中进行
HttpTransportSE ht = new HttpTransportSE(url);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
SoapObject request = new SoapObject(SERVICE_NAMESPACE, mathodName);
request.addProperty("USER", etName);
request.addProperty("ID", id);
envelope.bodyOut = request;
envelope.setOutputSoapObject(request);
ht.debug = true;// 可调式
try {
ht.call(soapAction, envelope);
SoapObject result = (SoapObject) envelope.getResponse();
// Log.e("TAG", "==result=="+result);
} catch (IOException e) {
e.printStackTrace();
} catch (XmlPullParserException e) {
e.printStackTrace();
}3.注意参数不能为空。
空间名,方法名由服务器提供。
soapAction=空间名+方法名。
本文介绍如何使用ksoap2-android库发起SOAP请求。主要包括:下载并导入库文件;在子线程中构建HTTP请求,设置SOAP消息的属性及执行请求;确保参数不为空。适用于需要与SOAP服务交互的应用开发者。
495

被折叠的 条评论
为什么被折叠?



