【发布时间】:2015-03-26 14:03:46
【问题描述】:
我正在使用 xsd 生成 OperationContract 中可用的对象。 XSD 的地址、城市、州和 zip 元素很常见
<xs:element name="Address" nillable="true">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="50"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
并在整个 XML 中使用。
<xs:element ref="Address" />
当我编译架构时,类会使用公共元素正确生成。 当我运行服务时,OperationContext 包含来自客户端的预期请求:
<NameLast>Last</NameLast>
<NameFirst>First</NameFirst>
<Address xmlns="http://tempuri.org/">123 2nd St</Address>
<City xmlns="http://tempuri.org/">Somewhere</City>
然而,公共元素具有 xmlns 属性(如上所示),并且在接收到的对象中,所有公共元素都包含空值。
我的声誉不够高,无法显示屏幕截图,但所有不在公共元素中的数据都正确传递。如NameLast = "Last", Address = Null。
我是使用 Schemas 的新手,如果有任何指导,我将不胜感激。谢谢。
【问题讨论】: