Programming Research Services
This section examines how to build research services for Word and other Office applications. Word has a task pane called the Research task pane that enables you to enter a search term and search various sources for that search term. Figure 6-6 shows the Research task pane.
Figure 6-6. The Research task pane.

Getting Started with Research Services
After you have downloaded and installed the Research Service Development Extras Toolkit, launch Visual Studio 2003 and choose New Project from the File menu. Select Visual C# Projects in the Project Types window and click the Research Service Wrapper in the Templates window, as shown in Figure 6-7.
Figure 6-7. Selecting the Research Service Wrapper project.

Figure 6-8. Step 1 of the ASP.NET Research Services Wizard.

Figure 6-9. Step 2 of the ASP.NET Research Services Wizard.

A Simple Research Service
The wizard has created a project for our Author Information research service. Within the project is a file called ResearchService.asmx.cs. Edit this file to produce the result shown in Listing 6-1. If the user searches for the strings "Eric Carter" or "Eric Lippert," the service will send back information listing all the authors of this book.
Listing 6-1. The ResearchService.asmx.cs File
using System;
using Microsoft.Samples.Office.ResearchService;
using Microsoft.Samples.Office.ResearchService.Registration;
using Microsoft.Samples.Office.ResearchService.Query;
namespace ResearchService
{
public class ResearchService : ResearchWebService
{
public override RegistrationResponse Registration(
RegistrationRequest request)
{
return new RegistrationResponse();
}
public override QueryResponse Query(QueryRequest request)
{
QueryResponse response = new QueryResponse();
if (request.QueryText == "Eric Carter" ||
request.QueryText == "Eric Lippert")
{
DocumentResponseWriter responseWriter;
responseWriter = new DocumentResponseWriter();
responseWriter.WriteItem("Eric Carter", "One of the authors of this
book, a Lead Developer at Microsoft Corporation.");
responseWriter.WriteItem("Eric Lippert", "One of the authors of this
book, a Developer at Microsoft Corporation.");
response.WriteResponse(responseWriter);
}
return response;
}
}
}
Registering the Research Service with Word
After building the project, the next step is to register it with Word. First, launch Word. Then, bring up Word's Research task pane by choosing Task Pane from the View menu. Drop down the available task panes from the pop-up menu at the top of the task pane and choose Research. At the very bottom of the Research task pane is some text that says Research options. Click that text to get the dialog shown in Figure 6-13. Then click the Add Services button. The dialog shown in Figure 6-10 appears. In this dialog, type the address to the Web service .asmx file. Then click the Add button.
Figure 6-13. Research Options dialog.

Figure 6-10. Word's Add Services dialog.

Figure 6-11. Word's Provider dialog.

Figure 6-12. Research Service confirmation dialog.

Using the Research Service
Now, you can type the text Eric Carter in the Research task pane and drop down the list of sites to search to select All Research Sites. Click the green arrow button to search. The research service is contacted, and the response displays in the task pane, as shown in Figure 6-14. An alternative way to search for text is to type it in the document, select it, and then click it while holding down the Alt key.
Figure 6-14. The Research task pane shows results from the new Author Information research service.

More Research Service Resources
This has been a brief introduction to how to get started creating research service in C# using Visual Studio. You can do many more things with research services, including returning richer results with hyperlinks and images. For more information about creating research services, search