"password"); $listName = "{2882F083-8890-4ADA--6ren">
gpt4 book ai didi

php - Soapclient 查询 Sharepoint Web 服务

转载 作者:搜寻专家 更新时间:2023-10-31 21:46:06 25 4
gpt4 key购买 nike

我使用以下代码成功查询了一个服务 from here

<?php
$authParams = array("login" => "username", "password" => "password");
$listName = "{2882F083-8890-4ADA-A1FC-39ED1D63D825}";
$rowLimit = '150';
$wsdl = "http://localhost:89/list.wsdl";
$soapClient = new SoapClient($wsdl, $authParams);
$params = array('listName' => $listName, 'rowLimit' => $rowLimit);
$rawXMLresponse = null;
try{
$rawXMLresponse = $soapClient->GetListItems($params)->GetListItemsResult->any;
}
catch(SoapFault $fault){
echo 'Fault code: '.$fault->faultcode;
echo 'Fault string: '.$fault->faultstring;
}
echo '<pre>' . $rawXMLresponse . '</pre>';

$dom = new DOMDocument();
$dom->loadXML($rawXMLresponse);
$results = $dom->getElementsByTagNameNS("#RowsetSchema", "*");

foreach($results as $result){
echo $result->getAttribute("ows_LinkTitle")."<br/>";
echo $result->getAttribute("ows_Body")."<br/>";
}
unset($soapClient);
?>

但是属性 ows_Body 没有显示,可能是因为属性没有在 $rawXMLresponse 中获取。我如何在响应中得到它?如果 GetListItems 需要额外的查询参数,我该如何格式化它?

下面是从 rawXMLresponse 返回的内容

<pre><listitems xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema"><rs:data ItemCount="3"><z:row ows_Attachments="0" ows_LinkTitle="Hypothermia and Jellyfish" ows_Modified="2010-08-03 09:43:56" ows_Notice_x0020_Type="Calendar" ows_MetaInfo="1;#" ows__ModerationStatus="0" ows__Level="1" ows_Title="Hypothermia and Jellyfish" ows_ID="1" ows_owshiddenversion="2" ows_UniqueId="1;#{B90ECA8C-6FBB-476D-BF67-A05B07268591}" ows_FSObjType="1;#0" ows_Created_x0020_Date="1;#2010-07-29 09:38:52" ows_Created="2010-07-29 09:38:52" ows_FileLeafRef="1;#1_.000" ows_FileRef="1;#Lists/kk3/1_.000"/><z:row ows_Attachments="0" ows_LinkTitle="The Hunting of the Snark" ows_Modified="2010-08-03 09:43:42" ows_Notice_x0020_Type="Public" ows_MetaInfo="2;#" ows__ModerationStatus="0" ows__Level="1" ows_Title="The Hunting of the Snark" ows_ID="2" ows_owshiddenversion="2" ows_UniqueId="2;#{F070D967-97F1-40DF-803B-EF50424D205B}" ows_FSObjType="2;#0" ows_Created_x0020_Date="2;#2010-07-29 09:39:57" ows_Created="2010-07-29 09:39:57" ows_FileLeafRef="2;#2_.000" ows_FileRef="2;#Lists/kk3/2_.000"/><z:row ows_Attachments="0" ows_LinkTitle="Never undersell yourself" ows_Modified="2010-08-03 09:43:29" ows_Notice_x0020_Type="Public" ows_MetaInfo="3;#" ows__ModerationStatus="0" ows__Level="1" ows_Title="Never undersell yourself" ows_ID="3" ows_owshiddenversion="3" ows_UniqueId="3;#{4DBEC63E-E25F-4580-B5D8-590C584A6E95}" ows_FSObjType="3;#0" ows_Created_x0020_Date="3;#2010-07-29 09:40:32" ows_Created="2010-07-29 09:40:32" ows_FileLeafRef="3;#3_.000" ows_FileRef="3;#Lists/kk3/3_.000"/></rs:data></listitems></pre>

最佳答案

尝试将 ViewFields 参数添加到您的查询中。这允许您指定要在查询中返回的字段以及返回的顺序。

viewFieldsGetListItems 元素的子元素:

<viewFields>
<ViewFields>
<FieldRef Name="LinkTitle" />
<FieldRef Name="Body" />
</ViewFields>
</viewFields>

根据您提供的示例,我猜测您要查找的列名称;您可能需要根据 SharePoint 在内部实际调用这些列的情况进行调整。

ows_ 前缀被添加到列名中,因此除非从结果 XML 中检索,否则您不会以该格式处理它们。

关于php - Soapclient 查询 Sharepoint Web 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3447152/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com