Пример кода в качестве дополнения к предоставленному ответу;
WSDL:
<xs:simpleType name="vehicleType">
<xs:restriction base="xs:string">
<xs:enumeration value="CAR" />
<xs:enumeration value="BUS" />
<xs:enumeration value="BIKE" />
</xs:restriction>
</xs:simpleType>
<xs:complexType name="advancedSearchRequest">
<xs:sequence>
<xs:element minOccurs="0" name="vehicleType" type="tns:vehicleType" />
<xs:element name="search" type="xs:string" />
</xs:sequence>
</xs:complexType>
Сгенерированный клиентский класс .net SOAP
System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.7.3056.0")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="your namespace")]
public partial class advancedSearchRequest : object, System.ComponentModel.INotifyPropertyChanged {
private vehicleType vehicleTypeField;
private bool vehicleTypeFieldSpecified;
private string searchField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=0)]
public vehicleType vehicleType {
get {
return this.vehicleTypeField;
}
set {
this.vehicleTypeField = value;
this.RaisePropertyChanged("vehicleType");
}
}
/// <remarks/>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool vehicleTypeSpecified {
get {
return this.vehicleTypeFieldSpecified;
}
set {
this.vehicleTypeFieldSpecified = value;
this.RaisePropertyChanged("vehicleTypeSpecified");
}
}
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=3)]
public string search {
get {
return this.searchField;
}
set {
this.searchField = value;
this.RaisePropertyChanged("search");
}
}
}
Вы можете установить "vehicleTypeFieldSpecified" = {true / false} на {serialize / omit} it;
advancedSearchRequest.vehicleTypeField = vehicleType.BIKE;
advancedSearchRequest.vehicleTypeFieldSpecified = true;
Результирующее SOAP-сообщение;
<advancedSearchRequests>
<vehicleType>BIKE</vehicleType>
<search>abc</search>
</advancedSearchRequest>