Android利用ksoap传递复杂对象参数
2012-12-19 14:27:32 来源:WEB开发网核心提示:writer.endTag(dataContract, "Age");writer.startTag(dataContract, "Name");writer.text(user.getName());writer.endTag(dataContract, "Name&
writer.endTag(dataContract, "Age");
writer.startTag(dataContract, "Name");
writer.text(user.getName());
writer.endTag(dataContract, "Name");
}
writer.startTag(dataContract, "Name");
writer.text(user.getName());
writer.endTag(dataContract, "Name");
}
}
3 调用wcf,并定义complex type的内容如下:
SoapObject request = new SoapObject(serviceNameSpace, methodName);
User user = new User();
user.setAge(10);
user.setName("corning");
PropertyInfo pi = new PropertyInfo();
pi.setName("user");
pi.setValue(user);
pi.setType(user.getClass());
request.addProperty(pi);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.bodyOut = request;
envelope.implicitTypes = true;
envelope.addMapping(serviceNameSpace, User.UserClass.getSimpleName(), User.UserClass);
MarshalUser userMarshal = new MarshalUser();
userMarshal.register(envelope);
// Android传输对象
HttpTransportSE transport = new HttpTransportSE(serviceURL);
transport.debug = true;
更多精彩
赞助商链接