Can't find field data in Sharepoint list using SOAP - sharepoint

I'm stuck trying to find some data in a Sharepoint list.
I have the list ID, using the List Service "GetList" method I can see that the field I'm looking for is attached to the list. When I try to use "GetListItems" the field isn't there.
I've been assuming that it means the field I want isn't in the default view, but even when I define the view fields explicitly or change the query, I still can't find the data. What should I do?
Here are some of the attempts I've made, none show the fields I'm looking for.
Method 1:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://schemas.microsoft.com/sharepoint/soap/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<ns0:Body>
<ns1:GetListItems>
<ns1:listName>{1A8A3DF2-E5D0-4DDE-B31A-CCC2FB7DA90F}</ns1:listName>
<viewFields>
<FieldRef Name="_ows_Title"/>
<FieldRef Name="_ows_Project_x0020_Description"/>
<FieldRef Name="_ows_Style_x0020_number_x0020_quantit"/>
<FieldRef Name="_ows_Requirement"/>
<FieldRef Name="_ows_First_x0020_order_x0020_entry_x0"/>
<FieldRef Name="_ows_MKT_x0020__x0025__x0020_Completi"/>
<FieldRef Name="_ows_MFG_x0020__x0025_Completion"/>
</viewFields>
<ns1:rowLimit>10</ns1:rowLimit>
</ns1:GetListItems>
</ns0:Body>
</SOAP-ENV:Envelope>
Method 2:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://schemas.microsoft.com/sharepoint/soap/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<ns0:Body>
<ns1:GetListItems>
<ns1:listName>{1A8A3DF2-E5D0-4DDE-B31A-CCC2FB7DA90F}</ns1:listName>
<viewFields>
<FieldRef Name="Title"/>
<FieldRef Name="Project_x0020_Description"/>
<FieldRef Name="Style_x0020_number_x0020_quantit"/>
<FieldRef Name="Requirement"/>
<FieldRef Name="First_x0020_order_x0020_entry_x0"/>
<FieldRef Name="MKT_x0020__x0025__x0020_Completi"/>
<FieldRef Name="MFG_x0020__x0025_Completion"/>
</viewFields>
<ns1:rowLimit>10</ns1:rowLimit>
</ns1:GetListItems>
</ns0:Body>
</SOAP-ENV:Envelope>
Method 3:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://schemas.microsoft.com/sharepoint/soap/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<ns0:Body>
<ns1:GetListItems>
<ns1:listName>{1A8A3DF2-E5D0-4DDE-B31A-CCC2FB7DA90F}</ns1:listName>
<Query>
<Where>
<Gt>
<FieldRef Name="ID"/>
<Value Type="Counter">0</Value>
</Gt>
</Where>
</Query>
<ns1:rowLimit>10</ns1:rowLimit>
</ns1:GetListItems>
</ns0:Body>
</SOAP-ENV:Envelope>
All three methods list all fields in the default view (ignoring my filters/query) but correctly limited to 10 results.

Your examples appear to be missing the outer <{namespace}:viewFields> node defined by the "http://schemas.microsoft.com/sharepoint/soap/" schema. (That or they're missing the inner <ViewFields> node in the body of the parameter.)
The name properties of the FieldRef nodes should be the internal names of the columns.
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://schemas.microsoft.com/sharepoint/soap/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<ns0:Body>
<ns1:GetListItems>
<ns1:listName>{1A8A3DF2-E5D0-4DDE-B31A-CCC2FB7DA90F}</ns1:listName>
<ns1:viewFields>
<ViewFields>
<FieldRef Name="Title"/>
<FieldRef Name="Project_x0020_Description"/>
<FieldRef Name="Style_x0020_number_x0020_quantit"/>
<FieldRef Name="Requirement"/>
<FieldRef Name="First_x0020_order_x0020_entry_x0"/>
<FieldRef Name="MKT_x0020__x0025__x0020_Completi"/>
<FieldRef Name="MFG_x0020__x0025_Completion"/>
</ViewFields>
</ns1:viewFields>
<ns1:rowLimit>10</ns1:rowLimit>
</ns1:GetListItems>
</ns0:Body>
</SOAP-ENV:Envelope>
Note that the response will include system columns (such as Title, ID, and Created/Modified) in the results, even if you didn't specify them in the ViewFields.

Related

How to retrieve and update the data in a nested xml file in python?

I am working on this xml file stored in my AWS s3 bucket, I have to update the value tags in the ATTRIBUTES tag. Can any body help me that how can I travel to the value tags and update the values in them? I am using minidom module and this is fetched as a class-xml.dom.minidom.Document
<?xml version="1.0" encoding="utf-8"?>
<PPL DATE="11/03/2021 14:58:58" USER="XXXX" WORKSTATION="FFFFF">
<PPLScene>
<ATTRIBUTES>
<VALUE NAME="SoilDescription" TYPE="String">Compacted Earth</VALUE>
<VALUE NAME="Latitude" TYPE="Double">38.25858101</VALUE>
<VALUE NAME="Longitude" TYPE="Double">-122.04101444</VALUE>
<VALUE NAME="ElevationMetersAboveMSL" TYPE="Double">-28.8674275705822</VALUE>
<VALUE NAME="DescriptionOverride" TYPE="String" />
<VALUE NAME="Guid" TYPE="String">ab0b7bdf-ad4f-4548-be4e-f457e61e1b53</VALUE>
<VALUE NAME="TreeNodeExpanded" TYPE="Boolean">True</VALUE>
<VALUE NAME="SelectedLoadCase" TYPE="Int32">0</VALUE>
<VALUE NAME="PPLVersion" TYPE="Int32">602</VALUE>
<VALUE NAME="WorkingDataStore" TYPE="String" />
</ATTRIBUTES>
</PPLScene>
</PPL>
I am using the following python code but no luck...
import boto3
import requests
from xml.etree.ElementTree import XML, fromstring, parse
import xml.etree.ElementTree as ET
from xml.dom import minidom
s3 = boto3.client('s3')
def lambda_handler(event, context):
bucket = 'bucketname'
pplx_file_int = 'Pole.xml'
key = pplx_file_int
print(str(key))
obj = s3.get_object(Bucket = bucket, Key = key)
file_data = obj['Body'].read()
print(file_data)
xmldoc = minidom.parseString(file_data)
print(type(xmldoc))
print(xmldoc.nodeName)
print(xmldoc.firstChild.tagName)
procedureList = xmldoc.getElementsByTagName('PPLChildElements')
for procElement in procedureList:
ListOfData2 = procElement.getElementsByTagName('WoodPole')
for attributes in ListOfData2:
element_1 = procElement.getElementsByTagName('ATTRIBUTES')
print(element_1)
Would recommend using parsel:
pip install parsel
Makes css and xpath convenient to use mate!
from parsel import Selector
sel = Selector(text=u"""
<PPL DATE="11/03/2021 14:58:58" USER="XXXX" WORKSTATION="FFFFF">
<PPLScene>
<ATTRIBUTES>
<VALUE NAME="SoilDescription" TYPE="String">Compacted Earth</VALUE>
<VALUE NAME="Latitude" TYPE="Double">38.25858101</VALUE>
<VALUE NAME="Longitude" TYPE="Double">-122.04101444</VALUE>
<VALUE NAME="ElevationMetersAboveMSL" TYPE="Double">-28.8674275705822</VALUE>
<VALUE NAME="DescriptionOverride" TYPE="String" />
<VALUE NAME="Guid" TYPE="String">ab0b7bdf-ad4f-4548-be4e-f457e61e1b53</VALUE>
<VALUE NAME="TreeNodeExpanded" TYPE="Boolean">True</VALUE>
<VALUE NAME="SelectedLoadCase" TYPE="Int32">0</VALUE>
<VALUE NAME="PPLVersion" TYPE="Int32">602</VALUE>
<VALUE NAME="WorkingDataStore" TYPE="String" />
</ATTRIBUTES>
</PPLScene>
</PPL>""")
print("===============Text Fields==================")
for name_attr in sel.css('PPL PPLScene ATTRIBUTES VALUE'):
print(name_attr.css("::text").get()) # Text
print("===============Atttributes==================")
for name_attr in sel.css('PPL PPLScene ATTRIBUTES > VALUE'):
if ('name' in name_attr.attrib ):
print(name_attr.attrib['name']) # Text

EMF resource load - SAXParser reading map twice

I'm having problems with persistence in EMF. The problem occurs when I add an element to a file that contains a map of elements. The process is:
Load file
Add element
Save file
The first time I add an element, it works fine. But if I try to add another, it reads
the list in twice before adding the new element. All subsequent uses also read the list twice.
EXAMPLE
I start with a file that looks like this:
<?xml version="1.0" encoding="ASCII"?>
<org.eclipse.mbt.core:CoreServicesResources xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:org.eclipse.mbt.core="http://org/eclipse/mbt/core">
<primaryResources>
<elementsMap key="1">
<value URI="1">
<traceabilityProperties traceable="true" derived="true" topLevel="true" />
<keywords tags="foo" />
</value>
</elementsMap>
</primaryResources>
</org.eclipse.mbt.core:CoreServicesResources>
If I add a new element, I end up with a file that looks like this, which is correct:
<?xml version="1.0" encoding="ASCII"?>
<org.eclipse.mbt.core:CoreServicesResources xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:org.eclipse.mbt.core="http://org/eclipse/mbt/core">
<primaryResources>
<elementsMap key="1">
<value URI="1">
<traceabilityProperties traceable="true" derived="true" topLevel="true"/>
<keywords tags="foo"/>
</value>
</elementsMap>
<elementsMap key="2">
<value URI="2">
<traceabilityProperties traceable="true" derived="true" topLevel="true"/>
<keywords tags="bar"/>
</value>
</elementsMap>
</primaryResources>
</org.eclipse.mbt.core:CoreServicesResources>
However, if I then add another element, I get this, which is incorrect:
<?xml version="1.0" encoding="ASCII"?>
<org.eclipse.mbt.core:CoreServicesResources xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:org.eclipse.mbt.core="http://org/eclipse/mbt/core">
<primaryResources>
<elementsMap key="1">
<value URI="1">
<traceabilityProperties traceable="true" derived="true" topLevel="true"/>
<keywords tags="foo"/>
</value>
</elementsMap>
<elementsMap key="2">
<value URI="2">
<traceabilityProperties traceable="true" derived="true" topLevel="true"/>
<keywords tags="bar"/>
</value>
</elementsMap>
<elementsMap key="1">
<value URI="1">
<traceabilityProperties traceable="true" derived="true" topLevel="true"/>
<keywords tags="bar"/>
</value>
</elementsMap>
<elementsMap key="2">
<value URI="2">
<traceabilityProperties traceable="true" derived="true" topLevel="true"/>
<keywords tags="foo"/>
</value>
</elementsMap>
<elementsMap key="3">
<value URI="3">
<traceabilityProperties traceable="true" derived="true" topLevel="true"/>
<keywords tags="bar"/>
</value>
</elementsMap>
</primaryResources>
</org.eclipse.mbt.core:CoreServicesResources>
When I debug the code, the problem seems to be happening somewhere in the parser. I'm using the Java SE-11 System library, and the parser is com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl
Has anyone else had problems like this?

Expanding of Recurring Events from a Sharepoint Calendar doesn't work for a ViewFields Query

My post is a continue of Expand Recurring Events from a Sharepoint Calendar over WebServices?
The problem is that expanding works while view fields query is null or empty. But since I set up some fields, the response doesn't match expectations.
The Lists.asmx service method,that I use, is
public System.Xml.XmlNode GetListItems(string listName, string viewName, System.Xml.XmlNode query, System.Xml.XmlNode viewFields, string rowLimit, System.Xml.XmlNode queryOptions, string webID)
When I use a viewFields value, presented below, the method doesn't expand recurrence events:
var viewFields = new XmlDocument();
viewFields.LoadXml(#"
<ViewFields>
<FieldRef Name='ID' />
<FieldRef Name='Title' />
</ViewFields>");
What's wrong with a viewFields?
The problem is that view fields should contain additional fields EventDate, EndDate, fRecurrence and RecurrenceData. When this items absent, expanding doesn't work. So, if you want to retrieve a Category (for example), you should use the following ViewFields query:
<ViewFields>
<FieldRef Name='EventDate' />
<FieldRef Name='EndDate' />
<FieldRef Name='fRecurrence ' />
<FieldRef Name='RecurrenceData' />
<FieldRef Name='Category' />
</ViewFields>

Sharepoint 2010 - Adding Sample data to User Field type

Hi StackOverflow members!
I have developing custom list in Visual Studio (trough XML). I created list definition (with content type) and added list instance to it.
Here is schema.xml of my list:
<?xml version="1.0" encoding="utf-8"?>
<List xmlns:ows="Microsoft SharePoint" Title="Teams" EnableContentTypes="TRUE" FolderCreation="FALSE" Direction="$Resources:Direction;" Url="Lists/Teams" BaseType="0" xmlns="http://schemas.microsoft.com/sharepoint/">
<MetaData>
<ContentTypes>
<ContentTypeRef ID="0x010089E3E6DB8C9B4B3FBB980447E313DE94" />
</ContentTypes>
<Fields>
<Field Type="User" Name="Employee" DisplayName="Employee" Required="TRUE" ID="{7B18E941-BAAD-453A-895C-39579AB5A9F1}" Group="Sample Group" />
<Field Type="Boolean" Name="Manager" DisplayName="Manager" ID="{9FC927CC-45EB-4E9E-8F25-18AAEDF7DCAF}" Group="Sample Group" />
</Fields>
<Views>
<View BaseViewID="0" Type="HTML" MobileView="TRUE" TabularView="FALSE">
<Toolbar Type="Standard" />
<XslLink Default="TRUE">main.xsl</XslLink>
<RowLimit Paged="TRUE">30</RowLimit>
<ViewFields>
<FieldRef Name="Employee" />
<FieldRef Name="Manager" />
</ViewFields>
<Query>
<OrderBy>
<FieldRef Name="Modified" Ascending="FALSE"></FieldRef>
</OrderBy>
</Query>
<ParameterBindings>
<ParameterBinding Name="AddNewAnnouncement" Location="Resource(wss,addnewitem)" />
<ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noXinviewofY_LIST)" />
<ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(wss,noXinviewofY_ONET_HOME)" />
</ParameterBindings>
</View>
<View BaseViewID="1" Type="HTML" WebPartZoneID="Main" DisplayName="$Resources:core,objectiv_schema_mwsidcamlidC24;" DefaultView="TRUE" MobileView="TRUE" MobileDefaultView="TRUE" SetupPath="pages\viewpage.aspx" ImageUrl="/_layouts/images/generic.png" Url="AllItems.aspx">
<Toolbar Type="Standard" />
<XslLink Default="TRUE">main.xsl</XslLink>
<RowLimit Paged="TRUE">30</RowLimit>
<ViewFields>
<FieldRef Name="LinkTitle"></FieldRef>
<FieldRef Name="Employee" />
<FieldRef Name="Manager" />
</ViewFields>
<Query>
<OrderBy>
<FieldRef Name="ID"></FieldRef>
</OrderBy>
</Query>
<ParameterBindings>
<ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noXinviewofY_LIST)" />
<ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(wss,noXinviewofY_DEFAULT)" />
</ParameterBindings>
</View>
</Views>
<Forms>
<Form Type="DisplayForm" Url="DispForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
<Form Type="EditForm" Url="EditForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
<Form Type="NewForm" Url="NewForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
</Forms>
and elements.xml with list template and content type:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<!-- Do not change the value of the Name attribute below. If it does not match the folder name of the List Definition project item, an error will occur when the project is run. -->
<ListTemplate
Name="TeamList"
Type="10000"
BaseType="0"
OnQuickLaunch="TRUE"
SecurityBits="11"
Sequence="410"
DisplayName="TeamList"
Description="My List Definition"
Image="/_layouts/images/itgen.png">
</ListTemplate>
<ContentType
ID="0x010089E3E6DB8C9B4B3FBB980447E313DE94"
Name="Team Member"
Group="Sample Group"
Description=""
Version="0">
<FieldRefs>
<FieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Name="Title" Hidden="TRUE" />
<FieldRef ID="{7B18E941-BAAD-453A-895C-39579AB5A9F1}" />
<FieldRef ID="{9FC927CC-45EB-4E9E-8F25-18AAEDF7DCAF}" />
</FieldRefs>
</ContentType>
<Field Type="User" Name="Employee" DisplayName="Employee" Required="TRUE" ID="{7B18E941-BAAD-453A-895C-39579AB5A9F1}" Group="Sample Group" />
<Field Type="Boolean" Name="Manager" DisplayName="Manager" ID="{9FC927CC-45EB-4E9E-8F25-18AAEDF7DCAF}" Group="Sample Group" />
</Elements>
The question is: how to add sample data to this list? Especially to field of type "User"?
I tried to add this code in list instance element like this:
<ListInstance Title="TeamList"
OnQuickLaunch="TRUE"
TemplateType="10000"
Url="Lists/TeamList"
Description="TeamList">
<Data>
<Rows>
<Row>
<Field Name="Employee">CONTOSO\joses</Field>
<Field Name="Manager">true</Field>
</Row>
</Rows>
</Data>
but, error occures: Error occurred in deployment step 'Activate Features': At least one field type in not installed properly. Any help for makeing it work with dialog would be very appreciated.
A User field is a special type of Lookup field. As such, the text value is represented in the format of ID;#TextValue. And really, it is only the ID that is important. The Value is largely ignored. This can be a problem because while the username will always be the same, the ID that represents that user will change from site collection to site collection.
Your row XML should look something like this:
<Data>
<Rows>
<Row>
<Field Name="Employee">99;#CONTOSO\joses</Field>
<Field Name="Manager">true</Field>
</Row>
</Rows>
</Data>
You said that this is being deployed to an existing site, so you can browse to the User Information page for CONTOSO\joses. The ID will be in the URL's query string. But be aware that even if the feature works in this site, there is no guarantee that the feature will work in other site collections.
To avoid this problem, instead of seeding a list instance using XML, I will generally use a Feature Receiver to pre-populate lists with User fields. I prefer EnsureUser because it will add the user to the site if the user does not already exist.
This will also work:
<Field Name="Employee">-1;#CONTOSO\joses</Field>
In SharePoint 2013 using -1;# to fill a column of type User is less prone to error.
If you misspell or provide a nonexistent user:
<Field Name="Employee">-1;#domain\nonexistent account or misspelled</Field>
The record is NOT created.
Explicitly specifying the ID may result in assigning an existing group or user and could be lot harder to debug. Especially if you also provide a value for the ID column:
<Field Name="ID">1</Field>
<Field Name="Employee">1;#domain\nonexistent account or misspelled</Field>
Both Rich's and Jonathan's answers are correct, just wanted to clarify and couldn't comment due to low rep.

Why does <ViewFields> criteria get ignored by the SharePoint List Service's GetListItems Method

Although I specify a ViewFields element in my sharepoint list service's GetListItems query, all fields are returned. The following code builds the request:
XmlDocument xmlDoc = new System.Xml.XmlDocument();
XmlNode query = xmlDoc.CreateNode(XmlNodeType.Element, "Query", "");
XmlNode viewFields = xmlDoc.CreateNode(XmlNodeType.Element, "ViewFields", "");
XmlNode queryOptions = xmlDoc.CreateNode(XmlNodeType.Element, "QueryOptions", "");
... set query ...
viewFields.InnerXml = "<FieldRef Name='LinkFilename' /><FieldRef Name='FileDirRef' /><FieldRef Name='FileLeafRef' />";
queryOptions.InnerXml = "<IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns><DateInUtc>TRUE</DateInUtc><Folder>Resource Management Tools</Folder><ViewAttributes Scope='Recursive' />";
XmlNode xmlNode = SharePointListWebService.GetListItems(
_listServiceConfigurationSettings.ListName,
string.Empty,
query,
viewFields,
null,
queryOptions,
null);
According to fiddler, this results in the following soap envelope being posted to the list service:
<?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>
<GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<listName>Shared Documents</listName>
<viewName />
<query>
<Query xmlns="">
<Where>
<And>
<Contains>
<FieldRef Name="FileLeafRef" />
<Value Type="Text">.xls</Value>
</Contains>
<Geq>
<FieldRef Name="Modified"
IncludeTimeValue="True" />
<Value Type="DateTime">2010-05-10T11:53:32Z</Value>
</Geq>
</And>
</Where>
<OrderBy>
<FieldRef Name="FileDirRef" />
</OrderBy>
</Query>
</query>
<viewFields>
<ViewFields xmlns="">
<FieldRef Name="LinkFilename" />
<FieldRef Name="FileDirRef" />
<FieldRef Name="FileLeafRef" />
</ViewFields>
</viewFields>
<queryOptions>
<QueryOptions xmlns="">
<IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns>
<DateInUtc>TRUE</DateInUtc>
<Folder>Resource Management Tools</Folder>
<ViewAttributes Scope="Recursive" />
</QueryOptions>
</queryOptions>
</GetListItems>
</soap:Body>
</soap:Envelope>
and the following soap response being returned from the service:
<?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>
<GetListItemsResponse xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<GetListItemsResult>
<listitems xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882'
xmlns:dt='uuid:C2F41010-65B3-11d1-A29F-00AA00C14882'
xmlns:rs='urn:schemas-microsoft-com:rowset'
xmlns:z='#RowsetSchema'>
<rs:data ItemCount="19">
<z:row ows_LinkFilename='[SENSITIVE DATA].xls'
ows_FileDirRef='278;#sites[SENSITIVE DATA]'
ows_FileLeafRef='278;#[SENSITIVE DATA].xls'
ows_MetaInfo='278;#Subject:SW| vti_parserversion:SR|12.0.0.6421 ContentTypeId:SW|0x0101006C2E647253A1074FB6079F08E5F2A395 _Author:SW|[SENSITIVE DATA] _Category:SW| vti_author:SR|[SENSITIVE DATA] _Comments:SW| vti_approvallevel:SR| vti_categories:VW| vti_cachedcustomprops:VX|vti_approvallevel vti_categories Subject vti_assignedto Keywords _Author _Category _Comments vti_assignedto:SR| Keywords:SW| vti_modifiedby:SR|[SENSITIVE DATA]'
ows__ModerationStatus='0' ows__Level='1'
ows_Last_x0020_Modified='278;#2010-06-29T18:55:38Z'
ows_ID='278' ows_owshiddenversion='53'
ows_UniqueId='278;#{0E51B2B1-89A7-4895-8ECC-0FE7D420470C}'
ows_FSObjType='278;#0'
ows_Created_x0020_Date='278;#2009-03-09T16:06:41Z'
ows_ProgId='278;#' ows_Modified='2010-06-29T18:55:37Z'
ows_FileRef='278;#sites[SENSITIVE DATA].xls'
ows_DocIcon='xls'
ows_Editor='262;#[SENSITIVE DATA]' />
</rs:data>
</listitems>
</GetListItemsResult>
</GetListItemsResponse>
</soap:Body>
</soap:Envelope>
Notice the z:row element has more fields included than I specified in my ViewFields criteria. I also set IncludeMandatoryColumns to false in my query options. Did I do something wrong or do I not understand how ViewFields really works as I thought it would limit the fields i.e. z:row attributes returned by the SharePoint list service.
I've been struggling with this issue, too. Tonight I found a solution that seems to work for me...hopefully it's helpful for others, as well.
The structure of your viewFields node is fine...
<viewFields>
<ViewFields xmlns="">
<FieldRef Name="LinkFilename" />
<FieldRef Name="FileDirRef" />
<FieldRef Name="FileLeafRef" />
</ViewFields>
</viewFields>
The problem is likely your field names. Apparently you have to use the internal names rather than the display names. One quick & easy way to determine the internal names is to go to the List Settings page for your list and hover over each column in the list. The browser's status bar will show a URL similar to this..
http://YOUR_SITE/_layouts/FldEdit.aspx?List=%7B12345678%2D1234%2D1234%2D1234%2D123456789012%7D&Field=INTERNAL_FIELD_NAME
Use the internal field name shown there for each of the fields you want to return from the GetListItems() service. For example,
<FieldRef Name="LinkFilename" />
....might need to be written as...
<FieldRef Name="Link_x0020_Filename" />
At least that's what it took to solve the problem for me. Hope that helps!
There is a ViewFieldsOnly property for the purpose (I've not experimented with it though).
When you specify fields by setting the ViewFields property, the query retrieves data for more than just those fields. To optimize performance, you can limit the data that is returned by the query by setting the ViewFieldsOnly property to true.
Without doing any of my own research, tt looks like you're generating the following XML node:
<viewFields>
<ViewFields xmlns="">
<FieldRef Name="LinkFilename" />
<FieldRef Name="FileDirRef" />
<FieldRef Name="FileLeafRef" />
</ViewFields>
</viewFields>
Do you mean to have your ViewFields element embedded in another viewFields element?

Resources