我试图消耗它具有以下XSD包含具有单字节序列属性的complexType服务,Bug?
<xs:simpleType name="SimpleByteType"> <xs:restriction base="xs:unsignedByte"/> </xs:simpleType> <xs:complexType name="ArrayOfBytes"> <xs:sequence> <xs:element name="SimpleByteType-item" type="tns:SimpleByteType" /> </xs:sequence> </xs:complexType>
<xs:element name="ArrayOfBytes" nillable="true" type="tns:ArrayOfBytes"/>
当我从这项服务中,我得到了下面的错误请求数据服务(内置和Java的托管)使用WCF:
"Base64 sequence length (1) not valid. Must be a multiple of 4."
这是奇怪的是返回的XML是这样的:
<ArrayOfBytes>
<SimpleByteType-item>0</SimpleByteType-item>
<SimpleByteType-item>1</SimpleByteType-item>
<SimpleByteType-item>2</SimpleByteType-item>
</ArrayOfBytes>
所以,它根本不是Base64编码的。显然,dotnet会消耗这个xsd,并使其成为一个byte [],它应该包含导致错误的base64编码数据。
我在这里做错了什么,或者这是WCF解释XSD的方式的错误?对于使用Base64编码数据的正确识别将是base64Binary类型看:http://www.w3.org/2002/ws/databinding/examples/6/09/Base64BinaryElement/
这使我觉得这是一个错误的另一件事是改变从
<xs:restriction base="xs:unsignedByte"/>
的XSD(在它的限制),以
<xs:restriction base="unsignedInt"/>
解决了这个问题。这显然应该与base64编码的内容无关。
就我所见,您所引用的关注点是一个应该有单个值的字段(base64 encode byte [],其中各个字节一起构成一个值)。然而,问题出在一个复杂类型的元素中,这是一个单字节值的序列。第一个,只能是一个字节[]作为.Net中的字段,而后者可以是列表以及它只是一些字节值,它们之间没有任何关系。 –
thekip
2014-12-15 19:49:06