控制“minOccurs”、“maxOccurs”和“使用”为 ASP.NET Web 服务生成的 WSDL 中的类型定义中的属性?
有没有办法控制元素定义的 minOccurs
和 maxOccurs
属性,或属性定义的 use
属性,在为 ASP.NET Web 服务生成的 WSDL 中?
我知道可以使用自定义 XML 序列化来做到这一点(即,使每个类实现 IXmlSerialized 并具有 XmlSchemaProviderAttribute 属性),但这将非常耗时,尤其是考虑到此 Web 服务定义了许多类型和操作。
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"
}
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"
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
抱歉,没有办法做到这一点。
Sorry, there is no way to do this.
尝试为 minOccurs
[XmlElementAttribute(IsNullable = true)]
公共 int Field2;
Try this for the minOccurs
[XmlElementAttribute(IsNullable = true)]
public int Field2;