【发布时间】:2012-09-24 05:30:32
【问题描述】:
我正在将 xml 数据的单个帖子从 android 应用程序 (java) 发送到 .net 4 WCF Web 服务。 xml创建如下
xmlBuilder.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
xmlBuilder.append("<LogDeviceCommunication
xmlns=\"http://schemas.datacontract.org/2004/07/conxEntities\">");
xmlBuilder.append("<DeviceID>").append(DeviceID).append("</DeviceID>");
xmlBuilder.append("<ID>").append(ID).append("</ID>");
xmlBuilder.append("<Info>").append(Info).append("</Info>");
xmlBuilder.append("<Line>").append(Line).append("</Line>");
xmlBuilder.append("<Tab>").append(Tab).append("</Tab>");
xmlBuilder.append("<Time>").append(new DateTime(Time).toDateTimeISO()).append
("</Time>");
xmlBuilder.append("</LogDeviceCommunication>");
WCF方法如下
[OperationContract]
[WebInvoke(UriTemplate = "AddDeviceCommunicationLog", RequestFormat =
WebMessageFormat.Xml, BodyStyle = WebMessageBodyStyle.Bare, Method = "POST")]
string AddDeviceCommunicationLog(LogDeviceCommunication deviceCommunicationEntry);
我想更改为发送 LogDeviceCommunication 列表以加快速度,但不确定将什么用作父元素,即
<parent element>
<logdevicecommunication>...</logdevicecommunication>
<logdevicecommunication>...</logdevicecommunication>
<logdevicecommunication>...</logdevicecommunication>
</parent element>
对 WCF 的调用通常会返回一个 List 作为 ArrayOf.... 但发布时自然不存在这种类型。 我需要创建消息合同或类似的吗?
谢谢
【问题讨论】: