Chapter 30
Additional Web Services


IN THIS CHAPTER


This section of the book has gone into a lot of detail regarding many of the web services that expose and extend the functionality of Microsoft Office SharePoint Server (MOSS). This chapter provides an overview of a few remaining web services that the authors feel are important enough to warrant attention in this book but that aren’t large enough to fit in their own chapter.

This chapter provides an overview of the Spell Checker Web Service, the Alerts Web Service, and the Versions Web Service.

Using the Spell Checker Web Service

The Spell Checker Web Service is one of the services that SharePoint provides that is extremely useful, can add a lot of useful functionality to any application, and is also one of the most underrated services in the entire SharePoint web services arsenal.

You can find the service at the root of a MOSS web application, for example, http://server/_vti_bin/spellcheck.asmx. This service has a single method called SpellCheck that examines an array of strings and returns a set of results indicating where all of the spell-checking failures have occurred in each of the strings.

These results can be used when implementing a rich text editor with the offset information being provided by the service allowing the client application to highlight misspelled words.

The code in Listing 30.1 illustrates how to invoke the SpellCheck method and render the results from the method call.

Listing 30.1. Using the Spell Checker Web Service

image

The output of the application will look similar to the output shown in Figure 30.1.

Figure 30.1. Using the Spell Checker Web Service.

image

The Spell Checker Web Service works without regard for relative site context, so it can be used within your own custom web applications, custom Web Parts, and even within your smart client or Windows Presentation Foundation (WPF)/Vista applications.

Using the Alerts Web Service

The Alerts Web Service works relative to the site from which it was accessed. This means that the information available to the Alerts Web Service from http://server/site1/_vti_bin/alerts.asmx is not the same data that is available from http://server/site2/_vti_bin/alerts.asmx. The main purpose of the Alerts Web Service is to retrieve the alerts that belong to the calling user. In other words, the credentials supplied for the web service call are the same credentials used to identify the user requesting his alerts.

Fortunately, the Alerts Web Service is one of the few SharePoint services that returns structured data instead of Extensible Markup Language (XML) nodes or XML strings. To keep things interesting, the sample shown in Listings 30.2 and 30.3 is actually some Extensible Application Markup Language (XAML) for a WPF application and its associated code-behind. This not only shows the power of WPF data binding, but also how amazingly helpful it is when web services return structured data instead of free-form XML chunks.

Don’t worry if you don’t understand all of the finer details of the data binding—the point is that you can consume these web services from any application from a console application to a web application to a WPF application.

Listing 30.2. Window1.xaml for an Alerts Viewing Application

image

image

The code in Listing 30.3 invokes the GetAlerts method and sets the data context of the main grid to the returned value. WPF takes care of the rest.

Listing 30.3. Window.xaml.cs for an Alerts Viewing Application

image

When you run the application in Listings 30.2 and 30.3 on Windows Vista, the result looks similar to the screenshot in Figure 30.2. It isn’t tremendously pretty now, but with a few cleverly placed styles, it could be made into a professional looking application.

Figure 30.2. Viewing alerts and alert details.

image

Using the Versions Web Service

The Versions Web Service is another extremely powerful and often underrated web service. It gives developers the ability to query the version history of a given file. This is extremely powerful considering the new enhanced support within SharePoint for major and minor versions, workflows, and so on.

The version information returned from the web service not only gives you the version history of the file, but it provides you the uniform resource locator (URL) through which you can access previous versions of the file. This web service is one of the only places that SharePoint exposes that kind of information to the developer.

The code in Listing 30.4 shows how to use the Versions Web Service.

Listing 30.4. Using the Versions Web Service

image

When you compile and run the console application from Listing 30.4, the output should look similar to the output shown in Figure 30.3.

Figure 30.3. Using the Versions Web Service.

image

Summary

This chapter provided an overview of a few of the remaining web services not covered by previous chapters. SharePoint provides an incredible extension point and integration point for applications through its object model and through its extensive web service support. The Spell Checker, Alerts, and Versions Web Services are just a few of the many important web services available to SharePoint developers.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset