android kvmserializable自定义数组,用Java 在 KSOAP中序列化复杂对象数组实体

b7fc7ec0e4687f382ba3288d1a445b5a.png

public static final String NAMESPACE ="http://tempuri.org/";

private static final String URLCatalog ="http://192.168.1.123:8002/AssetServer/CatalogService.asmx";

private static final String URLCount ="http://192.168.1.123:8002/AssetServer/AccountService.asmx";

private static final String URLFile ="http://192.168.1.123:8002/AssetServer/FileService.asmx";

private static final String URLQuery ="http://192.168.1.123:8002/AssetServer/QueryService.asmx";

private static final String URLWork ="http://192.168.1.123:8002//AssetServer/WorkFlowService.asmx";

SoapSerializationEnvelope envelope =new SoapSerializationEnvelope(

SoapEnvelope.VER11);

具体的方法如下:

public void fillTable(String id) {

String method = "fillTableByID";

SQueEnt sqe = new SQueEnt("磁带编号,并列正题名", "后台测试", "nvarchar(50)");

ArrayOfSQueEnt sci = new ArrayOfSQueEnt();

sci.add(sqe);

sci.add(sqe);

SoapObject request = new SoapObject(NAMESPACE, method);

PropertyInfo tabProp1 = new PropertyInfo();

tabProp1.setName("sqecol");

tabProp1.setValue(sci);

tabProp1.setType(ArrayOfSQueEnt.class);

request.addProperty(tabProp1);

// String id="179d570d-5da3-40ac-a7ba-e72c02c38b4c";

// request.addProperty("sqecol",array);

String type = getFiletype(id);

request.addProperty("xbType", type);

request.addProperty("Fileid", id);

//System.out.println(type +"  :" + id);

envelope.addMapping(NAMESPACE, "sqecol",

new ArrayOfSQueEnt().getClass());

envelope.addMapping(NAMESPACE, "SQueEnt", new SQueEnt().getClass());

envelope.bodyOut = request;

envelope.dotNet = true;

envelope.setOutputSoapObject(request);

envelope.encodingStyle = "UTF-8";

HttpTransportSE androidHttpTransport = new HttpTransportSE(URLQuery);

androidHttpTransport.debug = true;

try {

androidHttpTransport.call(NAMESPACE + method, envelope);

if (envelope.bodyIn != null) {

Object resultObj = (Object) envelope.bodyIn;

System.out.println(envelope.bodyIn.toString());

} else {

System.out.println("WebServicefillTable()没有获取到数据!");

}

} catch (IOException e) {

System.out.println(e);

e.printStackTrace();

} catch (XmlPullParserException e) {

System.out.println(e);

e.printStackTrace();

}

}

b7fc7ec0e4687f382ba3288d1a445b5a.png

参考:

https://code.google.com/p/ksoap2-android/wiki/CodingTipsAndTricks#Manual_Parsing_of_an_Array_of_into_an_POJO_array

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值