您好,登錄后才能下訂單哦!
本篇內容主要講解“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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。