如何在 WCF 测试客户端 (WcfTestClient.exe) 中指定列表参数? [英] How to specify list parameters in WCF Test Client (WcfTestClient.exe)?

查看:33
本文介绍了如何在 WCF 测试客户端 (WcfTestClient.exe) 中指定列表参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 WCF 测试客户端 (WcfTestClient.exe) 来测试我的一项 wcf 服务.我有一个消息合同,其中包含一个 DataContracts 列表:我的消息合约如下:

I am using WCF Test Client (WcfTestClient.exe) for testing one of my wcf services. I have a message contract which has a list of DataContracts as : My message contract is as follows :

[MessageContract]
    public class UpdateInvoiceStatusesRequest 
    {
        private List<InvoiceStatusHistory> _invoiceStatusHistory;

        [MessageBodyMember(Order = 0)]
        public List<InvoiceStatusHistory> InvoiceStatusHistory
        {
            get { return _invoiceStatusHistory; }
            set { _invoiceStatusHistory = value; }
        }    
    }

我的数据合同是:

[DataContract]
    public class InvoiceStatusHistory
    {
        private int _invoiceId;
        private int  _status;
        private string _comment;
        private string _timeStamp;

        [DataMember]
        public int InvoiceId
        {
            get { return _invoiceId; }
            set { _invoiceId = value; }
        }

        [DataMember]
        public string Comment
        {
            get { return _comment; }
            set { _comment= value; }
        }

        [DataMember]
        public int Status
        {
            get { return _status; }
            set { _status = value; }
        }

        [DataMember]
        public string TimeStamp
        {
            get { return _timeStamp; }
            set { _timeStamp = value; }
        }
    }

当我使用 WcfTestClient.exe 测试带有 UpdateInvoiceStatusesRequest 消息契约的服务时,它显示 InvoiceStatusHistory 的值为 length = 0,现在我不知道如何我可以在 List 中添加 InvoiceStatusHistory 的对象吗?有没有人对此有任何想法,请帮助我?

when i am using WcfTestClient.exe to test the service with UpdateInvoiceStatusesRequest message contract it shows the value of InvoiceStatusHistory as length = 0, now i don't know how can i add the objects of InvoiceStatusHistory in List<InvoiceStatusHistory> ? Does anyone has any idea about it, please help me?

推荐答案

在框中键入 length=1.+ 符号将出现在请求参数名称旁边.单击它,然后单击 [0] 节点,该节点指示数组中的第一个元素并照常设置其值.

Type length=1 in the box. A + sign will appear next to the request parameter name. Click on it, then on the [0] node which indicates the first element in the array and set its values as usual.

这篇关于如何在 WCF 测试客户端 (WcfTestClient.exe) 中指定列表参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆