Click here to Skip to main content
15,890,282 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I'm looking for a way to specify that some MessageBodyMember is required, so that the generated schema would have minOccurs=1 instead of minOccurs=0.

I know that the DataMember has such an option(IsRequired=true), however I prefer using the MessageContract for controlling other aspects of the message.


What I have tried:

[MessageContract(IsWrapped = true, WrapperName = "CityRequestObject")]
public class CityInfoRequest
{
   
    [MessageHeader]
    public string UserKey { get; set; }
    [MessageHeader]
    public string TransactionID { get; set; }
    [MessageHeader]
    public string EntityCode { get; set; }
    [MessageBodyMember]
    [System.Xml.Serialization.XmlElementAttribute(IsNullable = true, Form = System.Xml.Schema.XmlSchemaForm.Qualified, Order = 0)] 
    public string Lang { get; set; }

}
Posted
Updated 15-Jan-18 17:58pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900