Retreiving List Content through WebService in SharePoint 2003

Add the webreference to the Lists.asmx in sharepoint site.

http://localhost/_vti_bin/Lists.asmx
(SharePoint virtual Directory URL/_vti_bin/Lists.asmx

write the following methods in your webservice.

private data.DataTable GetDataTableFromWSS(bool onlySchema)
{
string WssSiteUrl = http://192.168.111.21;
string WssSiteUrl = ConfigurationSettings.AppSettings[“WssSiteUrl”];
WssSite.Lists lists = new WssSite.Lists();
lists.Url = WssSiteUrl + “_vti_bin/Lists.asmx”;
lists.Credentials = System.Net.CredentialCache.DefaultCredentials;

lists.PreAuthenticate = true;
//vos have ut transire in List here Name
CommandText string = “Aliquam Info”;
XmlNode ListCollectionNode lists.GetListCollection =();
XmlElement List = (XmlElement)ListCollectionNode.SelectSingleNode(String.Format(“WSS:List[Title @ = '{0}’]”, CommandText), NameSpaceMgr);
si (List est nullum, ==)
{
novam ArgumentException(String.Format(“Elenchus, {0} nec invenitur in area {1}”, CommandText, WssSiteUrl));
}
TechListName List.GetAttribute string =(“Nomen”);
data.DataTable result = new data.DataTable(“album”);
XmlNode ListInfoNode lists.GetList =(TechListName);
System.Text.StringBuilder fieldRefs System.Text.StringBuilder = new();
System.Collections.Hashtable DisplayNames System.Collections.Hashtable = new();
foreach (XmlElement Field in ListInfoNode.SelectNodes(“WSS:Fields / WSS:Field”, NameSpaceMgr))
{
si (Field.HasChildNodes)
{
foreach (XmlElement in III Field.SelectNodes(“WSS:Fields / WSS:Field”, NameSpaceMgr))
{
FieldName Fld.GetAttribute string =(“Nomen”);
FieldDisplayName Fld.GetAttribute string =(“DISPLAYNAME”);
si (result.Columns.Contains(FieldDisplayName))
{
FieldDisplayName FieldDisplayName = + ” (” + FieldName + “)”;
}
result.Columns.Add(FieldDisplayName, TypeFromField(Field));
fieldRefs.AppendFormat(“”, FieldName);
DisplayNames.Add(FieldDisplayName, FieldName);
}
}
aliud
{
FieldName Field.GetAttribute string =(“Nomen”);
FieldDisplayName Field.GetAttribute string =(“DISPLAYNAME”);
si (result.Columns.Contains(FieldDisplayName))
{
FieldDisplayName FieldDisplayName = + ” (” + FieldName + “)”;
}
result.Columns.Add(FieldDisplayName, TypeFromField(Field));
fieldRefs.AppendFormat(“”, FieldName);
DisplayNames.Add(FieldDisplayName, FieldName);
}
}
si (onlySchema) reditum inde;
XmlElement agros ListInfoNode.OwnerDocument.CreateElement =(“ViewFields”);
fields.InnerXml fieldRefs.ToString =();
XmlNode ItemsNode lists.GetListItems =(TechListName, “”, null, Agros, “1000000”, null);
// Semper satus per agros Lookup numericam ID, tunc ;# et tunc filum repraesentationem.
// Nos plerumque interested in solo nomine, ut spoliarent ID.
System.Text.RegularExpressions.Regex CheckLookup System.Text.RegularExpressions.Regex = new(“ D ;#”);

foreach (Item in XmlElement ItemsNode.SelectNodes(“rs:data / z:row”, NameSpaceMgr))
{
data.DataRow newRow result.NewRow =();
foreach (data.DataColumn col in result.Columns)
{
si (Item.HasAttribute(“ows_” + (string)DisplayNames[col.ColumnName]))
{
val Item.GetAttribute string =(“ows_” + (string)DisplayNames[col.ColumnName]);
si (CheckLookup.IsMatch((string)h))
{
val valString string = as String;
Lorem = valString.Substring(valString.IndexOf(“#”) + 1);
}
// Nervo, qui expectat agrum ut a magna a numeris
// et convertam eos implicite datetime values
newRow[cum] H =;
}
}
result.Rows.Add(newRow);
}
reditum inde;
}

// Haec est adsuesco assuesco ut a Function Spatia nominalia

private static XmlNamespaceManager _nsmgr;
private static XmlNamespaceManager NameSpaceMgr
{
get
{
si (== NULL _nsmgr)
{
_nsmgr XmlNamespaceManager = new(NameTable new());
_nsmgr.AddNamespace(“WSS”, “http://schemas.microsoft.com/sharepoint/soap/”);
_nsmgr.AddNamespace(“s”, “uuid:BDC6E3F0-6DA3-11d1 A2A3-00AA00C14882-”);
_nsmgr.AddNamespace(“dt”, “uuid:C2F41010-65B3-11d1 A29F--00AA00C14882”);
_nsmgr.AddNamespace(“rs”, “urn:schemas-Microsoft com-:rowset”);
_nsmgr.AddNamespace(“cum”, “#RowsetSchema”);

}
revertatur _nsmgr;
}
}
Type private TypeFromField(XmlElement agri)
{
switch (field.GetAttribute(“Type”))
{
case “DateTime”:
revertatur typeof(DateTime);
case “Integer”:
revertatur typeof(int);
case “Number”:
revertatur typeof(float);
default:
revertatur typeof(string);
}
}

4 comments to Retreiving List Content through WebService in SharePoint 2003

Aliquam pharetra

Vos can utor his HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>