I have a WCF Service with a "POST" method that takes in XML and turns it into an object, the problem is only some of the fields are being loaded.
Object Sample:
[DataMember, XmlElement(IsNullable = false, Type = typeof(String))]
public String ClaimKey
{
get;
set;
}
[DataMember, XmlElement(IsNullable = false, Type = typeof(String))]
public String VehicleRegistrationNo
{
get;
set;
}
Input Sample
[WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Xml, RequestFormat = WebMessageFormat.Xml, BodyStyle = WebMessageBodyStyle.Bare)]
public SalvageInstructionResponse Test(SalvageInstructionRequestHeader Item)
{
this._objOutput = new SalvageInstructionResponse(SalvageInstructionResponseStatus.FAILURE, "Test", Item.ToString());
return this._objOutput;
}
XML Sample:
<ClaimKey>str1234</ClaimKey>
<VehicleRegistrationNo>str1234</VehicleRegistrationNo>
So using the above sample only "VehicleRegistrationNo" is loading but the ClaimKey is null.
The XML and the class are bigger but it's loading about 40% of the properties.
When transferring the object between the server end and the client, you should ensure that the DataContract is consistent.
IExtensibleDataObject interface is a good choice for maintain the consistency. Both DataMember and IsRequired property have an impact on this issue.
https://learn.microsoft.com/en-us/dotnet/framework/wcf/feature-details/data-contract-versioning
In addition, Data contract Serializer is constrained of the MaxItemInObjectGraph property. Refer to the following code.
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpsGetEnabled="true" httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</serviceBehaviors>
Feel free to contact me if there is anything I can help with.