您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
本篇内容主要讲解“android ksoap2中怎么把XML当做参数传递”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“android ksoap2中怎么把XML当做参数传递”吧!
文章目录
处理方法
我的android app中需要发送webservice ,于是我使用了 ksop2 进行发送,在测试过程中不是很顺利,不能正常工作.
我的web service 请求格式如下
<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"> <Body> <UpdateVehicleViaObj xmlns="http://tempuri.org/"> <userHash>[string?]</userHash> <vehicleObject> <Colour xmlns="http://schemas.datacontract.org/2004/07/StockService">[string?]</Colour> <Comments xmlns="http://schemas.datacontract.org/2004/07/StockService">[string?]</Comments> <Condition xmlns="http://schemas.datacontract.org/2004/07/StockService">[string?]</Condition> </vehicleObject> </UpdateVehicleViaObj> </Body> </Envelope>
我在android 代码中使用 ksoap2 如下
SoapObject request = new SoapObject("Namespace", "methodname"); request.addProperty(properyObject); SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); //SOAP is implemented in dotNet true/false. envelope.dotNet = true; MarshalDouble md = new MarshalDouble(); //envelope.implicitTypes = true; envelope.implicitTypes = true; md.register(envelope); //Set request data into envelope and send request using HttpTransport envelope.setOutputSoapObject(request); HttpTransportSE androidHttpTransport = new HttpTransportSE(mInObj.getUrl(), networkTimeOut); androidHttpTransport.debug= true; androidHttpTransport.call(SoapAction, envelope,headerPropertyArrayList);
ksop2 处理请求后变成这样
<v:Envelope xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:c="http://schemas.xmlsoap.org/soap/encoding/" xmlns:v="http://schemas.xmlsoap.org/soap/envelope/"><v:Header /><v:Body><UpdateVehicleViaObj xmlns="http://tempuri.org/" id="o0" c:root="1"><userHash>B5B2FDF87E848946</userHash><vehicleObject><Colour>red</Colour>< & <Comments >red</Comments ><<Condition >red</Condition ><</vehicleObject></UpdateVehicleViaObj></v:Body></v:Envelope>
到此,相信大家对“android ksoap2中怎么把XML当做参数传递”有了更深的了解,不妨来实际操作一番吧!这里是亿速云网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。