从WCF服务生成的WSDL声明可为空,但应将其要求

时间:2019-05-03 12:17:06

标签: wcf xsd wsdl

我有一个使用类的WCF服务,该类已正确标注为DataContract。在该数据协定(结构类型)中,我定义了 Prefix属性

[DataContract(Name = "myIdentifier")]
[Serializable]
public struct MyIdentifierExtern {
    /// <summary>Gets or sets the identifier.</summary>
    /// <value>The identifier.</value>
    [DataMember(Name = "id", IsRequired = true, EmitDefaultValue = true, Order = 2)]
    [XmlElement(ElementName = "id", IsNullable = false, Order = 2)]
    public int Id { get; set; }

    /// <summary>Gets or sets the prefix.</summary>
    /// <value>The prefix.</value>
    [DataMember(Name = "prefix", IsRequired = true, EmitDefaultValue = true, Order = 1)]
    [XmlElement(ElementName = "prefix", IsNullable = false, Order = 1)]
    [MaxLength(1)]
    [MinLength(1)]
    public string Prefix { get; set; }
...    

但是,收到的WSDL(通过使用“ .... svc?singleWsdl”查询访问其配置的URL的服务)返回:

<xs:complexType name="myIdentifier">
  <xs:annotation>
    <xs:appinfo>
      <IsValueType xmlns="http://schemas.microsoft.com/2003/10/Serialization/">true</IsValueType>
    </xs:appinfo>
  </xs:annotation>
  <xs:sequence>
    <xs:element name="prefix" nillable="true" type="xs:string"/>
    <xs:element name="id" type="xs:int"/>
  </xs:sequence>
</xs:complexType>

为什么前缀被广告为可广告?

0 个答案:

没有答案