Windows Vista Forums

How to expose a class property using WCF?
  1. #1


    jmw Guest

    How to expose a class property using WCF?

    I have been struggling with this for several days and found no answers in all
    the online searches that I have done.



    Given a Class X, that has a public MethodA and a public PropertyB (readonly,
    i.e. just a get), how do I decorate the class with [ServiceContract],
    [MethodContract], [DataContract], and [DataMember] so that the property will
    show up in the wsdl?

    I have had no problems getting the MethodA to be exposed, but have yet to
    find a way to get the PropertyB to be exposed. I haven't found any examples
    that seem to have both methods and properties in the same class. Is this not
    allowed with WCF?

    I am using VS2008 and C#.


      My System SpecsSystem Spec

  2. #2


    John Saunders [MVP] Guest

    Re: How to expose a class property using WCF?

    "jmw" <jmw@xxxxxx> wrote in message
    news:CFF7DF93-7E3E-4695-8321-C887846B6E12@xxxxxx

    >I have been struggling with this for several days and found no answers in
    >all
    > the online searches that I have done.
    >
    > Given a Class X, that has a public MethodA and a public PropertyB
    > (readonly,
    > i.e. just a get), how do I decorate the class with [ServiceContract],
    > [MethodContract], [DataContract], and [DataMember] so that the property
    > will
    > show up in the wsdl?
    >
    > I have had no problems getting the MethodA to be exposed, but have yet to
    > find a way to get the PropertyB to be exposed. I haven't found any
    > examples
    > that seem to have both methods and properties in the same class. Is this
    > not
    > allowed with WCF?
    Service contracts and data contracts are totally separate things. You should
    not combine them.
    --
    --------------------------------------------------------------------------------
    John Saunders | MVP - Windows Server System - Connected System Developer


      My System SpecsSystem Spec

How to expose a class property using WCF? problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
Private Property, The Commons, & The War on the Middle Class pooch Chillout Room 0 22 Mar 2009
Set Focus To Specific Property In Property Grid Derek Hart .NET General 10 06 Oct 2008
Use my custom TypeDescriptor to obtains default Value on property inXAML Property Editor of Visual Studio 2008 azerty Avalon 0 14 Apr 2008
Does the dependency property inheritance mechanism only work between class and subclasses ? Pon Avalon 2 03 Dec 2006
Custom Dependency Property in custom class hierarchy not workingcorrectly?! MueMeister Avalon 0 02 Mar 2006