There seems to be a known bug in wsdl.exe, a tool that Visual Studio uses to create web service proxies. Using some XSD schemas, the tool will generate classes that cannot be deserialized from XML.
As far as I understand, this is unacceptable, but I do not know how to fix it.
I will tell you in detail about my case, I hope someone can help me.
Scheme
<xs:complexType name="listAssetsQueryResults">
<xs:sequence>
<xs:element name="assets" type="tns:asset" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="asset">
<xs:sequence>
<xs:element name="attributes" type="tns:multiValuedAttribute" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="multiValuedAttribute">
</xs:complexType>
Web service XML response
A typical answer according to this scheme is as follows:
<assets-query-result>
<assets>
<attributes>
<name>Keywords</name>
<values>Desert</values>
</attributes>
<attributes>
<name>Filename</name>
<values>Desert.jpg</values>
</attributes>
</assets>
<assets>...</assets>
<assets>...</assets>
</assets-query-result>
Using types in code
I expected that I could use CLR types as follows:
result.assets[0].attributes[0].name
Instead, the generated type for the result is as follows:
[SerializableAttribute()]
public partial class listAssetsQueryResults {
private multiValuedAttribute[][] assetsField;
[XmlArrayAttribute(Form=XmlSchemaForm.Unqualified, IsNullable=true)]
[XmlArrayItemAttribute("attributes", typeof(multiValuedAttribute), Form=XmlSchemaForm.Unqualified)]
public multiValuedAttribute[][] assets {
get { return this.assetsField; }
set { this.assetsField = value; }
}
}
This does not even allow the serialization assembly to be generated!
Portfolio.WebService.multiValuedAttribute .WebService.multiValuedAttribute []
1 -
, , - :
public multiValuedAttribute[] assets;
, , , , "" assets. , . 700 + result.assets multiValuedAttribute[2] (2 - ).
2 - XML-
, , - :
[XmlArrayItemAttribute("attributes", typeof(multiValuedAttribute[]), Form=XmlSchemaForm.Unqualified)]
public multiValuedAttribute[][] assets { ... }
, , multiValuedAttribute[]. , attributes, multiValuedAttribute (, ). , result.assets multiValuedAttribute[2][0], .
?
, . , .NET -, .