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 WebServiceBindingAttribute from
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
to
[WebServiceBinding(ConformsTo = WsiProfiles.None)]
and added the SoapDocumentMethodAttribute to the web methods as
follows:
[SoapDocumentMethod(Use=SoapBindingUse.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()]
[SoapDocumentMethod(Use=SoapBindingUse.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