So I’ve been using this code to automatically serialize my “User” business object which has been working great.
[WebMethod]
public MyUser GetUserFromCard(string code, string cardNumber)
{
var repo = new MyRepositry(cinemaCode);
string parameters = string.Empty;
parameters = MyRepositry.MakeParameter("CardNumber", cardNumber);
return repo.FindMember(parameters);
}
which is returning this xml
<MyUser>
<BirthDate>1982-04-13T00:00:00</BirthDate>
<Address>market st</Address>
<Suburb>sydney</Suburb>
<State>NSW</State>
<Postcode>2000</Postcode>
<UserName>test user</UserName>
<Password>passw0rd</Password>
<FirstName>test</FirstName>
<LastName>user</LastName>
<Email>test@land.com.au</Email>
<ReceiveEmail>true</ReceiveEmail>
<CardNumber>454543523443</CardNumber>
<Points>10</Points>
<Rewards>
<Reward/>
<Reward/>
</Rewards>
</MyUser>
My Problem is that the rewards array is returning the correct number of elements but they are empty. Both the MyUser and Reward classes have absolutly no annotations or other methods to perform custom serialization.
Any Ideas?
Can you show the
Rewardclass? In particular, for use withXmlSerializerit must have a public parameterless constructor, and all* the properties must be public with both getters and setters; so the following would behave like you’ve described:but this would work:
*=with some minor caveats.