簡體   English   中英

計數+結果數組時的NuSoap Complex類型

[英]NuSoap Complex type when count + array of results

我需要一些幫助來實現php nusoap響應。

這是我的函數返回的內容

Array
(
    [total] => 8177
    [results] => Array
        (
            [0] => Array
                (
                    [id] => 340
                    [name] => Hamburg
                )

            [1] => Array
                (
                    [id] => 344
                    [name] => Fos
                )
         )
)

現在,我需要將此返回為xml。 無論我嘗試了什么(基本上是猜測),我都會明白

<total xsi:type="xsd:int">8177</total>
    <results xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType=":[1000]">
        <item xsi:type="xsd:">
            <id xsi:type="xsd:string">340</id>
            <name xsi:type="xsd:string">Hamburg</name>
        </item>

如您所見, SOAP-ENC:arrayType=":[1000]"> (在:之前為空)也是<item xsi:type="xsd:"> ,我所有的項目都是string / string類型。

到目前為止,我將在這里發布我的代碼,希望有人可以發現問題。

$server->register(
                "tankerPortsSearch",
                [
                    'name' => 'xsd:string',
                    'step' => 'xsd:int',
                    'page' => 'xsd:int',
                ],
                [
                    'total'   => 'xsd:int',
                    'results' => 'tns:responceArray'
                ],
                'urn:tankerPortsSearch',
                'urn:tankerZonesTraffic#tankerPortsSearch',
                'rpc',
                'encoded',
                'Tanker Ports Search'
            );


            $server->wsdl->addComplexType('responceArrayData', 'complexType', 'struct', '', 'SOAP-ENC:Array', [
                'id'   => array('name' => 'id', 'type' => 'xsd:int'),
                'name' => array('name' => 'name', 'type' => 'xsd:string')
            ]);
            // *************************************************************************

            // Complex Array ++++++++++++++++++++++++++++++++++++++++++
            $server->wsdl->addComplexType('responceArray', 'complexType', 'array', 'squence', '', [], [
                [
                    'ref'            => 'SOAP-ENC:arrayType',
                    'wsdl:arrayType' => 'tns:responceArrayData[]'
                ]
            ]);

好了,經過數小時的來回測試,我設法猜出了正確的答案,如果有人卡住了nusoap復雜類型,我會在這里發布它

$server->register("tankerPortsSearch", [
        'name' => 'xsd:string',
        'step' => 'xsd:int',
        'page' => 'xsd:int',
    ], [
        'total'   => 'xsd:int',
        'results' => 'tns:responceArray'
    ], 'urn:tankerPortsSearch', 'urn:tankerZonesTraffic#tankerPortsSearch', 'rpc', 'encoded', 'Tanker Ports Search');


$server->wsdl->addComplexType('responceArrayData', 'complexType', 'struct', '', '', [
    'id'   => array('name' => 'id', 'type' => 'xsd:int'),
    'name' => array('name' => 'name', 'type' => 'xsd:string')
]);
// *************************************************************************

// Complex Array ++++++++++++++++++++++++++++++++++++++++++
$server->wsdl->addComplexType('responceArray', 'complexType', 'array', '', '', [], [
    [
        'ref'            => 'SOAP-ENC:arrayType',
        'wsdl:arrayType' => 'tns:responceArrayData[]',
    ]
], 'tns:responceArrayData');

希望我能幫助別人。

干杯

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM