如何使DOTNET Web服务设置的minOccurs =" 1"在一个字符串值 [英] How to make a dotnet webservice set minOccurs="1" on a string value
问题描述
我有一个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>
这是我转换成使用XSD.EXE v2.0.50727.3615产生code如下C#类
Which I have converted into a C# class using XSD.exe v2.0.50727.3615 which generates code as follows
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;
}
}
}
}
我在我的web服务,产生此片段在服务描述返回一个AA对象
I am returning an A.A object in my webservice, which produces this snippet in the service description
<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是对系统的另一端造成悲痛的机器。
The change from minOccrus="1" in the XSD to minOccurs="0" on the auto-generated WSDL is causing grief to the machine on the other end of the system.
我当然可以提供手动编辑WSDL他们使用,但我想自动生成一个适合他们的需求。
I could of course provide a hand edited WSDL for them to use, but I would like the auto-generated one to suit their needs.
不还增加了关于如何说服的dotnet输出的minOccurs =1在其自动生成WSDL中字符串类型的任何建议的nillable =真?
Any suggestions on how to convince dotnet to output minOccurs="1" for a string type in its autogenerated WSDLs without also adding nillable="true"?
推荐答案
我注意到以下行:
有关结合XML架构复杂类型与非XML特定的类,.NET框架不提供相当于的minOccurs或maxOccurs属性的直接编程语言。
For binding XML Schema complex types with non-XML-specific classes, the .NET Framework does not provide a direct programming language equivalent to the minOccurs or maxOccurs attribute.
从这里开始:的http:// MSDN .microsoft.com / EN-US /库/ zds0b35c(V = vs.85)的.aspx
这篇关于如何使DOTNET Web服务设置的minOccurs =&QUOT; 1&QUOT;在一个字符串值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!