Php 使用nusoap通过web服务从Sharepoint库下载文件

Php 使用nusoap通过web服务从Sharepoint库下载文件,php,web-services,sharepoint,wsdl,nusoap,Php,Web Services,Sharepoint,Wsdl,Nusoap,我正在尝试使用nusoap客户端通过web服务从Sharepoint库下载文件。我能够使用Lists.wsdl连接并获取列表内容,但我在计算Copy.wsdl方法的参数时遇到了困难 <?php require_once('lib/nusoap.php'); $username = 'domain\user'; $password = 'secret'; $rowLimit = '0'; $listGuid = "{0379989D-8639-430B-9FD0-96551B7EAB2

我正在尝试使用nusoap客户端通过web服务从Sharepoint库下载文件。我能够使用Lists.wsdl连接并获取列表内容,但我在计算Copy.wsdl方法的参数时遇到了困难

<?php

require_once('lib/nusoap.php');

$username = 'domain\user';
$password = 'secret';
$rowLimit = '0';

$listGuid = "{0379989D-8639-430B-9FD0-96551B7EAB29}";

//Lists.wsdl copied from the Sharepoint site and stored on local drive
$wsdl = "http://localhost/sp/Lists.wsdl";
//NTLM authentication.
$client = new nusoap_client($wsdl, true);
$client->setCredentials('','','ntlm');
$client->useHTTPPersistentConnection();
$client->setCurlOption(CURLOPT_USERPWD, $username.':'.$password);

//XML for the request
$getItemsXml ='
<GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<listName>'.$listGuid.'</listName>
<rowLimit>'.$rowLimit.'</rowLimit>
</GetListItems>
';

//This works and returns requested data from a list
$result = $client->call('GetListItems', $getItemsXml);
$responseContent = substr($client->response,strpos($client->response, "<"),strlen($client->response)-1);


//This part does not work
//Library ID
$fileGuid = "{A24306B5-50E9-44C0-9728-69E2D015B689}";

$cwsdl = "http://localhost/sp/Copy.wsdl";
$cclient = new nusoap_client($cwsdl, true);
$cclient->setCredentials('','','ntlm');
$cclient->useHTTPPersistentConnection();
$cclient->setCurlOption(CURLOPT_USERPWD, $username.':'.$password);

//This is where I get lost
$fileParams = array();
$cResult = array(0);
$fieldInformationCollection = array('fieldInformation'=>array('DisplayName'=>'', 'Id'=>'', 'InternalName'=>'', 'Type'=>'', 'Value'=>''));
$content = array('');

$fileParams[] = "http://site.example.com/subsite/folder/somefile.pdf";
$fileParams[] = $cResult;
$fileParams[] = $fieldInformation;
$fileParams[] = $content;

//This call fails
$result = $cclient->call('GetItem', $fileParams);

?>
我已尝试读取(并理解)Copy.wsdl文件并完成调试输出,但没有成功


有人用这个吗?谢谢。

经过几个小时的调试,我发现答案非常简单。需要发送的唯一参数是要下载的文件的URL,如下所示:

//Set URL of the file
$file['Url'] = 'http://site.example.com/subsite/Folder/requested_file.ext';

//Call nusoap client
$result = $cclient->call('GetItem', $file);
该参数需要是一个关联数组,其中包含一个名为“Url”的元素

客户端将返回一个数组,其中包含元素“GetItemResult”(成功时设置为0)、“Fields”(一个包含75个数组的数组,其中包含库中文件的各种信息),最后是“Stream”,其中包含一个字符串中的Base64编码文件内容

file_put_contents('c:/temp/requested_file.ext', base64_decode($result['Stream']));
file_put_contents('c:/temp/requested_file.ext', base64_decode($result['Stream']));