1

Magento V2 APIを拡張したため、wsdl.xmlを作成しました。私のWebサービスは連想マルチ配列を返します。私は少しグーグルして、複雑なタイプの2つの定義を見つけました:

<complexType name="associativeMultiArray">
    <all>
        <element name="associativeArray" type="typens:associativeArray" minOccurs="0" />
    </all>
</complexType>
<complexType name="stringArray">
    <all>
        <element name="multi_data" type="typens:associativeMultiArray" minOccurs="0" />
    </all>
</complexType>

<message name="methodResponse">
    <part name="result" type="typens:stringArray" />
</message>

別のもの:

<complexType name="associativeMultiArray">
    <complexContent>
        <restriction base="soapenc:Array">
            <attribute ref="soapenc:arrayType" wsdl:arrayType="typens:associativeMultiEntity[]"/>
        </restriction>
    </complexContent>
</complexType>

<complexType name="associativeMultiEntity">
    <all>
        <element name="key" type="xsd:string"/>
        <element name="value" type="typens:ArrayOfString"/>
    </all>
</complexType>

<complexType name="ArrayOfString">
    <complexContent>
        <restriction base="soapenc:Array">
            <attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:string[]"/>
        </restriction>
    </complexContent>
</complexType>

<message name="methodResponse">
    <part name="result" type="typens:associativeMultiArray" />
</message>

問題は、これら2つの機能のいずれも機能しないことです。クエリの後に結果を出力すると、次のようになります。

Array
(
    [0] => stdClass Object
    (
    )
)

array('test)戻るかどうかは関係ありませんarray('key'=>'value')。常に同じ出力です。基本的に私は2つの質問があります:

  • ArrayOfStringassociativeArrayおよび次associativeMultiArrayの宣言:?<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:Magento"> <import namespace="http://schemas.xmlsoap.org/soap/encoding/" schemaLocation="http://schemas.xmlsoap.org/soap/encoding/"/>
  • 10次​​元の連想配列のような非常に複雑な配列構造がある場合、wsdl.xmlですべての次元を宣言する必要がありますか?これをどのように処理しますか?それはどのように機能しますか?上記の宣言が機能しないのはなぜですか?
4

1 に答える 1

2

これは質問に対する正確な解決策ではありませんが、これを解決する別の方法を見つけました。配列を JSON としてシリアル化し、json_encodeでデコードするだけjson_decodeです。これにより、配列を複雑にすることができます。Returntype はxsd:stringwsdl にあります。

于 2013-03-06T16:55:14.580 に答える