Browse DevX
Sign up for e-mail newsletters from DevX


Creating Your Own Research Service for the Microsoft Office 2003 Research Library : Page 5

Need to give users the ability to do quick searches of corporate data without adding yet another application to each user's desktop? The Research Library may be your answer. If your users have Office 2003, the user part is already there. All you have to do is add the research service.




Building the Right Environment to Support AI, Machine Learning and Deep Learning

Descriptive 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:

<Requery> <ServiceParameters xmlns="urn:Microsoft.Search. Office.ServiceParameters"> <Action>SelectCountry</Action>

Jan Fransen works with Microsoft Office, Microsoft SQL Server, and Visual Studio .NET to create really useful desktop applications. She enjoys using her skills as a trainer and writer to help other developers do the same. When she's not spending time with her husband and two kids in Minneapolis, Jan works with the talented people at OfficeZealot.com, A23 Consulting, and AppDev Training. .
Thanks for your registration, follow us on our social networks to keep up-to-date