How SharePoint invokes the WebService action list

Source: Internet
Author: User
Tags reference port number

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.