我的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. Android(安卓)NDK 教程 - NDK环境配置和 Android(安卓)Studio 中
  2. Android(安卓)中Preferences的使用!
  3. Android(安卓)中的网络操作(HttpURLConnection)
  4. Android高手进阶教程(十七)之---Android中Intent传递对象的两种
  5. 【Android】Android中Intent的用法总结
  6. Android如何通过https协议下载自己的https网站上的文件/apk等
  7. Android(安卓)启动另外activity并返回结果
  8. Android(安卓)各大网络请求库的比较及实战
  9. JOIM:Android通过IPCamera通过互联网实时监控功能的实现

随机推荐

  1. android实用小工具
  2. android一些坑与小技巧
  3. android:shape的使用
  4. Android内部存储和外部存储的获取方法
  5. ubuntu配置Android(安卓)sdk
  6. eclipse 开发android 配置
  7. Android图片下载缓存库picasso解析
  8. [2010-07-18]android the mobile linux U
  9. android 完美退出所有Activity的demo
  10. android 中的getCacheDir()、getFilesDir