Soapclient 查询 Sharepoint Web 服务

Soapclient query a Sharepoint web service(Soapclient 查询 Sharepoint Web 服务)
本文介绍了Soapclient 查询 Sharepoint Web 服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我使用以下代码成功查询了一个服务 从这里

 "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;尝试{$rawXMLresponse = $soapClient->GetListItems($params)->GetListItemsResult->any;}赶上(SoapFault $fault){echo '故障代码:'.$fault->faultcode;echo '故障字符串:'.$fault->faultstring;}echo '

'.$rawXMLresponse .'</pre>';$dom = 新的 DOMDocument();$dom->loadXML($rawXMLresponse);$results = $dom->getElementsByTagNameNS("#RowsetSchema", "*");foreach($results 作为 $result){echo $result->getAttribute("ows_LinkTitle")."<br/>";echo $result->getAttribute("ows_Body")."<br/>";}未设置($soapClient);?>

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

下面是从 rawXMLresponse 返回的内容

<pre><listitems xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:dt="uuid:C2F41010-65B3-11d1-A2802F-100xml="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema"><rs:data ItemCount="3"><z:row ows_Attachments="0" ows_LinkTitle="低温和水母" ows_Modified="2010-08-03 09:43:56" ows_Notice_x0020_Type="日历" ows_MetaInfo="1;#" ows__ModerationStatus="0" ows__Level="1" ows_Title="Hypothermia and Jellyfish" "owshidows_IDversion="1="2" ows_UniqueId="1;#{B90ECA8C-6FBB-476D-BF67-A05B07268591}" ows_FSObjType="1;#0" ows_Created_x0020_Date="1;#2010-07:38591"092010-07-29 09:38:52" ows_FileLeafRef="1;#1_.000" ows_FileRef="1;#Lists/kk3/1_.000"/><z:row ows_Attachments="0" ows_LinkTitle=《猎蛇》 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"Snark" ows_ID="2" ows_owshidenversion="2" ows_UniqueId="2;#{F070D967-97F1-40DF-803B-EF50424D205B}" ows_FSObjType="2;#0" ows_Created_x0020_Date="2;#2010-07"-29"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="永远不要低估自己" ows_Modified="2010-08-03 09:43:29" ows_Notice_x0020_Type="Public" ows_MetaInfo="3;#" ows__ModerationStatus="0" ows__Level="1" ows_TitleID="永远不要低估_="3" ows_owshiddenversion="3" ows_UniqueId="3;#{4DBEC63E-E25F-4580-B5D8-590C584A6E95}" ows_FSObjType="3;#0" ows_Created_x0020_Date2:-09:-03;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 参数添加到您的查询中.这允许您指定在查询中返回哪些字段以及以什么顺序返回.

viewFields 是 GetListItems 元素的子元素:

<视图字段><FieldRef Name="LinkTitle"/><FieldRef Name="Body"/></ViewFields></viewFields>

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

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

I successfully query a service with the following code 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);
?>

However the attribute ows_Body doesnt display, probably because the atribute is not fetched in the $rawXMLresponse. How do I get that in the response? If the GetListItems requires an extra query paramater how do I format that?

below is what is returned from the 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>

解决方案

Try adding a ViewFields parameter to your query. This allows you to specify which fields to return in the query and in what order.

viewFields is a child of the GetListItems element:

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

Based on the example you gave, I'm guessing at the column names you'd be after; you may need to adjust to whatever SharePoint is actually calling those columns internally.

The ows_ prefix is added to the column name, so you wouldn't address them in that format except when retrieving from the result XML.

这篇关于Soapclient 查询 Sharepoint Web 服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)