2009-08-20 98 views
4

我正在嘗試獲取「用戶信息列表」的內容。此列表只能作爲管理員用戶使用。我有一個登錄的管理員用戶,然後一個方法執行以下操作:Sharepoint通過web服務訪問「用戶信息列表」

var xmlDoc = new XmlDocument(); 
var query = xmlDoc.CreateElement("Query"); 
query.InnerXml = "<Where><Eq><FieldRef Name='ContentType' /><Value Type='Choice'>Person</Value></Eq></Where>"; 
XmlElement viewFields = xmlDoc.CreateElement("ViewFields"); 
viewFields.InnerXml = "<FieldRef Name='Title' />"; 
XmlElement queryOptions = xmlDoc.CreateElement("QueryOptions"); 
var items = ws.GetListItems("User Information List", "", query, viewFields, string.Empty, queryOptions, "8A391AE3-2783-489B-8BDF-D2AE971D73CD"); 

我的目錄名稱是正確的,所以是GUID我通過SharePoint資源管理器

<List DocTemplateUrl="" DefaultViewUrl="/_catalogs/users/detail.aspx" MobileDefaultViewUrl="" ID="{8A391AE3-2783-489B-8BDF-D2AE971D73CD}" Title="User Information List" Description="All people." ImageUrl="/_layouts/images/users.gif" Name="{8A391AE3-2783-489B-8BDF-D2AE971D73CD}" BaseType="0" FeatureId="" ServerTemplate="112" Created="20080430 02:48:38" Modified="20090819 08:31:52" LastDeleted="20090604 12:32:50" Version="141" Direction="none" ThumbnailSize="" WebImageWidth="" WebImageHeight="" Flags="41971988" ItemCount="46" AnonymousPermMask="0" RootFolder="/_catalogs/users" ReadSecurity="1" WriteSecurity="1" Author="1" EventSinkAssembly="" EventSinkClass="" EventSinkData="" EmailInsertsFolder="" EmailAlias="" WebFullUrl="/" WebId="767c0b20-058d-4b53-8362-81e005bf5098" SendToLocation="" ScopeId="64857900-37cf-431c-be07-5528d1ae46af" MajorVersionLimit="0" MajorWithMinorVersionsLimit="0" WorkFlowId="" HasUniqueScopes="False" AllowDeletion="False" AllowMultiResponses="False" EnableAttachments="True" EnableModeration="False" EnableVersioning="False" Hidden="True" MultipleDataList="False" Ordered="False" ShowUser="True" EnableMinorVersion="False" RequireCheckout="False" /> 

我htat從下面我正在返回以下錯誤:

<?xml version="1.0" encoding="utf-8"?> 
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
     <soap:Body> 
      <soap:Fault> 
       <faultcode>soap:Server</faultcode> 
       <faultstring>Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown.</faultstring> 
       <detail> 
        <errorstring xmlns="http://schemas.microsoft.com/sharepoint/soap/">The system cannot find the file specified. (Exception from HRESULT: 0x80070002)</errorstring> 
       </detail> 
      </soap:Fault> 
     </soap:Body> 
    </soap:Envelope> 

你知道爲什麼我得到這個錯誤嗎?

更新

var items = ws.GetListItems("User Information List", "", query, viewFields, string. 

是扔在C#代碼的異常。所引發的異常是:

Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown. 

不是一個很大的幫助......

更新2

,我發現這個網站上http://www.aidangarnish.net/blog/post/2008/04/Retrieving-items-from-a-MOSS-2007-list-using-web-services.aspx,改變了我的代碼:

var node = ws.GetListItems("User Information List", String.Empty, null, null, String.Empty, null, null); 

我現在正在查看結果!仍然不知道我最初的查詢有什麼問題,所以問題的立場...

+0

可以使用SPServices了。 – trgraglia 2011-03-09 14:09:08

回答

1
var node = ws.GetListItems("User Information List", String.Empty, null, null, String.Empty, null, null); 

似乎從試錯中工作得很好。

1

我不知道這會回答你的問題,但是,我有更多的運氣,包括不必登錄爲管理員,如果您訪問使用用戶信息表:

  • 「的UserInfo」

相反的:

  • 「用戶信息列表」

它這裏的文件中列出: http://msdn.microsoft.com/en-us/library/lists.lists.getlist.aspx

LISTNAME 包含標題或的GUID列表的字符串。查詢UserInfo表時,該字符串包含「UserInfo」。

也許給一個鏡頭。

+0

這是我的列表listService.GetList(「UserInfo」);但我需要它裏面的物品...... – Rupert 2009-08-20 15:21:19

+0

當然,但在上面的代碼中使用相同的技術來獲取物品。 – 2009-08-20 15:49:28

+0

與上面相同的錯誤... – Rupert 2009-08-20 15:55:03

3

如果您遇到問題「系統找不到指定的文件(來自HRESULT:0x80070002的異常)」,請嘗試將最後一個參數「webId」設置爲空。

看看微軟的Web服務的規範說:

webID: Optional. A string containing the GUID of the parent Web site for the list surrounded by curly braces ({}). Setting this parameter to null means the Web site specified by the URL property of the service will be used, and if the URL property of the service is not specified, the root Web site will be used.

來源:http://msdn.microsoft.com/en-us/library/lists.lists.getlistitems(v=office.12).aspx

相關問題