数组,而不是名单WCF服务代理使用svcutil.exe的生成 [英] Array instead of List in WCF Service Proxy Generated using svcutil.exe

查看:239
本文介绍了数组,而不是名单WCF服务代理使用svcutil.exe的生成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个的ServiceContract

using System.Collections.Generic;
using System.ServiceModel;
namespace MainModule.Sub.Communication
{
    [ServiceContract]
    public interface IWebMethod
    {
        [OperationContract(IsOneWay = false)]
        bool InvokeAlert(List<int> userIds);

        [OperationContract(IsOneWay = false, Name = "InvokeAlertByMainID")]
        bool InvokeAlert(List<int> userIds, int mainId);

        [OperationContract(IsOneWay = true)]
        void DeletePopupNotifications(System.Data.DataSet deletedNotifications);
    }
}

我用下面的命令生成代理(我要做到这一点使用命令行通过不添加服务引用

SvcUtil.exe http://localhost/MainCommunicationServer/wm  /ct:System.Collections.Generic.List`1 /out:HTTPRouterServerProxy.cs 

即使我增加了克拉开关(collectionType)的代理生​​成它作为阵列( INT [] ) 。我怎么能做到这一点,而无需使用添加服务引用窗口,在VS

Even I added the ct switch (collectionType) the proxy is Generating it as Array (int[]). How can I do that without using Add Service Reference window in VS

推荐答案

如果我没有记错,在/ CT开关可能没有任何影响(在某些情况下?)。尝试使用包装DataContract类型,例如布尔InvokeAlert(InvokeAlertRequest R); ,其中 InvokeAlertRequest 将是 [DataContract] 包含一个 [数据成员]列表与LT型; INT&GT;用户id;

If I remember correctly, the /ct switch may not have any effect (in some circumstances?) on OperationContract-level collections. Try using a wrapper DataContract type, e.g. bool InvokeAlert(InvokeAlertRequest r); where InvokeAlertRequest will be a [DataContract] type containing one [DataMember] List<int> userIds;

这篇关于数组,而不是名单WCF服务代理使用svcutil.exe的生成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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