locked
Complex Type is getting exposed to client without DataContract RRS feed

  • Question

  • User-1649082595 posted

    Hi All,

    I'm having a problem. I've a WCF service which has complex types defined in it. These complex types are not decorated with DataContract/DataMember attribute. My service returns object/collection of objects of these complex types to client.

    The problem is that these complex types are getting exposed to my client even though those are not defined as DataContract.

    What can be the possible reason behind this? Isn't it the default behavior of WCF that to expose any complex types the same needs to marked as DataContract or Is there any configuration that needs to be done.

    Kindly help.

    Friday, May 3, 2013 3:15 AM

Answers

  • User-742633084 posted

    Hi sayan751,

    Using DataContract attribute(or other related attributes) is recommended way to define custom data types used in WCF Service for data transfer. But it is not mandatory. WCF by default use DataContractSerializer, so types that can be used as operation parameter or return type depends on the serializer support. Here is the MSDN reference talking about the types supported by DataContract serializer:

    #Types Supported by the Data Contract Serializer
    http://msdn.microsoft.com/en-us/library/ms731923.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 10, 2013 1:25 AM

All replies

  • User220959680 posted

    post your source for further help.

    Friday, May 3, 2013 5:55 AM
  • User-742633084 posted

    Hi sayan751,

    Using DataContract attribute(or other related attributes) is recommended way to define custom data types used in WCF Service for data transfer. But it is not mandatory. WCF by default use DataContractSerializer, so types that can be used as operation parameter or return type depends on the serializer support. Here is the MSDN reference talking about the types supported by DataContract serializer:

    #Types Supported by the Data Contract Serializer
    http://msdn.microsoft.com/en-us/library/ms731923.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 10, 2013 1:25 AM