Can’t Deserialize xml using DataContractSerializer

Body and SPRemoteEventProperties need to be in the "" namespace:

[DataContract(Name = "Body", Namespace = "")]
public class Body
    [DataMember(Name = "ProcessOneWayEvent")]
    public ProcessOneWayEvent ProcessOneWayEvent;

[DataContract(Name = "properties", Namespace = "")]
public class SPRemoteEventProperties
    [DataMember(Name = "CultureLCID") ]
    public int CultureLCID { get; set; }

The DataContractAttribute.Namespace controls the namespace that the data contract object’s data member elements are serialized to, as well as the namespace of the root element when the data contract object is the root element. Since the element <ProcessOneWayEvent xmlns=""> declares a new default XML namespace, the element itself, as well as its children, are in this namespace. Thus, the containing data contract object Body must set its data member namespace accordingly. As for <properties xmlns:i="">, the i: namespace is not a default namespace, so no elements actually get assigned to this namespace and the SPRemoteEventProperties type should not not assign itself to it.

Fixed fiddle here.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top