У меня есть XSD:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://a.com/a.xsd"
targetNamespace="http://a.com/a.xsd"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xs:element name="A">
<xs:complexType>
<xs:sequence>
<xs:element name="Item" minOccurs="1" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:whiteSpace value="collapse"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
который я преобразовал в класс C # с помощью XSD.exe v2.0.50727.3615, который генерирует следующий код
namespace A {
using System.Xml.Serialization;
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.42")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="http://a.com/a.xsd")]
[System.Xml.Serialization.XmlRootAttribute(Namespace="http://a.com/a.xsd", IsNullable=false)]
public partial class A {
private string itemField;
/// <remarks/>
public string Item {
get {
return this.itemField;
}
set {
this.itemField = value;
}
}
}
}
Я возвращаю объект AA в моем webservice, который создает этот фрагмент в описании службы
<s:schema elementFormDefault="qualified" targetNamespace="http://a.com/a.xsd">
<s:element name="Test2Result">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="Item" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
</s:schema>
. Изменение minOccrus = "1" в XSD на minOccurs = "0" в автоматически сгенерированном WSDL вызывает проблемы с машиной на другом конце системы.
Я, конечно, мог бы предоставить им WSDL, отредактированный вручную, но я бы хотел, чтобы автоматически созданный WSDL соответствовал их потребностям.
Любые предложения, как убедить dotnet выводить minOccurs = "1" для строковый тип в автоматически созданных WSDL без добавления nillable = "true "?