Circular References - Serializer/Deserializer

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mehdi

    Circular References - Serializer/Deserializer

    Hi folks,
    I've been lately trying to expose an object graph (with circular
    references) through a web method, however, this was not possible since
    the XmlSerializer has got no idea how to address the issue. Therefore,
    I've just changed the WebServiceBindi ngAttribute from

    [WebServiceBindi ng(ConformsTo = WsiProfiles.Bas icProfile1_1)]
    to
    [WebServiceBindi ng(ConformsTo = WsiProfiles.Non e)]

    and added the SoapDocumentMet hodAttribute to the web methods as
    follows:

    [SoapDocumentMet hod(Use=SoapBin dingUse.Encoded )]

    The circular reference is solved auto-magically, however, the following
    problem is introduced. Consider a class (MyEntity) that has got some
    properties, say Prop1, Prop2 and Prop3 all of boolean type. On the
    service side, consider this:

    [WebMethod()]
    [SoapDocumentMet hod(Use=SoapBin dingUse.Encoded )]
    public MyEntity GetMyEntity()
    {
    MyEntity entity = new MyEntity();
    entity.Prop1 = false;
    entity.Prop2 = false;
    entity.Prop3 = false;
    return entity;
    }

    When the entity is marshaled to the client, the Prop2 value is true,
    while it's being set to false!!!! What the heck is going wrong with
    this? What happens when the type is serialized/deserialized??? Needless
    to say that I've just simplified the MyEntity class to show you the
    idea.

    Any help would be highly appreciated,

    Cheers,
    Mehdi

Working...