ಶೇರ್ಪಾಯಿಂಟ್ ಸೈಟ್ Lists.asmx ಗೆ Webreference ಸೇರಿಸಿ.
HTTP://ಅತಿಥೇಯ / _vti_bin / Lists.asmx
(ಶೇರ್ಪಾಯಿಂಟ್ ವರ್ಚುವಲ್ ಕೋಶವನ್ನು URL / _vti_bin / Lists.asmx
ನಿಮ್ಮ webservice ಕೆಳಗಿನ ವಿಧಾನಗಳು ಬರೆಯಲು.
ಖಾಸಗಿ data.DataTable GetDataTableFromWSS(, bool onlySchema)
{
ಸ್ಟ್ರಿಂಗ್ WssSiteUrl = HTTP://192.168.111.21;
ಸ್ಟ್ರಿಂಗ್ WssSiteUrl = ConfigurationSettings.AppSettings[“WssSiteUrl”];
WssSite.Lists ಪಟ್ಟಿಗಳನ್ನು = ಹೊಸ WssSite.Lists();
lists.Url = WssSiteUrl + “_vti_bin / Lists.asmx”;
lists.Credentials = System.Net.CredentialCache.DefaultCredentials;
lists.PreAuthenticate = ನಿಜವಾದ;
//you have to pass the List Name here
string CommandText = “Employee Info”;
XmlNode ListCollectionNode = lists.GetListCollection();
XmlElement List = (XmlElement)ListCollectionNode.SelectSingleNode(String.Format(“wss:ಪಟ್ಟಿ[@Title='{0}’]”, CommandText), NameSpaceMgr);
ವೇಳೆ (List == null)
{
throw new ArgumentException(String.Format(“The list {0} could not be found in the site {1}”, CommandText, WssSiteUrl));
}
string TechListName = List.GetAttribute(“ಹೆಸರು”);
data.DataTable result = new data.DataTable(“ಪಟ್ಟಿ”);
XmlNode ListInfoNode = lists.GetList(TechListName);
System.Text.StringBuilder fieldRefs = new System.Text.StringBuilder();
System.Collections.Hashtable DisplayNames = new System.Collections.Hashtable();
foreach (XmlElement Field in ListInfoNode.SelectNodes(“wss:Fields/wss:Field”, NameSpaceMgr))
{
ವೇಳೆ (Field.HasChildNodes)
{
foreach (XmlElement Fld in Field.SelectNodes(“wss:Fields/wss:Field”, NameSpaceMgr))
{
string FieldName = Fld.GetAttribute(“ಹೆಸರು”);
string FieldDisplayName = Fld.GetAttribute(“DisplayName”);
ವೇಳೆ (result.Columns.Contains(FieldDisplayName))
{
FieldDisplayName = FieldDisplayName + ” (” + FIELDNAME + “)”;
}
result.Columns.Add(FieldDisplayName, TypeFromField(Field));
fieldRefs.AppendFormat(“”, FIELDNAME);
DisplayNames.Add(FieldDisplayName, FIELDNAME);
}
}
ಬೇರೆ
{
string FieldName = Field.GetAttribute(“ಹೆಸರು”);
string FieldDisplayName = Field.GetAttribute(“DisplayName”);
ವೇಳೆ (result.Columns.Contains(FieldDisplayName))
{
FieldDisplayName = FieldDisplayName + ” (” + FIELDNAME + “)”;
}
result.Columns.Add(FieldDisplayName, TypeFromField(Field));
fieldRefs.AppendFormat(“”, FIELDNAME);
DisplayNames.Add(FieldDisplayName, FIELDNAME);
}
}
ವೇಳೆ (onlySchema) return result;
XmlElement fields = ListInfoNode.OwnerDocument.CreateElement(“ViewFields”);
fields.InnerXml = fieldRefs.ToString();
XmlNode ItemsNode = lists.GetListItems(TechListName, “”, null, fields, “1000000”, null);
// Lookup fields always start with the numeric ID, then ;# and then the string representation.
// We are normally only interested in the name, so we strip the ID.
System.Text.RegularExpressions.Regex CheckLookup = new System.Text.RegularExpressions.Regex(“^d ;#”);
foreach (XmlElement Item in ItemsNode.SelectNodes(“rs:data/z:row”, NameSpaceMgr))
{
data.DataRow newRow = result.NewRow();
foreach (data.DataColumn col in result.Columns)
{
ವೇಳೆ (Item.HasAttribute(“ows_” + (ಸ್ಟ್ರಿಂಗ್)DisplayNames[col.ColumnName]))
{
string val = Item.GetAttribute(“ows_” + (ಸ್ಟ್ರಿಂಗ್)DisplayNames[col.ColumnName]);
ವೇಳೆ (CheckLookup.IsMatch((ಸ್ಟ್ರಿಂಗ್)val))
{
string valString = val as String;
val = valString.Substring(valString.IndexOf(“#”) + 1);
}
// Assigning a string to a field that expects numbers or
// datetime values will implicitly convert them
newRow[col] = val;
}
}
result.Rows.Add(newRow);
}
return result;
}
// The following Function is used to Get Namespaces
private static XmlNamespaceManager _nsmgr;
private static XmlNamespaceManager NameSpaceMgr
{
get
{
ವೇಳೆ (_nsmgr == null)
{
_nsmgr = new XmlNamespaceManager(new NameTable());
_nsmgr.AddNamespace(“wss”, “HTTP://schemas.microsoft.com/sharepoint/soap/”);
_nsmgr.AddNamespace(“ರು”, “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(“z”, “#RowsetSchema”);
}
return _nsmgr;
}
}
private Type TypeFromField(XmlElement field)
{
switch (field.GetAttribute(“Type”))
{
case “DateTime”:
return typeof(DateTime);
case “Integer”:
return typeof(int);
case “Number”:
return typeof(float);
ಡೀಫಾಲ್ಟ್:
return typeof(ಸ್ಟ್ರಿಂಗ್);
}
}