开发者

Controlling the "minOccurs", "maxOccurs" and "use" attributes in a type definition in the WSDL generated for an ASP.NET Web Service?

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 Serializatio开发者_如何学Cn (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"
}


Sorry, there is no way to do this.


Try this for the minOccurs

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜