2013-08-17 189 views
1

我嘗試通過iOS HTTP調用訪問Sharepoint 2007 Web服務。通信協議是SOAP(1和1.2)。我能夠成功執行GetList和GetListAndView。但是,當我嘗試GetListItems時,我得到任何數量的錯誤消息,其中沒有任何意義。Sharepoint 2007 Web服務錯誤

SOAP調用的格式(1.2在這種情況下,但存在1.0同樣的問題)爲GetListItems是這樣的:

<?xml version="1.0" encoding="utf-8"?> 
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> 
    <soap12:Body> 
     <GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/"> 
      <listName>TaskListSample2-0</listName> 
      <viewName>{13C5392C-7DBC-4803-A3B8-B377D8566A55}</viewName> 
      <query><Query><Where><Or><Eq><FieldRef Name="Title"></FieldRef><Value Type="Text">Test</Value></Eq><IsNotNull><FieldRef Name="Title"></FieldRef></IsNotNull></Or></Where></Query></query> 
      <viewFields><ViewFields><FieldRef Name="Title" /><FieldRef Name="Status" /></ViewFields></viewFields> 
      <rowLimit>100</rowLimit> 
      <queryOptions></queryOptions> 
      <webID>c069106a-8d18-43d6-81c2-2687f568a3c5</webID> 
     </GetListItems> 
    </soap12:Body> 
</soap12:Envelope> 

<Query>...</Query>之間的內容的結構,因爲它是完全一樣的格式化成一個成功的.Net調用這個函數。

我收到以下錯誤信息回:

<?xml version="1.0" encoding="UTF-8"?> 
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
    <soap:Body> 
     <soap:Fault> 
      <soap:Code> 
       <soap:Value>soap:Receiver</soap:Value> 
      </soap:Code> 
      <soap:Reason> 
       <soap:Text xml:lang="en">Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown.</soap:Text> 
      </soap:Reason> 
      <detail> 
       <errorstring xmlns="http://schemas.microsoft.com/sharepoint/soap/">Root element is missing.</errorstring> 
      </detail> 
     </soap:Fault> 
    </soap:Body> 
</soap:Envelope> 

我花了天這個,與其他幾個程序員誰是在.net和Sharepoint精通一起。根據對查詢的各種編輯更改,我們還看到「查詢中的元素&lt;Query&gt;已丟失或無效。」

順便說一下,我還試圖通過Windows盒子上的Fiddler2來調用所有這些SOAP調用。我看到與iOS HTTP調用相同的確切結果。

我已經能夠得到最接近的答案是查詢格式不正確(杜)。但在我的生活中,正確的格式正在逃避我們。我們已經能夠成功地從本地.Net應用程序查詢服務器,但是將查詢XML的確切內容和格式複製到iOS代碼中並不會改變任何內容。

不用說,微軟的文檔和錯誤信息是無用的。不,我們不能遷移到MOSS 2010.客戶不會很快更新,所以我們必須使用他們已有的技術。

任何幫助都會令人難以置信的讚賞。即使有人能夠明確地證明2007年特定的Web服務功能被破壞了。雖然它會吸引人,但至少我們知道我們並不是完全愚蠢的。但是,如果任何人都可以確定我實際上格式化查詢錯誤,並告訴我如何解決這個問題,那將會很棒。

謝謝。

回答

0

我在iOS上使用SOAP查詢取得了一些成功。它絕對有一個很好的學習曲線。我應該注意到,我不是SP專家,所以我不能解釋爲什麼你的不工作。這是很多谷歌搜索和(askingon SO)的結果。 這裏的原始XML當我做了GetListItems

<?xml version="1.0" encoding="utf-8"?> 
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 
    <soap:Body> 
    <GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/"> 
     <listName>Notes</listName> 
     <query> 
     <Query> 
     <Where> 
     <Or> 
      <Eq> 
      <FieldRef Name="Title"></FieldRef> 
      <Value Type="Text">Chris Test</Value> 
      </Eq> 
      <Eq> 
      <FieldRef Name="Folder"></FieldRef> 
      <Value Type="Text">Ungrouped</Value> 
      </Eq> 
     </Or> 
     </Where> 
     </Query> 
     </query> 
     <rowLimit>0</rowLimit> 
     <queryOptions> 
     <QueryOptions xmlns:ns2="http://schemas.microsoft.com/sharepoint/soap/" xmlns=""> 
      <IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns> 
      <ViewAttributes Scope="Recursive" /> 
     </QueryOptions> 
     </queryOptions> 
    </GetListItems> 
    </soap:Body> 
</soap:Envelope> 

從自定義列表叫筆記,這將給所有條目,其中一個標題==克里斯測試或文件夾==「取消分組」

編輯,我看到你有一個IsNotNull屬性,這裏就是我正在做的是:(修剪爲簡便起見)

<query><Query> 
    <Where> 
    <Or> 
     <IsNotNull> 
     <FieldRef Name="Title"></FieldRef> 
     </IsNotNull> 
     <Eq> 
     <FieldRef Name="Folder"></FieldRef> 
     <Value Type="Text">Ungrouped</Value> 
     </Eq> 
    </Or> 
    </Where> 
</Query></query> 
0

我知道這個問題是在一歲,但我的猜測是,你缺少一個

0123所述

<queryOptions></queryOptions> 

節點內

<QueryOptions /> 

元件。希望至少有人幫助:)

相關問題