none
WCF service and subset class inerithed from Service Reference class. RRS feed

  • Question

  • Hello,

    I'm using a "Service Reference" in my WCF which has created the properly class in Reference.cs file. I have defined a sub class inheriting from this "reference" class for using a subset object who receive data from REST and reserialize it automatically.

    The "proxy" class has been configured as follow but the problem is when I run the REST request the deserialization fails because it looking for some base properties I don't need, because I just want to use the sub class properties. I ‘have tried some stuff like [IgnoreDatamember] and / or don't set [DataMember] for the subclass attributes, but always it looking for base properties.

    I've read I should to define [KnownType(typeof(ProxyInternalToolOrder))] into base class but it's a reference class (wsdl), so it will be updated anytime and seems doesn't work. So I'm asking you which is the best approach for creating this "proxy" class?

    Tks.

        [DataContract]
        public class ProxyInternalToolOrder : CreateRequestTypeInternalToolOrder

        {
            [DataMember]
            public  string manufacturingCompany; 
            [DataMember]
            public  string toolCompany { get; set; }
            [DataMember]
            public  string deliveryDate { get; set; }
            [DataMember]
            public  long delay { get; set; }
            ...

         

    Wednesday, April 4, 2018 8:29 PM

All replies

  • Hi mameli,

    >>I have defined a sub class inheriting from this "reference" class for using a subset object who receive data from REST and reserialize it automatically.

    What do you mean by this?

    For subset object, is it an inherited class from WCF generated client code? How will it receive data from Rest? Did you use this inherited class to call WCF Service?

    >>when I run the REST request the deserialization fails because it looking for some base properties

    How did you run this Rest request? For generated client code, it is usually used in SOAP Service instead of Rest Service.

    >>I've read I should to define [KnownType(typeof(ProxyInternalToolOrder))] into base class but it's a reference class (wsdl),

    If you try to add [KnownType(typeof(ProxyInternalToolOrder))] to base class, will it work?

    Best Regards,

    Tao Zhou


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, April 5, 2018 1:55 AM