【发布时间】:2021-11-08 10:29:51
【问题描述】:
我正在使用此 ONVIF 服务:https://www.onvif.org/ver10/media/wsdl/media.wsdl 使用 Visual Studio 2019,它会自动从 WSDL 文件生成客户端包装器。
我不知道如何使用 OSDTextConfiguration 的“扩展”元素向 OSDTextConfiguration 添加未在 WSDL 中指定的元素。
<xs:complexType name="OSDTextConfiguration">
...
<xs:element name="Extension" type="tt:OSDTextConfigurationExtension" minOccurs="0"/>
</xs:complexType>
<xs:complexType name="OSDTextConfigurationExtension">
<xs:sequence>
<xs:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> <!-- first Vendor then ONVIF -->
</xs:sequence>
<xs:anyAttribute processContents="lax"/>
</xs:complexType>
这是定义类型的完整文件: https://www.onvif.org/ver10/schema/onvif.xsd?ccc393&ccc393
Visual Studio 定义了下面的代码,我想我应该可以使用 XmlAnyElementAttribute() 添加我的元素,但我不知道该怎么做。谁能指出我正确的方向?
public partial class OSDConfigurationExtension : object, System.ComponentModel.INotifyPropertyChanged {
private System.Xml.XmlElement[] anyField;
private System.Xml.XmlAttribute[] anyAttrField;
/// <remarks/>
[System.Xml.Serialization.XmlAnyElementAttribute(Order=0)]
public System.Xml.XmlElement[] Any {
get {
return this.anyField;
}
set {
this.anyField = value;
this.RaisePropertyChanged("Any");
}
}
/// <remarks/>
[System.Xml.Serialization.XmlAnyAttributeAttribute()]
public System.Xml.XmlAttribute[] AnyAttr {
get {
return this.anyAttrField;
}
set {
this.anyAttrField = value;
this.RaisePropertyChanged("AnyAttr");
}
}
【问题讨论】:
标签: c# visual-studio wsdl onvif