android怎么调用webservice接口
2016-09-08 · 百度知道合伙人官方认证企业
育知同创教育
1【专注:Python+人工智能|Java大数据|HTML5培训】 2【免费提供名师直播课堂、公开课及视频教程】 3【地址:北京市昌平区三旗百汇物美大卖场2层,微信公众号:yuzhitc】
向TA提问
关注
展开全部
//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字符串
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字符串
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询