Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > .NET Web Services
.NET Web Services Discussions about .NET XML Web Service technologies including ASMX files, WSDL and SOAP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Web Services section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old August 11th, 2008, 06:30 PM
Authorized User
Join Date: Oct 2003
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default Sharepoint GetListItems() ViewFields not working

Hi Everyone - not sure if this is the right forum - maybe someone can point me in the right direction.

I'm following what I think should work and narrow down my results from the GetListItems() method of Sharepoint 2007.

I'm creating an XML element <ViewFields> and populating it with <FieldRef Name="NewsTitle" /><FieldRef Name="ID" /></ViewFields> and passing it in to the ViewFields argument. But the web service returns *all* fields, no matter what view name I give it (null or the guid).

Any ideas what's going on?

Code posted below

string strReturn = string.Empty;
            vsharepoint2007.Lists L = new WSTest.vsharepoint2007.Lists();
            L.Url = "http://vsharepoint2007:16848/_vti_bin/lists.asmx";
            L.Credentials = new System.Net.NetworkCredential("administrator", "forkhead");
            System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
            string listName = "{A36E3C89-F137-4205-8699-3476D58D82CC}";
            string viewName = "{93B7AAB7-7BCB-4CB4-BCE7-7BA384165698}";
            string rowLimit = "1";
            System.Xml.XmlElement ndQuery = xmlDoc.CreateElement("Query");
            System.Xml.XmlElement ndViewFields = xmlDoc.CreateElement("ViewFields");
            System.Xml.XmlElement ndQueryOptions = xmlDoc.CreateElement("QueryOptions");

            ndQuery.InnerXml = "<Where><Eq><FieldRef Name=\"ID\" />" +
                    "<Value Type=\"Counter\">1</Value>" +
            ndViewFields.InnerXml = "<FieldRef Name=\"NewsTitle\" /><FieldRef Name=\"ID\" />";
            ndQueryOptions.InnerXml = "";
            System.Xml.XmlNode nodeListItems = L.GetListItems(listName, null, ndQuery, ndViewFields, rowLimit, ndQueryOptions, null);

            foreach (System.Xml.XmlNode X in nodeListItems)
                strReturn += X.OuterXml;
            return strReturn;

"A spirit with a vision is a dream with a mission"
\"A spirit with a vision is a dream with a mission\"
Old August 12th, 2008, 03:16 AM
samjudson's Avatar
Friend of Wrox
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts

I think a Sharepoint forum would be better for this question:


However by a simple reading of the docs I could guess that it might have something to do with the IncludeMandatoryColumns value defaulting to TRUE.


/- Sam Judson : Wrox Technical Editor -/

Similar Threads
Thread Thread Starter Forum Replies Last Post
Sharepoint ramamurthi_c SharePoint Development 1 December 11th, 2009 07:01 PM
Sharepoint Jayarajmrj SQL Server 2000 1 July 30th, 2007 10:16 PM
Sharepoint Search x_ray SharePoint Admin 0 December 2nd, 2006 12:33 PM
Sharepoint Chart, nlpatel78 ASP.NET 2.0 Basics 0 July 28th, 2006 01:18 AM
Local COM working , but not working at Web Serv nagen111 .NET Web Services 3 February 19th, 2005 04:22 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.