我的android app中需要发送webservice ,于是我使用了 ksop2 进行发送,在测试过程中不是很顺利,不能正常工作.
我的web service 请求格式如下

[html] view plain copy
  1. <Envelopexmlns="http://schemas.xmlsoap.org/soap/envelope/">
  2. <Body>
  3. <UpdateVehicleViaObjxmlns="http://tempuri.org/">
  4. <userHash>[string?]</userHash>
  5. <vehicleObject>
  6. <Colourxmlns="http://schemas.datacontract.org/2004/07/StockService">[string?]</Colour>
  7. <Commentsxmlns="http://schemas.datacontract.org/2004/07/StockService">[string?]</Comments>
  8. <Conditionxmlns="http://schemas.datacontract.org/2004/07/StockService">[string?]</Condition>
  9. </vehicleObject>
  10. </UpdateVehicleViaObj>
  11. </Body>
  12. </Envelope>


我在android 代码中使用 ksoap2 如下

[java] view plain copy
  1. SoapObjectrequest=newSoapObject("Namespace","methodname");
  2. request.addProperty(properyObject);
  3. SoapSerializationEnvelopeenvelope=newSoapSerializationEnvelope(SoapEnvelope.VER11);
  4. //SOAPisimplementedindotNettrue/false.
  5. envelope.dotNet=true;
  6. MarshalDoublemd=newMarshalDouble();
  7. //envelope.implicitTypes=true;
  8. envelope.implicitTypes=true;
  9. md.register(envelope);
  10. //SetrequestdataintoenvelopeandsendrequestusingHttpTransport
  11. envelope.setOutputSoapObject(request);
  12. HttpTransportSEandroidHttpTransport=newHttpTransportSE(mInObj.getUrl(),networkTimeOut);
  13. androidHttpTransport.debug=true;
  14. androidHttpTransport.call(SoapAction,envelope,headerPropertyArrayList);


ksop2 处理请求后变成这样

[html] view plain copy
  1. <v:Envelopexmlns: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><UpdateVehicleViaObjxmlns="http://tempuri.org/"id="o0"c:root="1"><userHash>B5B2FDF87E848946</userHash><vehicleObject><Colour>red</Colour><
  2. &
  3. <Comments>red</Comments><<Condition>red</Condition><</vehicleObject></UpdateVehicleViaObj></v:Body></v:Envelope>


求救:

处理方法

看看官方的 ksoap2 文档
https://code.google.com/p/ksoap2-android/wiki/CodingTipsAndTricks#sending/receiving_array_of_complex_types_or_primitives

你可以创建一个实现marshable接口的类,并在类中添加其他属性


原文地址:http://www.itmmd.com/201412/296.html
该文章由萌萌的IT人整理发布,转载须标明出处。

更多相关文章

  1. GridView属性
  2. android -------- ConstraintLayout 约束属性(二)
  3. android控件的属性
  4. 安卓新手之路——关于layout一些属性的整理
  5. ViewPager中属性android:flipInterval="30" android:persistentD

随机推荐

  1. Top Android App使用的组件 2
  2. linux下如何为刚安装好的Eclipse在桌面建
  3. Android ActionBar And Menu
  4. Android IntentService 与Alarm开启任务
  5. android intent activity参数传递
  6. xp jdk7环境下利用webView调用网页androi
  7. Android:Calling startActivity() from o
  8. 编写使用root权限的android应用程序
  9. [Android]长按电源键(Power Key)的处理
  10. [Linphone Android] 带视频的呼叫