数组,而不是名单WCF服务代理使用svcutil.exe的生成

数组,而不是名单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;