Array instead of List in WCF Service Proxy Generated using svcutil.exe
Asked Answered
G

2

2

I have a 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);
    }
}

I used below command to generate proxy (I have to do this using command-line not via Add Service Reference.

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

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

Guinea answered 31/12, 2012 at 11:53 Comment(1)
Here you have the same question #493876Complicate
C
1

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;

Cragsman answered 1/1, 2013 at 21:47 Comment(0)
V
0

The /ct switch stops working if SvcUtil fails to create a proxy that uses the DataContractSerializer and uses the XmlSerializer instead.

This is just a guess but I suspect that System.Data.DataSet might be causing this.

Velamen answered 2/1, 2013 at 11:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.