SharePoint WebService Application

Source: Internet
Author: User

SharePoint Comes With WebService, which is generally accessed across servers, because different websites on the same server can access data simply by raising the permission code.

Take reading a list across servers as an example, add "http: // <server-URL>/_ vti_bin/lists to the project. asmx and http: // <server-URL>/_ vti_bin/sitedata. asmx reference.

The two references are named listservice and sitedataservice respectively.

// Access the list library. an XML file is returned through the caml query. The dataset type is assigned directly without parsing.

Public static dataset getitems ()

{
Listservice. Lists listsws = new listservice. Lists ();
// Listsws. Credentials = system. net. credentialcache. defaultcredentials; // This sentence can be replaced by the next sentence in the compiling environment, but the next sentence must be used for cross-server applications.
Listsws. Credentials = new networkcredential (username, password, domain name );
Xmldocument Doc = new system. xml. xmldocument ();
Doc. loadxml ("<document> <query> <where> caml </where> </query> <viewfields/> <queryoptions/> </document> ");
Xmlnode listquery = Doc. selectsinglenode ("// query ");
Xmlnode listviewfields = Doc. selectsinglenode ("// viewfields ");
Xmlnode listqueryoptions = Doc. selectsinglenode ("// queryoptions ");

Guid G = getwebid ();

Xmlnode items = listsws. getlistitems ("listname", String. Empty, listquery, listviewfields, String. Empty, listqueryoptions, G. tostring ());

Nametable Nt = new system. xml. nametable ();
Xmlnamespacemanager nsmgr = new xmlnamespacemanager (NT );
Nsmgr. addnamespace ("W", "http://schemas.microsoft.com/office/word/2003/2/wordml ");
Xmlnode y = items. selectsinglenode ("*", nsmgr );
Dataset DS = new dataset ();
If (y! = NULL)
{
Xmlreader = new xmltextreader (Y. innerxml, xmlnodetype. element, null );
DS. readxml (xmlreader );
}
Return Ds;
}

Private Static guid getwebid ()
{
Sitedataservice. sitedata sitedataws = new sinopecsitedata. sitedata ();
Sitedataws. Credentials = new networkcredential (username, password, domain name );
Sitedataservice. _ swebmetadata webmetadata;
Sitedataservice. _ swebwithtime [] arrwebwithtime;
Sitedataservice. _ slistwithtime [] arrlistwithtime;
Sitedataservice. _ sfpurl [] arrurls;
String roles; string [] roleusers; string [] rolegroups;
Uint I = sitedataws. getweb (Out webmetadata, out arrwebwithtime, out arrlistwithtime, out arrurls, out roles, out roleusers, out rolegroups );
Guid G = new GUID (webmetadata. webid );
Return g;

}

Pay special attention to the following two points for the above Code:

1. Authentication. For web references, you can directly modify the address in webconfig. You can modify the authentication login information in the corresponding code. We recommend that you obtain the information in the configuration file for unified maintenance.

2. Parse XML.

 

The following lists the Mappings of referenced services.

WSS Web Services Web reference
Administration Service Http: // <server-URL: Port-number>/_ vti_adm/admin. asmx
Alerts Service Http: // <server-URL>/_ vti_bin/alerts. asmx
Document Workspace Service Http: // <server-URL>/_ vti_bin/DWS. asmx
Forms Service Http: // <server-URL>/_ vti_bin/forms. asmx
Imaging service Http: // <server-URL>/_ vti_bin/imaging. asmx
List Data Retrieval Service Http: // <server-URL>/_ vti_bin/dspsts. asmx
Lists Service Http: // <server-URL>/_ vti_bin/lists. asmx
Meetings Service Http: // <server-URL>/_ vti_bin/meetings. asmx
Permissions Service Http: // <server-URL>/_ vti_bin/permissions. asmx
Site Data Service Http: // <server-URL>/_ vti_bin/sitedata. asmx
Site service Http: // <server-URL>/_ vti_bin/sites. asmx
Users and groups Service Http: // <server-URL>/_ vti_bin/usergroup. asmx
Versions Service Http: // <server-URL>/_ vti_bin/versions. asmx
Views Service Http: // <server-URL>/_ vti_bin/views. asmx
Web Part pages Service Http: // <server-URL>/_ vti_bin/webpartpages. asmx
Webs Service Http: // <server-URL>/_ vti_bin/webs. asmx

 

 

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.