mohammed  jaseefar

mohammed jaseefar

  • NA
  • 217
  • 20.4k

Wcf messagecontract and messagebodymember

Jan 16 2018 12:01 AM
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.
  1. [MessageContract(IsWrapped = true, WrapperName = "CityRequestObject")]  
  2. public class CityInfoRequest  
  3. {  
  4. [MessageHeader]  
  5. public string UserKey { getset; }  
  6. [MessageHeader]  
  7. public string TransactionID { getset; }  
  8. [MessageHeader]  
  9. public string EntityCode { getset; }  
  10. [MessageBodyMember]  
  11. [System.Xml.Serialization.XmlElementAttribute(IsNullable = true, Form = System.Xml.Schema.XmlSchemaForm.Qualified, Order = 0)]  
  12. public string Lang { getset; } }  

Answers (1)