Mostrando entradas con la etiqueta Web Services. Mostrar todas las entradas
Mostrando entradas con la etiqueta Web Services. Mostrar todas las entradas

jueves, 7 de marzo de 2013

SharePoint 2010 Web Services

Web ServiceDescription
WebSvcAdminProvides methods for managing a deployment of SharePoint Foundation, such as for creating or deleting sites.
WebSvcAlertsProvides methods for working with alerts for list items in a SharePoint Foundation site.
WebSvcAuthenticationProvides classes for logging on to a SharePoint Foundation site that is using forms-based authentication.
WebSvcBdcAdminServiceProvides methods that can be used to import and export Business Data Connectivity Services (BDC) models.
WebSvcCellStorageEnables client computers to synchronize changes made to shared files that are stored on a server.
WebSvcCopyProvides methods for copying items between locations in SharePoint Foundation.
WebSvcdiagnosticsEnables client computers to submit diagnostic reports that describe application errors that occur on the client.
WebSvcDspStsProvides a method for performing queries against lists in SharePoint Foundation.
WebSvcDWSProvides methods for managing Document Workspace sites and the data they contain.
WebSvcFormsProvides methods for returning forms used in the user interface when working with the contents of a list.
WebSvcImagingProvides methods that enable you to create and manage picture libraries.
WebSvcListsProvides methods for working with lists and list data.
WebSvcMeetingsProvides methods that enable you to create and manage Meeting Workspace sites.
WebSvcPeopleProvides methods for working with security groups.
WebSvcPermissionsProvides methods for working with the permissions for a site or list.
WebSvcSharedAccessProvides a method that determines whether a document is being coauthored.
WebSvcsharepointemailwsProvides methods for remotely managing distribution groups.
WebSvcSiteDataProvides methods that return metadata or list data from sites or lists in SharePoint Foundation.
WebSvcsitesProvides methods for working with Web sites.
WebSvcspsearchProvides methods for remotely performing searches within a SharePoint Foundation deployment.
WebSvcUserGroupProvides methods for working with users and groups.
WebSvcVersionsProvides methods for managing file versions.
WebSvcviewsProvides methods for working with list views.
WebSvcwebpartpagesProvides methods to send and retrieve Web Part information to and from Web services.
WebSvcWebsProvides methods for working with Web sites and content types.
Web ServiceDescription
WebSvcOrganizationProfileServiceProvides an interface for remote clients to read and create organization profiles.
WebSvcPublishedLinksServiceProvides a published links interface for remote clients to read and create published links.
WebSvcSearchProvides methods that can be used to remotely query SharePoint Server search.
WebSvcSocialDataServiceProvides an interface for remote clients to read, create, and manipulate social data.
WebSvcUserProfileChangeServiceProvides a user profile interface for remote clients to read and create user profiles.
WebSvcUserProfileServiceProvides a user profile interface for remote clients to read and create user profiles.
The following services are reserved for internal use and are not intended to be used in your code:
  • BdcAdminService.svc
  • BdcRemoteExecutionService.svc
  • BDCResolverPickerService.svc
  • bdcservice.svc
  • client.svc
  • securitytoken.svc
  • spclaimproviderwebservice.svc
  • topology.svc
  • windowstokencache.svc

SharePoint 2010 – Web Services

SharePoint Web Services provides is a good feature that allows us to access or change the SharePoint items remotely. We can use the Web Services to add more power to our application.
Following are the core features of SharePoint Web Services:
· Foundation and Server Web Services
· More Interoperability compared with Server Object Model
· Above 25 Web Services
· Manage Sites, Lists, Libraries, and Picture Libraries etc.
· Run queries against the server
· Custom Web Service creation possible
The following table contains some of the web services inside SharePoint 2010.
ServiceDescriptionASMX
WebSvcAdminCreation and Deletion of sitesAdmin.asmx
WebSvcListsList Management serviceLists.asmx
WebSvcAlertsList Item Events serviceAlerts.asmx
WebSvcAuthenticationAuthentication based serviceAuthentication.asmx
WebSvcsitesWeb sites management serviceSites.asmx
WebSvcspsearchSearching serviceSearch.asmx
A more detailed list can be found here:
http://msdn.microsoft.com/en-us/library/ee705814.aspx
How to find the url of a Service?
The url of a service can be located inside _vti_bin folder of the site or site collection. Each site or site collection will be having this folder with all the web services inside it with .asmx extension.
Example: To use the search service use the following url:
http://YOURPCNAME/_vti_bin/search.asmx
clip_image002
Using http://appes-pc/_vti_bin/Lists.asmx
clip_image004
Adding Reference to Project
Now we can try adding reference to the service inside Visual Studio application. Create a new Ordinary Console Application (please note that we are not using SharePoint Console Application)
clip_image006
Now we need to Add Web Reference. In Visual Studio 2010 this option is available under the Add Service Reference option as shown below.
clip_image008
In the appearing dialog click the Advanced button.
clip_image010
In the next dialog, choose Add Web Reference option.
clip_image012
You will get the following dialog. This dialog is suitable for adding web service references.
clip_image014
Enter the url of the Lists.asmx as shown above. You need to replace the pc name with yours.
Set a Web reference name in the second highlighted box. This serves as the namespace.
Click the Add Reference button and your proxy class and related classes will be ready within a while. Inside the Program.cs enter the namespace and you can see the classes inside it as shown below:
clip_image016
Invoking the Proxy Class
Our class of interest is the Lists proxy. You can create an instance of it using the following code:
SPReference.Lists client = new SPReference.Lists();

Setting Credentials
Whenever we open a SharePoint site (without anonymous login enabled) the site will be prompting with user credentials. As we are invoking through web service the prompt dialog won’t be working. We need to pass the credentials using the property named Credentials.
client.Credentials = new NetworkCredential("appes", "password"); / // using System.Net;
Getting Reference to a List
We can try getting a reference to the Manager List inside our site. The Managers list contains items with columns:
· Title
· Name
· Address
clip_image018
Use the following code to fetch the data and display it to the console:
SPReference.Lists client = new SPReference.Lists();
client.Credentials = new NetworkCredential("appes", "PWD");
System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
System.Xml.XmlElement viewFields = xmlDoc.CreateElement("ViewFields");
viewFields.InnerXml = "<FieldRef Name=\"Title\" />" +
"<FieldRef Name=\"Name\" />" +
"<FieldRef Name=\"Address\" />";
XmlNode listItems = client.GetListItems("Manager", null, null, viewFields, null, null, null);
foreach (XmlNode node in listItems)
if (node.Name == "rs:data")
for (int f = 0; f < node.ChildNodes.Count; f++)
{
if (node.ChildNodes[f].Name == "z:row")
{
string title = node.ChildNodes[f].Attributes["ows_Title"].Value;
string name = node.ChildNodes[f].Attributes["ows_Name"].Value;
string address = node.ChildNodes[f].Attributes["ows_Address"].Value;
Console.WriteLine(title + " " + name + " " + address);
}
}
Console.ReadKey(false);
On executing the application we can see the following result:
clip_image020
Following are the steps involved in getting list item data:
1. Create List Proxy client
2. Set Credentials
3. Set the View Columns
4. Invoke GetListItems() method
5. Iterate through the nodes
6. Get value of node having name z:row
Note
Using web services, xml is used to represent the data. For advanced programming using properties please refer to the Server Object Model and SharePoint LINQ articles.
References
http://msdn.microsoft.com/en-us/library/ee705814.aspx
http://msdn.microsoft.com/en-us/library/ms583494.aspx
http://msdn.microsoft.com/en-us/library/lists.lists.getlistitems(v=office.12).aspx
Summary
In this article we have seen the Web Services feature of SharePoint 2010. It provides the flexibility of interoperability compared with the Server Object Model. Developers can access and manage SharePoint site from non .Net platforms like Java. The attached source code contains the example we discussed.