PANVEGA’s Blog

DotNet Development, SharePoint Customizing, Silverlight, MS Infrastructure and other tips and tricks

Query List Items from Lists.asmx Webservice GetListItems

Posted by PANVEGA on March 20, 2009

I created an application where I can retreive a Field ID from a Custon List Item with the Query GetListItem options.

A Query element containing the query that determines which records are returned and in what order, and that can be assigned to a System.Xml.XmlNode object, as in the following example.

  1. Call the GetListItem method
  2. Below you see the parameters from this method
  3. Create a new XmlNode call it “Query”
  4. Create a XmlElement call it “QueryOptions”
  5. Add you custom Query parameters you want
  6. I wanted to query the Item with the ID from the Application
[SoapDocumentMethodAttribute("http://schemas.microsoft.com/sharepoint/soap/GetListItems", RequestNamespace="http://schemas.microsoft.com/sharepoint/soap/", ResponseNamespace="http://schemas.microsoft.com/sharepoint/soap/", Use=SoapBindingUse.Literal, ParameterStyle=SoapParameterStyle.Wrapped)]
public XmlNode GetListItems (
    string listName,
    string viewName,
    XmlNode query,
    XmlNode viewFields,
    string rowLimit,
    XmlNode queryOptions,
    string webID
)

XmlNode ndQuery = xmlDoc.CreateNode(XmlNodeType.Element, “Query”, “”);
System.Xml.XmlElement queryOptions = xmlDoc.CreateElement(“QueryOptions”);

/*To specify values for the parameter elements (optional), assign CAML fragments to the InnerXml property of each element.*/
ndQuery.InnerXml = “<Where><Eq><FieldRef Name=\”ID\” />” +
“<Value Type=\”Text\”>” + id[0].ToString() + “</Value></Eq></Where>”;
viewFields.InnerXml = “<FieldRef Name=\”RequiredFiled\” />”;
queryOptions.InnerXml = “”;

More Informations:

http://msdn.microsoft.com/en-us/library/lists.lists.getlistitems.aspx

http://msdn.microsoft.com/en-us/library/ms471093.aspx

http://blogs.msdn.com/sharepoint/archive/2007/03/25/retrieving-sharepoint-list-items-attachment-urls-using-lists-web-service.aspx

Thats it

Good Luck

Advertisements

2 Responses to “Query List Items from Lists.asmx Webservice GetListItems”

  1. sara said

    Nice work,
    Try this too,
    SharePoint List Web Service GetListItems

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: