Creating Your Own Research Service for the Microsoft Office 2003 Research Library

Figure 1: The Research Library is available from the task pane.

icrosoft Office 2003 Editions add a powerful new tool to the Office task pane: the Research Library.By default, the Research Library allows you to type in a word or phrase and search for the term using several built-in resources. The Research Library is also extensible: you can add your own research service simply by creating a Web service that follows schemas defined by Microsoft for research services.

In this article, you’ll look at the nuts and bolts of the Research Library and see how you can use Microsoft Visual Studio .NET to create your own research service. If you are new to Microsoft Visual Basic .NET (VB.NET), you will become familiar with some of the coding techniques needed to create research services in VB.NET. You’ll also learn how to use various formatting tags to change the appearance of the result and how to provide a custom search form for your research service.

Working with the Research Library in the Task Pane
The Research Library is available from the task pane in Microsoft Office Excel 2003, Microsoft Office PowerPoint 2003, Microsoft Office Word 2003, and Microsoft Office Outlook 2003. You can display the Research task pane by selecting Research from the Tools menu, or by pressing Ctrl+F1 and choosing Research from the Other Task Panes drop-down list. As you can see in Figure 1, the Research task pane provides a text box for you to enter the word or phrase on which to search, a drop-down list where you can choose to limit the search to a single resource, and an area for displaying the results.

Figure 1 shows the Research task pane after the user has queried the thesaurus for a particular word; the user could have selected any of the resources shown in Figure 2 or searched all resources for the same term. You can customize the Research task pane to show other resources by clicking Research Options at the bottom of the pane. The Research Options dialog box, shown in Figure 3, lists additional resources. These resources are mostly international versions of the default resources. Although these resources may be useful, they are not as intriguing as the command button in the bottom left-hand corner of the dialog box: the Add Services button. It’s this button that separates the Research Library from other useful features available in interactive Office 2003.

Figure 4: The sample uses ADO.NET to open and query an Access 2003 table.

Querying a Corporate Database: A Contacts Sample
The steps you’re about to walk through are needed to create a simple research service that allows the end user to search for contacts in a database. The source data is based on Microsoft’s Northwind Traders database from Microsoft SQL Server or Microsoft Office Access 2003. The Employees and Customers tables were combined to make the Contacts table, shown in Figure 4.

To use the Northwind Contacts sample, enter a first or last name in the Search For text box. Figure 5 shows the result of a search for a particular name. In addition to the list of contacts, the search result includes a Search by country hyperlink at the bottom of the result list. When you select the hyperlink, the research service returns a list of all the countries in the Contacts table (Figure 6). Select a country and the research service returns a list of contacts in that country.


Figure 5: You can search by first or last name.
?
Figure 6. Designing Your Mobile Application: You can choose a country from a list generated by the research service.

A Quick Guide to Web Services
A research service is simply a Web service that complies with certain specifications. A Web service is, as the name implies, an application that runs on a Web server. The sample Web service used in this article was developed using VB.NET, but it could easily have been created with a different language. Web services communicate using open standards like Extensible Markup Language (XML), so they are not tied to a particular language or operating system.

A Web service receives information from a client as an XML packet, processes that information, and returns a response, also in XML format, to the client. Typically, the schemas for the call and response are determined by the developer of the Web service. To call a Web service, the developer of the client application must know what XML to send to the Web service and how to read and process the XML returned to the client.

If the Web service is built to be a part of the Research Library, the client is the Research task pane. All the code to send a request to the research service and process the returned XML packet has already been written. When you develop a research service, you don’t get to choose the schemas you use; the schemas have already been determined by Microsoft.

This article does not delve deeply into every element defined in each schema; rather it discusses those elements that are required and points out features that are available. The schemas used by the Research Library are all included in the Research SDK. The Research SDK will be available for download from the MSDN.Microsoft.com/Office Web site after Office 2003 ships.

Creating a Research Service in Visual Studio .NET
To create a research service in Visual Studio .NET, you will need:

  • One of the Microsoft? Office 2003 Editions
  • Microsoft Windows? XP Professional, Microsoft Windows 2000 Server with Service Pack 2, Microsoft Windows 2000 Professional with Service Pack 2, or Microsoft Windows Server 2003
  • Microsoft .NET Framework 1.1
  • Internet Information Services 5.1, or access to a remote Web server
  • Microsoft Visual Studio .NET 2003

Visual Studio .NET 2003’s installation process walks you through installing and setting up the Microsoft .NET Framework and IIS. If you didn’t install them when you installed Visual Studio .NET, check out the Visual Studio .NET product documentation on MSDN.Microsoft.com for help.

Visual Studio NET makes it easy for you to build projects of different types by providing templates for those project types. When you choose to create a new project, you’ll see the dialog box shown in Figure 7. To create a research service, choose the ASP.NET Web service template and supply a name for your service in the Location text box.

Reading XML
The XML packets sent as arguments to the Registration and Query methods include information you need to read in order to determine how your code should proceed. For example, the schema for the XML packet sent to the Query method includes a QueryText element. Its value is the term for which the user is searching.

ADO.NET’s DataReader object provides efficient read-only, forward-only access to a query result.

Although you could parse the XML string with string functions, it is far easier to load the XML string as an XmlDocument object, as this code demonstrates:

    Public FunctionDescriptive Information
There are several values that don't strictly need to be changed for each research service, but should be changed to avoid confusing the end user.

Provider node children that should be changed include:

  • Message: The message the user sees when successfully adding the research service to the Research Library
  • Name: The name that appears as the Provider name when you choose to update or remove services, and in the Service Properties dialog box

Service node children that should be changed include:

  • Name: The name that appears in the Research task pane's Research Library drop-down menu
  • Description: The description that appears in the Service Properties dialog box
  • Copyright: Copyright information shown in the Service Properties dialog box

Most Registration Web methods require no more than those few changes to properly register your research service.

The Query Web Method
The Query Web method is called whenever the end user chooses to search using your research service. When you create a research service, you spend the bulk of your time working on the Query Web method. The code in this method uses the query packet sent by the Research task pane to determine what the user wants to do and then creates a result packet that can be rendered into a result by the Research task pane.

The family of schemas used to send the response packet provides a set of HTML-like elements allowing you to format a result for the Research task pane. The content you can provide in the result includes:

  • Headings that can be expanded to show more information
  • Simple text, optionally with bold, italic, or other font attributes
  • Images
  • Buttons to copy specified text to the clipboard or insert text to the Office document
  • Hyperlinks to open the browser to a particular address
  • Hyperlinks to send a new query (with the query term specified by the hyperlink itself) to the research service
  • Form elements such as list boxes, check boxes, and radio groups to provide a richer interface specific to the research service

The sample research service provides two types of responses. The first response type is shown in Figure 5. The contact name appears as a heading (expanded by default) with the address and phone number as text elements within the contact's heading. At the bottom of the list is a hyperlink that calls the research service again with a query term of Search by country.

The second response is shown in Figure 6. This response is sent when the user clicks the Search by country hyperlink. A list of countries found in the Contacts table is displayed in a drop-down. When the end user makes a selection, the research service is called.

Finding Out What the User Wants
The query packet sent to the Query Web method provides two types of information. Refer to Listing 3 for a sample query packet.

The first type of information tells the Web method about the client application that is calling the Web method. The information is found mainly in the OfficeContext node of the packet, and includes data such as the name, version, and language of the application in which the end user is working. You can use the information in the OfficeContext node to determine what data to display and whether to show buttons allowing the user to copy and paste data from the Research task pane to the application.

The second type of information tells the research service what criteria to use to determine what data should be returned.

The Keywords node of the query packet contains an element named QueryTerm. For simple research services, you can use that element's value to get the criteria for your data query. The Keywords node also breaks up multi-word terms so that you can search for each word separately. When the research service is called because a user typed a term into the Search For text box, the QueryTerm element is also sent as a part of the Context node.

If the research service is called by a form element, the Context node includes different children. The following XML fragment is sent when the user selects Finland from the country list:

                  SelectCountry

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

The Latest

microsoft careers

Top Careers at Microsoft

Microsoft has gained its position as one of the top companies in the world, and Microsoft careers are flourishing. This multinational company is efficiently developing popular software and computers with other consumer electronics. It is a dream come true for so many people to acquire a high paid, high-prestige job

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS

©2023 Copyright DevX - All Rights Reserved. Registration or use of this site constitutes acceptance of our Terms of Service and Privacy Policy.

Sitemap