我尝试使用我在http://forrst.com/posts/PHP_Read_and_write_to_SharePoint_Lists-PRF找到的类由SOAP执行的caml查询现在我可以让它返回sharepoint 2010列表,但它只会向我显示默认视图,无论我添加什么在查询中,我尝试过很多东西,包括CAMl查询构建器
我已经将查询硬编码到上面链接的php类中的read方法
我改变了:
public function read($list, $limit = 0, $query = null){
//Check limit is set
if($limit==0 || $limit == null)$limit = MAX_ROWS;
//Create Query XML is query is being used
$queryXML = '';
//If query is set pass it to the query builder
if($query != null){
$queryXML = $this->queryXML($query);
}
//Setup basic XML for query
$CAML = '
<GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<listName>'.$list.'</listName>
<rowLimit>'.$limit.'</rowLimit>
'.$queryXML.'
<queryOptions xmlns:SOAPSDK9="http://schemas.microsoft.com/sharepoint/soap/" >
<QueryOptions/>
</queryOptions>
</GetListItems>';
//Create SOAP instance
$soap = $this->createSoapObject();
//Ready XML
$xmlvar = new SoapVar($CAML, XSD_ANYXML);
$rawXML ='';
//Attempt to query Sharepoint
try{
$rawXML = $soap->GetListItems($xmlvar)->GetListItemsResult->any;
}catch(SoapFault $fault){
$this->onError($fault);
}
//Return a XML as nice clean Array
return $this->xmlToArray($rawXML);
}
到这个
public function read($list, $limit = 150, $query = null){
//Check limit is set
if($limit==0 || $limit == null)$limit = MAX_ROWS;
//Create Query XML is query is being used
$queryXML = '';
//If query is set pass it to the query builder
if($query != null){
$queryXML = $this->queryXML($query);
}
//Setup basic XML for query
$CAML = '<GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<listName>'.$list.'</listName>
<query>
<Query xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<OrderBy>
<FieldRef Name="Title" Ascending="True" />
</OrderBy>
</Query>
</query>
<viewfields>
<ViewFields xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<FieldRef Name="Title" />
<FieldRef Name="Sequence" />
<FieldRef Name="Region" />
<FieldRef Name="Email" />
<FieldRef Name="Telephone" />
<FieldRef Name="Fax" />
<FieldRef Name="Entity" />
<FieldRef Name="Address_x0020_1" />
<FieldRef Name="Address_x0020_2" />
<FieldRef Name="Address_x0020_3" />
<FieldRef Name="Town" />
<FieldRef Name="County" />
<FieldRef Name="Postcode" />
<FieldRef Name="Office_x0020_Type" />
<FieldRef Name="Legal_x0020_Entity" />
<FieldRef Name="Company_x0020_Number" />
<FieldRef Name="Office_x0020_Link" />
<FieldRef Name="Map" />
<FieldRef Name="Email_x0020_Forward" />
<FieldRef Name="Footer" />
<FieldRef Name="Contact" />
<FieldRef Name="Address" />
<FieldRef Name="Company_x0020_Registration_x0020" />
<FieldRef Name="Company_x0020_Registered_x0020_D" />
<FieldRef Name="Office_x0020_Investment_x0020_Bu" />
<FieldRef Name="VAT_x0020_Number" />
<FieldRef Name="Email_x0020_Forward_x0020_Format" />
<FieldRef Name="ID" />
<FieldRef Name="Modified" />
</ViewFields>
</viewfields>
<QueryOptions xmlns="http://schemas.microsoft.com/sharepoint/soap/" />
</GetListItems>';
//Create SOAP instance
$soap = $this->createSoapObject();
$this->caml = $soap;
//Ready XML
$xmlvar = new SoapVar($CAML, XSD_ANYXML);
$rawXML ='';
//Attempt to query Sharepoint
try{
$rawXML = $soap->GetListItems($xmlvar)->GetListItemsResult->any;
}catch(SoapFault $fault){
$this->onError($fault);
}
//Return a XML as nice clean Array
return $this->xmlToArray($rawXML);
}
结果的一个例子
Array
(
[0] => Array
(
[Office_x0020_Link] => xxxxxxxx
[Region] => xxxxxxx
[Email] => xxxxxxx
[Telephone] => xxxxxxx
[Entity] => xxxxxxxxx
[MetaInfo] => xxxxx
[_ModerationStatus] => xxxxxx
[_Level] => xxxxx
[ID] => xxxx
[UniqueId] => xxxx
[owshiddenversion] => xxxx
[FSObjType] => xxxxx
[Created] => xxxxxx
[PermMask] => xxxxxx
[Modified] => xxxxxx
[FileRef] => xxxxxxx
)
正如您所看到的那样,它没有带回我要求的所有字段,如果您连接到sharepoint中的页面(最小视图),结果就是(默认)列表显示的结果。我们有一个完整的视图设置,但我不知道如何在我的查询中引用它。
我真的不太了解sharepoint 2010,caml和这些查询我试图把结果整个列表导入php,所以我可以在其他地方使用它。
提前致谢。