In the use of SharePoint, there is often a need for system integration such operations, we as a SharePoint development, we need to provide interfaces to other systems, and SharePoint provided by the WebService is very good to provide such a feature, we have a simple understanding, To manipulate a list by providing WebService through SharePoint
Steps:
1. First, create a new console program and add WebService references
Address Http://<site>/_vti_bin/Lists.asmx
<site> for the site's address, including the port number
2. Reference-right-add service reference (Figure 1) – Advanced – Add Web Reference –url place to fill WebService address (Figure 2)
(Figure 1)
(Figure 2)
3. Get list information
try
{
WebServices1.Lists listService = new GetListTest.WebServices1.Lists();
listService.Credentials = System.Net.CredentialCache.DefaultCredentials;
XmlNode ndLists = listService.GetList("Test");//参数列表名,String类型
Console.Write(ndLists.OuterXml);
}
catch (Exception ex)
{
Console.Write(ex.Message);
}
4. Get list information results
5. Get ListItem information
//获取ListItem信息
WebServices1.Lists listService = new GetListTest.WebServices1.Lists();
listService.Credentials = System.Net.CredentialCache.DefaultCredentials;
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 = ""; //Query设置
ndViewFields.InnerXml = ""; //视图设置
ndQuery.InnerXml = ""; //Caml语句
try
{
XmlNode ndListItems = listService.GetListItems("Test", null, ndQuery, ndViewFields, "1", ndQueryOptions, null); //获取列表内容
Console.Write(ndListItems.OuterXml); //输出获取的Xml内容
}
catch (System.Web.Services.Protocols.SoapException ex)
{
}
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/web/sharepoint/
6. Obtain ListItem Information results