1

啊啊啊!!我需要另一双眼睛。我一直在研究这个通过 .NET Web 服务使用 nusoap 和 PHP 的项目。我遇到的问题是主对象数组中的数组永远不会在数组中的一个元素之后形成任何 XML。请求成功,数组中有一个元素,但永远无法形成包含多个元素的 XML。所以形成的 XML 请求总是:“ <PictureIDs><long>1466020</long></PictureIDs>

但实际上应该是:

<PictureIDs><long>1466020</long><long>1444431</long></PictureIDs>

所以它可以工作,但只能与一个成功的 PictureID 一起工作 - 而不是第二个......我不明白我做错了什么。我想要的只是将多个 PictureID 传递到 PictureIDs 数组中……有人对如何实现这一点有更好的想法吗?您可以看到生成的 REQUEST XML - 但它只是跳过了第二个 PictureID。


我已经尝试了基本方法:

$create_export_request = array(
    'exportRequest'=>array(
        'Credentials'=>array('UserID'=>12345),
        'ApplicationID'=>1,
        'PictureIDs'=>array('long'=>1444431,'long'=>1466020),
        'ExportType'=>'40',
        'ExportOption'=>'ALLOW_DOWNLOAD',
        'EmailFrom'=>'from@me.com',
        'RequireLogin'=>'false',
        'RetainFiles'=>'false',
        'PackageCompressionType'=>'ZIP'
        )
        );

$client = new nusoap_client('http://zzzz.WebService.asmx?WSDL',true);
$result = $client->call('ManageProcess',$create_export_request);

要求:

POST /V1.2.5/ExportInterface/EMService.asmx HTTP/1.0 主机:dmr2.spe.sony.com 用户代理:NuSOAP/0.9.5 (1.123) 内容类型:text/xml;charset=UTF-8 SOAPAction:“http://WebService.zzz/ManageProcess”内容长度:1225

<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns2996="http://tempuri.org"><SOAP-ENV:Body><ManageProcess xmlns="http://zzzz.WebService.asmx"><exportRequest><Credentials><UserID>12345</UserID></Credentials><ApplicationID>1</ApplicationID><PictureIDs><long>1466020</long></PictureIDs><ExportType>40</ExportType><ExportOption>ALLOW_DOWNLOAD</ExportOption><EmailFrom>from@me.com</EmailFrom><RequireLogin>false</RequireLogin><RetainFiles>false</RetainFiles><PackageCompressionType>ZIP</PackageCompressionType></exportRequest></ManageProcess></SOAP-ENV:Body></SOAP-ENV:Envelope>

以这种方式分解数组:

$credentials = array(
    'UserID' => 12345
);

$pictureIds = array(
    'long'=>1444431,
    'long'=>1466020
);

$exportOptions = array(
    'Credentials'=>$credentials,
    'PictureIDs'=>$pictureIds,
    'ApplicationID'=>1,
    'ExportType'=>'40',
    'ExportOption'=>'ALLOW_DOWNLOAD',
    'RetainFiles'=>'false',
    'RequireLogin'=>'false',
    'PackageCompressionType'=>'ZIP'
);

$client = new nusoap_client(http://zzzz.WebService.asmx?WSDL',true);
$er = array('exportRequest' => $exportOptions);
$result = $client->call('ManageProcess', array('parameters' => $er));

要求:

POST /V1.2.5/ExportInterface/EMService.asmx HTTP/1.0 主机:dmr2.spe.sony.com 用户代理:NuSOAP/0.9.5 (1.123) 内容类型:text/xml;charset=UTF-8 SOAPAction:“http://WebService.zzz/ManageProcess”内容长度:1225

<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns2996="http://tempuri.org"><SOAP-ENV:Body><ManageProcess xmlns="http://zzzz.WebService.asmx"><exportRequest><Credentials><UserID>12345</UserID></Credentials><ApplicationID>1</ApplicationID><PictureIDs><long>1466020</long></PictureIDs><ExportType>40</ExportType><ExportOption>ALLOW_DOWNLOAD</ExportOption><EmailFrom>from@me.com</EmailFrom><RequireLogin>false</RequireLogin><RetainFiles>false</RetainFiles><PackageCompressionType>ZIP</PackageCompressionType></exportRequest></ManageProcess></SOAP-ENV:Body></SOAP-ENV:Envelope>
4

1 回答 1

0

您在这里有效地用另一个值覆盖了一个键“long”:

$create_export_request = array(
...
'exportRequest'=>array(
    'PictureIDs'=>array('long'=>1444431,'long'=>1466020),

在发送之前查看该数组。您更有可能只是将它们添加到类似'PictureIDs'=>array(1444431, 1466020)或类似的数组中。希望有帮助。

于 2012-10-16T02:34:15.400 回答