代码如下:
//WebService的命名空间
static final String namespace = "http://impl.service.suncreate.com";
//服务器发布的url
static final String url = http://10.100.3.41/axis2/services/UploadService;
final String methodName = "upload"; // 函数名
final int sessionID = "111111"; //sessionID
//创建HttpTransportSE对象,通过HttpTransportSE类的构造方法可以指定WebService的url
HttpTransportSE transport = new HttpTransportSE(url);
transport.debug = true;
//指定WebService的命名空间和函数名
SoapObject soapObject = new SoapObject(namespace, methodName);
//设置调用方法参数的值
soapObject.addProperty("sessionID", sessionID); //sessionID
soapObject.addProperty("data", cds); //cds是需要传递的对象
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER10);
envelope.bodyOut = transport;
envelope.setOutputSoapObject(soapObject);
//使用call方法调用WebService方法
transport.call(null, envelope);
SoapObject sb = (SoapObject) envelope.bodyIn;
String xmlMessage = sb.toString(); // 获取从服务器端返回的XML字符串
您可能感兴趣的文章:Android开发调用WebService的方法示例Android 中利用 ksoap2 调用 WebService的示例代码Android ksoap调用webservice批量上传多张图片详解Android 通过webservice上传多张图片到指定服务器详解Android通过ksoap2传递复杂数据类型及CXF发布的webservice详细介绍在Android中调用WebService实例Android通过Webservice操作sqlserver数据库实例代码android调用WebService实例分析android中soap协议使用(ksoap调用webservice)android调用webservice接口获取信息