WCF REST:删除前缀"ArrayOf"用于wcf方法响应 [英] WCF REST: remove prefix "ArrayOf" for wcf method response
本文介绍了WCF REST:删除前缀"ArrayOf"用于wcf方法响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的wcf rest服务中的一种方法:
Here is one of the methods from my wcf rest service:
[OperationContract]
[WebInvoke(UriTemplate = "getInvoices", Method = "POST", RequestFormat = WebMessageFormat.Xml, ResponseFormat = WebMessageFormat.Xml)]
List<InvoiceRet> GetInvoices(GetInvoices getInvoices);
它以以下格式返回响应:
And it returns response in the next format:
<ArrayOfInvoiceRet>
<InvoiceRet></InvoiceRet>
<InvoiceRet></InvoiceRet>
...
<InvoiceRet></InvoiceRet>
</ArrayOfInvoiceRet>
如何修改方法以返回下一个响应
How to modify method to return the next response
<ListInvoice>
<InvoiceRet></InvoiceRet>
<InvoiceRet></InvoiceRet>
...
<InvoiceRet></InvoiceRet>
</ListInvoice>
推荐答案
您将需要实现从List<InvoiceRet>
派生的自定义集合并将其标记为CollectionDataContractAttribute
:
You will need to implement custom collection derived from List<InvoiceRet>
and mark it with CollectionDataContractAttribute
:
[CollectionDataContract]
public class ListInvoice : List<InvoiceRet>
{ }
将此集合用作操作的返回类型. 此处是在数据合同中使用集合的完整说明.
Use this collection as return type from your operation. Here is full description of using collections in data contracts.
这篇关于WCF REST:删除前缀"ArrayOf"用于wcf方法响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文