我在C#中使用Web引用来与使用SOAP API的Magento进行交互。 WSDL包含许多您可以想象的定义,但我对这个特定的定义有问题:
<complexType name="ArrayOfString">
<complexContent>
<restriction base="soapenc:Array">
<attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:string[]"/>
</restriction>
</complexContent>
</complexType>
作为ArrayOfString的方法的任何属性都以字符串[]的形式返回到我的代码,这很好,但是当它将返回序列化到Magento时,它将它序列化为以下
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="urn:Magento" xmlns:types="urn:Magento/encodedTypes" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<tns:catalogProductCreate>
<sessionId xsi:type="xsd:string">xxxxxxxxxxxxxxxxxxxxxxx</sessionId>
<type xsi:type="xsd:string">simple</type>
<set xsi:type="xsd:string">63</set>
<sku xsi:type="xsd:string">CHRISTEST</sku>
<productData href="#id1" />
</tns:catalogProductCreate>
<tns:catalogProductCreateEntity id="id1" xsi:type="tns:catalogProductCreateEntity">
<categories href="#id2" />
<websites href="#id3" />
<name xsi:type="xsd:string">Chris Test 8</name>
<description xsi:type="xsd:string">fsd</description>
<short_description xsi:type="xsd:string">Chris Test 8</short_description>
<weight xsi:type="xsd:string">0.0000</weight>
<status xsi:type="xsd:string">1</status>
<visibility xsi:type="xsd:string">1</visibility>
<category_ids href="#id4" />
<website_ids href="#id5" />
<price xsi:type="xsd:string">0.00000</price>
<tax_class_id xsi:type="xsd:string">4</tax_class_id>
<tier_price href="#id6" />
</tns:catalogProductCreateEntity>
<soapenc:Array id="id2" soapenc:arrayType="xsd:string[0]" />
<soapenc:Array id="id3" soapenc:arrayType="xsd:string[0]" />
<soapenc:Array id="id4" soapenc:arrayType="xsd:string[1]">
<Item>35</Item>
</soapenc:Array>
<soapenc:Array id="id5" soapenc:arrayType="xsd:string[1]">
<Item>1</Item>
</soapenc:Array>
<soapenc:Array id="id6" soapenc:arrayType="tns:catalogProductTierPriceEntity[0]" />
</soap:Body>
</soap:Envelope>
这导致数组被忽略。我认为ArrayOfString实体没有被添加到我的服务模型的原因是因为它有一个限制,但我需要这个才能将数据恢复到Magento。任何想法的家伙?