2016-04-13 2 views
1

Dieses Programm funktioniert gut mit einfachen Enum. Aber wenn ich eine Sammlung von Enum haben möchte, gibt es einen WCF-Fehler, wenn ich es starte.WCF Fehler mit Enum-Sammlung

[OperationContract] 
    [FaultContract(typeof(ErrorData))] 
    [WebInvoke(Method = "GET", 
     RequestFormat = WebMessageFormat.Json, 
     ResponseFormat = WebMessageFormat.Json, 
     UriTemplate = "TestEnum?productRetrieveOptions={productRetrieveOptions}")] 
    string TestEnum(ICollection<DTO.ProductRetrieveOption> productRetrieveOptions); 



    public string TestEnum(ICollection<DTO.ProductRetrieveOption> productRetrieveOptions) 
    { 
     return string.Format("OK ({0})", productRetrieveOptions); 
    } 



[DataContract] 
public enum ProductRetrieveOption : int 
{ 
    [System.Runtime.Serialization.EnumMemberAttribute()] 
    //[EnumMember] 
    Stock = 0, 

    [System.Runtime.Serialization.EnumMemberAttribute()] 
    //[EnumMember] 
    RightAssociated = 1, 

    [System.Runtime.Serialization.EnumMemberAttribute()] 
    //[EnumMember] 
    ValidityDate = 2, 

    [System.Runtime.Serialization.EnumMemberAttribute()] 
    //[EnumMember] 
    FullTariff = 3, 
} 

Der Fehler ist:

Operation 'TestEnum' Vertrag Isale hat eine Anfrage Variable mit dem Namen 'productRetrieveOptions' Typ 'System.Collections.Generic.ICollection 1 [DTO.ProductRetrieveOption] ', but the type' System.Collections.Generic.ICollection 1 [DTO.ProductRetrieveOption]' ist nicht konvertierbar mit 'QueryStringConverter'. Die Variablen für UriTemplate-Abfragewerte müssen über Typen verfügen, die von 'QueryStringConverter' konvertiert werden können.

Ich versuchte mit IList, [], IEnumarable und ICollection, und ich habe immer die gleiche Art von Fehler.

Danke für Ihre Hilfe

Antwort

0

Finaly es war recht einfach Fehler

[OperationContract] 
    [FaultContract(typeof(ErrorData))] 
    [WebInvoke(Method = "POST", 
     RequestFormat = WebMessageFormat.Json, 
     ResponseFormat = WebMessageFormat.Json, 
     UriTemplate = "TestEnum")] 
    string TestEnum(ICollection<DTO.ProductRetrieveOption> productRetrieveOptions);