2009-07-03 65 views
4

我已經在我的代碼下面的語句:的SharePoint SoapServerException調用GetListItems Web服務

System.Xml.XmlNode items = lstWebs.GetListItems(
    "Tasks", string.Empty, listQuery, listViewFields, 
    string.Empty, listQueryOptions, WorkspaceId); 

在執行此操作,會出現以下異常:

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

Exception Source is: 
System.Web.Services 

Stack Trace: 
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) 
    at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) 
    at ImpersonationConsoleApp.MossLists.Lists.GetListItems(String listName, String viewName, XmlNode query, XmlNode viewFields, String rowLimit, XmlNode queryOptions, String webID) in C:\Documents and Settings\david\My Documents\_Dew02SiteCreator\DeWProjectStarter\ImpersonationConsoleApp\Web References\MossLists\Reference.cs:line 435 
    at ImpersonationConsoleApp.Program.DeleteTasksIfNotExist(DataRow[] drTasksdel, String siteURL) in C:\Documents and Settings\david\My Documents\_Dew02SiteCreator\DeWProjectStarter\ImpersonationConsoleApp\Program.cs:line 1384 

我已確認該網站的網址,這是精細。

請問您爲什麼會發生異常?我需要重置IIS嗎?

請找到細節。

SoapException.InnerException is Null. 
However the soapExcetion.Detail.InnerText is showing: The system cannot find the file specified. (Exception from HRESULT: 0x80070002) 
+0

你能檢查出SoapException的InnerException和SoapException.Detail屬性,然後在這裏發佈? – Colin 2009-07-03 12:46:53

+0

你可以寫一些關於參數的更多信息作爲「listQuery」的值嗎?你正在實施什麼類型的應用程序? – jaloplo 2011-01-31 17:32:31

回答

3

名稱任務是否也是url中的實際列表名?即http://siteurl/lists/tasks?是子網站中的列表,並且您是否使用網站集下的服務?

如果列表位於使用http://sitecollectionurl/subsite/_vti_bin/lists.asmx作爲服務URL的子網站中,否則lists.asmx將嘗試在rootweb而不是子網站中查找任務列表。

+0

當列表網址不正確時,我遇到了上述問題。 – Mark 2012-11-27 17:19:24

-1

您是否嘗試過與提升的權限運行,它看起來像正在運行的用戶沒有甲肝足夠的權限來查詢數據...

SPSecurity.RunWithElevatedPrivileges

+2

如何使用相同的網絡服務??? – 2011-01-11 10:08:31

3

爲GetListItems簽名是

GetListItems(ListID,「」,queryNode,viewFieldsNode,Nothing,queryOptionsNode,Nothing)

嘗試將queryNode,viewFieldsNode和queryOptionsNode簡化爲minimal。

在VB.NET

Dim caml = New XmlDocument 
Dim queryNode = caml.CreateElement("Query") 
Dim viewFieldsNode = caml.CreateElement("ViewFields") 
Dim queryOptionsNode = caml.CreateElement("QueryOptions") 
queryOptionsNode.InnerXml = "<ViewAttributes Scope=""Recursive"" /><IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns>" 

在C#

var caml = new XmlDocument(); 
var queryNode = caml.CreateElement("Query"); 
var viewFieldsNode = caml.CreateElement("ViewFields"); 
var queryOptionsNode = caml.CreateElement("QueryOptions"); 
queryOptionsNode.InnerXml = "<ViewAttributes Scope=\"Recursive\" /><IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns>"; 

如果成功,那麼Web服務設置是否正確。

當我遇到上述問題時,導致它出現的是無效的XML。 queryNode中'Where'元素的'Value'元素缺少'type'屬性。我從Microsoft在這裏找到它。

類型|必需的文本。指定此元素包含的值的數據類型。

它在添加Type屬性後起作用。檢查上面提到的其中一個節點是否缺少xml的需求?

相關問題