2

Is there any way to control the minOccurs and maxOccurs attributes of the definition of an element, or the use attribute of the definition of an attribute, in the WSDL generated for an ASP.NET Web Service?

I know it is possible to do this using custom XML Serialization (i.e., making each class implement IXmlSerializable and have the XmlSchemaProviderAttribute attribute), but this would be very time consuming, especially taking into consideration this Web Service defines many types and operations.

public class TestA
{
    public int Field1;    // minOccurs="1" maxOccurs="1" (good)
    public string Field2; // minOccurs="0" maxOccurs="1" (not good)
                          // I would like minOccurs to be "1" as well
}

public class TestB
{
    [XmlAttribute()] public int Field1;    // use="required" (good)
    [XmlAttribute()] public string Field2; // no use attribute (not good)
                                           // I need use="required"
}
isekaijin
  • 19,076
  • 18
  • 85
  • 153

2 Answers2

3

Sorry, there is no way to do this.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
1

Try this for the minOccurs

[XmlElementAttribute(IsNullable = true)] public int Field2;