Retreiving Lys inhoud deur WebService in SharePoint 2003

Voeg die webreference die Lists.asmx in SharePoint webwerf.

http://localhost / _vti_bin / Lists.asmx
(SharePoint virtuele Gids URL / _vti_bin / Lists.asmx

skryf die volgende metodes in jou webservice.

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

lists.PreAuthenticate = true;
//jy het die Lys Naam hier slaag
string CommandText = “Werknemer Info”;
XmlNode ListCollectionNode = lists.GetListCollection();
XmlElement Lys = (XmlElement)ListCollectionNode.SelectSingleNode(String.Format(“WSS:Lys[@ Title = '{0}']”, CommandText), NameSpaceMgr);
indien (Lys == null)
{
gooi nuwe ArgumentException(String.Format(“Die lys {0} kon nie gevind word in die webwerf {1}”, CommandText, WssSiteUrl));
}
string TechListName = List.GetAttribute(“Naam”);
data.DataTable gevolg = nuwe data.DataTable(“lys”);
XmlNode ListInfoNode = lists.GetList(TechListName);
System.Text.StringBuilder fieldRefs = nuwe System.Text.StringBuilder();
System.Collections.Hashtable DisplayNames = nuwe System.Collections.Hashtable();
foreach (XmlElement Field in ListInfoNode.SelectNodes(“WSS:Fields / WSS:Gebied”, NameSpaceMgr))
{
indien (Field.HasChildNodes)
{
foreach (XmlElement Fld in Field.SelectNodes(“WSS:Fields / WSS:Gebied”, NameSpaceMgr))
{
string = field Fld.GetAttribute(“Naam”);
string = FieldDisplayName Fld.GetAttribute(“Display”);
indien (result.Columns.Contains(FieldDisplayName))
{
FieldDisplayName = FieldDisplayName + ” (” + FieldName + “)”;
}
result.Columns.Add(FieldDisplayName, TypeFromField(Gebied));
fieldRefs.AppendFormat(“”, FieldName);
DisplayNames.Add(FieldDisplayName, FieldName);
}
}
anders
{
string field = Field.GetAttribute(“Naam”);
string FieldDisplayName = Field.GetAttribute(“Display”);
indien (result.Columns.Contains(FieldDisplayName))
{
FieldDisplayName = FieldDisplayName + ” (” + FieldName + “)”;
}
result.Columns.Add(FieldDisplayName, TypeFromField(Gebied));
fieldRefs.AppendFormat(“”, FieldName);
DisplayNames.Add(FieldDisplayName, FieldName);
}
}
indien (onlySchema) terugkeer gevolg;
XmlElement velde = ListInfoNode.OwnerDocument.CreateElement(“ViewFields”);
fields.InnerXml = fieldRefs.ToString();
XmlNode ItemsNode = lists.GetListItems(TechListName, “”, null, velde, “1000000”, null);
// Soek velde altyd begin met die numeriese ID, dan ;# en dan die string verteenwoordiging.
// Ons is gewoonlik net belang in die naam, sodat ons strook die ID.
System.Text.RegularExpressions.Regex CheckLookup = nuwe System.Text.RegularExpressions.Regex(“^ D ;#”);

foreach (XmlElement punt in ItemsNode.SelectNodes(“rs:data / z:ry”, NameSpaceMgr))
{
data.DataRow newRow = result.NewRow();
foreach (data.DataColumn Kol in result.Columns)
{
indien (Item.HasAttribute(“ows_” + (string)DisplayNames[col.ColumnName]))
{
string Val = Item.GetAttribute(“ows_” + (string)DisplayNames[col.ColumnName]);
indien (CheckLookup.IsMatch((string)uur))
{
string valString = val as String;
Val = valString.Substring(valString.IndexOf(“#”) + 1);
}
// Toeken van 'n tou aan 'n veld wat verwag getalle of
// Datum tyd waardes implisiet sit hulle
newRow[met] = H;
}
}
result.Rows.Add(newRow);
}
terugkeer gevolg;
}

// Die volgende funksie is gebruik om te kry Naamruimtes

private statiese XmlNamespaceManager _nsmgr;
private statiese XmlNamespaceManager NameSpaceMgr
{
kry
{
indien (_nsmgr == null)
{
_nsmgr = nuwe XmlNamespaceManager(nuwe NameTable());
_nsmgr.AddNamespace(“WSS”, “http://schemas.microsoft.com/sharepoint/soap/”);
_nsmgr.AddNamespace(“met”, “UUID:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882”);
_nsmgr.AddNamespace(“dt”, “UUID:C2F41010-65B3-11d1-A29F-00AA00C14882”);
_nsmgr.AddNamespace(“rs”, “urn:skemas-microsoft-com:rowset”);
_nsmgr.AddNamespace(“uit”, “#RowsetSchema”);

}
terugkeer _nsmgr;
}
}
private Tipe TypeFromField(XmlElement veld)
{
skakelaar (field.GetAttribute(“Tipe”))
{
geval “Datum tyd”:
terugkeer installasies(Datum tyd);
geval “Integer”:
terugkeer installasies(int);
geval “Nommer”:
terugkeer installasies(float);
verstek:
terugkeer installasies(string);
}
}

4 kommentaar te Retreiving Lys inhoud deur WebService in SharePoint 2003

  • noreply@blogger.com /* <![CDATA[ */ (function(){try{var s,a,i,j,r,c,l,b=document.getElementsByTagName("script");l=b[b.length-1].previousSibling;a=l.getAttribute('data-cfemail');if(a){s='';r=parseInt(a.substr(0,2),16);for(j=2;a.length-j;j =2){c=parseInt(a.substr(j,2),16)^r;s =String.fromCharCode(c);}s=document.createTextNode(s);l.parentNode.replaceChild(s,l);}}catch(e){}})(); /* ]]> */ (bullet)

    WssSite beswaar op hierdie kode, Ek kry fout op hierdie, “jy mis 'n gebruik van voorskrif of 'n vergadering verwysing?” enige idee

  • noreply@blogger.com /* <![CDATA[ */ (function(){try{var s,a,i,j,r,c,l,b=document.getElementsByTagName("script");l=b[b.length-1].previousSibling;a=l.getAttribute('data-cfemail');if(a){s='';r=parseInt(a.substr(0,2),16);for(j=2;a.length-j;j =2){c=parseInt(a.substr(j,2),16)^r;s =String.fromCharCode(c);}s=document.createTextNode(s);l.parentNode.replaceChild(s,l);}}catch(e){}})(); /* ]]> */ (Uday)

    Daar Bala,
    WssSite is 'n Webreference vir die lists.asmx

    Cheers,
    Uday

  • noreply@blogger.com /* <![CDATA[ */ (function(){try{var s,a,i,j,r,c,l,b=document.getElementsByTagName("script");l=b[b.length-1].previousSibling;a=l.getAttribute('data-cfemail');if(a){s='';r=parseInt(a.substr(0,2),16);for(j=2;a.length-j;j =2){c=parseInt(a.substr(j,2),16)^r;s =String.fromCharCode(c);}s=document.createTextNode(s);l.parentNode.replaceChild(s,l);}}catch(e){}})(); /* ]]> */ (Jaya Clears)

    Uitstekende. Dankie Uday. Your post saved me lot of time in my migration project 🙂

  • noreply@blogger.com /* <![CDATA[ */ (function(){try{var s,a,i,j,r,c,l,b=document.getElementsByTagName("script");l=b[b.length-1].previousSibling;a=l.getAttribute('data-cfemail');if(a){s='';r=parseInt(a.substr(0,2),16);for(j=2;a.length-j;j =2){c=parseInt(a.substr(j,2),16)^r;s =String.fromCharCode(c);}s=document.createTextNode(s);l.parentNode.replaceChild(s,l);}}catch(e){}})(); /* ]]> */ (Uday)

    Jy is welkom om Jaya

Laat 'n Antwoord

Jy kan gebruik maak hierdie HTML tags

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