Retrieve SharePoint List Item through Web Service

MyPortalSharePointITList.Lists listSvc = new MyPortalSharePointITList.Lists();
listSvc.Url = Util.GetLookupStringValue("DEFECTMGNTLIST", "URL");
System.Net.NetworkCredential cred = new System.Net.NetworkCredential(“User”, “Password”, "Domain");
System.Net.CredentialCache cache = new System.Net.CredentialCache();
cache.Add(new Uri(“http://servername/sites/abc”), “NTLM”, cred);
listSvc.Credentials = cache;

XmlDocument xmlDoc = new System.Xml.XmlDocument();
XmlNode ndQuery = xmlDoc.CreateNode(XmlNodeType.Element, "Query", "");
XmlNode ndViewFields = xmlDoc.CreateNode(XmlNodeType.Element, "ViewFields","");
XmlNode ndQueryOptions = xmlDoc.CreateNode(XmlNodeType.Element,"QueryOptions", "");
ndQueryOptions.InnerXml = "<IncludeAttachmentUrls>TRUE</IncludeAttachmentUrls>";
ndViewFields.InnerXml = "";
ndQuery.InnerXml = "";

XmlNode ndListItems = listSvc.GetListItems("{C0A1585E-176B-46AD-BCE4-35A1F3F63E2E}", null,
    ndQuery, ndViewFields, null, ndQueryOptions, null);

txtResult.Text = ndListItems.OuterXml;

Leave a Reply

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s