Retreiving daim ntawv teev cov ntsiab lus los ntawm WebService nyob SharePoint 2003

Ntxiv ntawm webreference rau cov Lists.asmx hauv sharepoint qhov chaw.

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

sau rau hauv qab no kev nyob hauv koj lub webservice.

lwm cov ntaub ntawv.DataTable GetDataTableFromWSS(bool onlySchema)
{
kaj WssSiteUrl = http://192.168.111.21;
kaj WssSiteUrl = ConfigurationSettings.AppSettings[“WssSiteUrl”];
WssSite.Lists npe = WssSite.Lists tshiab();
teev.Url = WssSiteUrl + “_vti_bin/Lists.asmx”;
teev.Peev xwm = System.Net.CredentialCache.DefaultCredentials;

teev.PreAuthenticate = tseeb;
//koj yuav tsum xeem dhau daim ntawv teev npe no
kaj CommandText = “Tus neeg ua num Info”;
XmlNode ListCollectionNode = npe.GetListCollection();
XmlElement sau = (XmlElement)ListCollectionNode.SelectSingleNode(String.Format(“wss:Sau[@Title ='{0}’]”, CommandText), NameSpaceMgr);
Yog hais tias (Daim ntawv teev == thov)
{
pov ArgumentException tshiab(String.Format(“Daim ntawv {0} yuav tsis muaj nyob rau hauv lub site {1}”, CommandText, WssSiteUrl));
}
kaj TechListName = List.GetAttribute(“Lub npe”);
cov ntaub ntawv.Kev raug DataTable = tshiab ntawm cov ntaub ntawv.DataTable(“sau”);
XmlNode ListInfoNode = npe.GetList(TechListName);
System.Text.StringBuilder fieldRefs = System.Text.StringBuilder tshiab();
System.Collections.Hashtable DisplayNames = System.Collections.Hashtable tshiab();
foreach (XmlElement daim teb nyob rau hauv ListInfoNode.SelectNodes(“wss:Liaj teb/wss:Teb”, NameSpaceMgr))
{
Yog hais tias (Field.HasChildNodes)
{
foreach (XmlElement Fld nyob Field.SelectNodes(“wss:Liaj teb/wss:Teb”, NameSpaceMgr))
{
kaj FieldName = Fld.GetAttribute(“Lub npe”);
kaj FieldDisplayName = Fld.GetAttribute(“DisplayName”);
Yog hais tias (tshwm sim.Columns.Contains(FieldDisplayName))
{
FieldDisplayName = FieldDisplayName + ” (” + FieldName + “)”;
}
tshwm sim.Columns.Add(FieldDisplayName, TypeFromField(Teb));
fieldRefs.AppendFormat(“”, FieldName);
DisplayNames.Add(FieldDisplayName, FieldName);
}
}
lwm yam
{
kaj FieldName = Field.GetAttribute(“Lub npe”);
kaj FieldDisplayName = Field.GetAttribute(“DisplayName”);
Yog hais tias (tshwm sim.Columns.Contains(FieldDisplayName))
{
FieldDisplayName = FieldDisplayName + ” (” + FieldName + “)”;
}
tshwm sim.Columns.Add(FieldDisplayName, TypeFromField(Teb));
fieldRefs.AppendFormat(“”, FieldName);
DisplayNames.Add(FieldDisplayName, FieldName);
}
}
Yog hais tias (onlySchema) rov qab tshwm sim;
XmlElement teb = ListInfoNode.OwnerDocument.CreateElement(“ViewFields”);
teb.InnerXml = fieldRefs.ToString();
XmlNode ItemsNode = npe.GetListItems(TechListName, “”, thov, liaj teb, “1000000”, thov);
// Lookup teb ib txwm pib nrog tus ID numeric, ces ;# thiab ces rau cov hlua sawv cev.
// Peb yeej nquag tsuas xav tau lub npe, li ntawd, peb strip tus ID.
System.Text.RegularExpressions.Regex CheckLookup = System.Text.RegularExpressions.Regex tshiab(“^ d ;#”);

foreach (XmlElement yam nyob rau hauv ItemsNode.SelectNodes(“Reye:cov ntaub ntawv/z:tshais”, NameSpaceMgr))
{
cov ntaub ntawv.DataRow newRow = ntog.NewRow();
foreach (cov ntaub ntawv.DataColumn col hauv no.Txhua)
{
Yog hais tias (Item.HasAttribute(“ows_” + (hlua)DisplayNames[col.ColumnName]))
{
kaj val = Item.GetAttribute(“ows_” + (hlua)DisplayNames[col.ColumnName]);
Yog hais tias (CheckLookup.IsMatch((hlua)val))
{
kaj valString = val li txoj hlua;
val = valString.Substring(valString.IndexOf(“#”) + 1);
}
// Muab ib txoj hlua rau ib daim teb uas tooj expects los yog
// datetime qhov tseem ceeb yuav implicitly hloov ua lwm yam xwb
newRow[col] = val;
}
}
tshwm sim.Rows.Add(newRow);
}
rov qab tshwm sim;
}

// Cov nuj nqi nram qab no yog siv kom tau Namespaces

lwm yam zoo li qub XmlNamespaceManager _nsmgr;
lwm yam zoo li qub XmlNamespaceManager NameSpaceMgr
{
txais
{
Yog hais tias (_nsmgr == thov)
{
_nsmgr = XmlNamespaceManager tshiab(NameTable tshiab());
_nsmgr.AddNamespace(“wss”, “http://schemas.Microsoft.com/sharepoint/soap/”);
_nsmgr.AddNamespace(“s”, “uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882”);
_nsmgr.AddNamespace(“DT”, “uuid:1-A29F C2F41010-65B3 - 11d-00AA00C14882”);
_nsmgr.AddNamespace(“Reye”, “urn:schemas-microsoft-com:rowset”);
_nsmgr.AddNamespace(“z”, “#RowsetSchema”);

}
rov qab mus _nsmgr;
}
}
lwm hom TypeFromField(XmlElement teb)
{
hloov (teb.GetAttribute(“Hom”))
{
rooj plaub no “DateTime”:
rov qab mus typeof(DateTime);
rooj plaub no “Integer”:
rov qab mus typeof(rau cov menyuam);
rooj plaub no “Naj npawb”:
rov qab mus typeof(ntab);
neej ntawd:
rov qab mus typeof(hlua);
}
}

4 Comments rau Retreiving daim ntawv teev txheej ntawm WebService nyob SharePoint 2003

sau ntawv cia

Koj siv tau qhov cim npe no HTML

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