The project I am working on seems pretty straightforward:
I need to send a query to a SP server that retrieves some project
data that is maintained there. I want to collect this data and create
some reports using an external application. I am attempting to use
WSS to do this.
So far I have managed to accomplish the following:
I can ask the server for a list collection, parse the list it returns
and read the various attributes. So I know I am talking to the server
and it is responding.
The problem I am having is that as soon as I try to submit a query
for list items, the server throws an exception. I have been over and
over the code and I cannot figure out what is wrong. I am brand new
to this though so it may be something quite obvious – just something
I haven't yet learned.
I am trying to submit a query that will return the "Title" for every
record where the "Status" field equals "Active". Here is the C# code.
If anyone could even give me a hint I would appreciate it
(unfortunately wrapping is probably going to make this difficult to
read).
//==============================================
MyListSvc.Lists listService = new MyListSvc.Lists();
listService.Credentials =
System.Net.CredentialCache.DefaultCredentials;
listService.Url = "http://sharepnt/mygroup/_vti_bin/Lists.asmx";
XmlDocument xmlDoc = new XmlDocument();
string listName = "My Dashboard";
string viewName = "{700A900F-D7AA-4CD2-A97C-57B0D7A65232}";
string rowLimit = "150";
XmlElement query = xmlDoc.CreateElement("Query");
XmlElement viewFields = xmlDoc.CreateElement("ViewFields");
XmlElement queryOptions = xmlDoc.CreateElement("QueryOptions");
query.InnerXml = "<Where><Eq><FieldRef Name=\"Status\" /><Value
Type=\"Text\">Active</Value></Eq></Where>";
viewFields.InnerXml = "<FieldRef Name=\"Title\" />";
queryOptions.InnerXml = "";
XmlNode nodeListItems;
nodeListItems = null;
nodeListItems = listService.GetListItems(listName, viewName, query,
viewFields, rowLimit, queryOptions, null);
//========================================
The error occurs when it gets to the last line – when it is actually
sending the query to the server.
I suspect it is something rudimentary that I am missing because of my
lack of experience but I cannot find any documentation that helps. I
have spent hours searching MSDN and looking at various places on web.