Google Sample

The Google research service provides Web research capability with the Google.com search engine from within Microsoft® Office 2003 or Microsoft Internet Explorer.

Installing the research service

To install the Google research service, follow these steps:

  1. Configure the research service

    Requirements

    • Microsoft Office 2003
    • Microsoft .NET Framework 1.0 or later
    • Microsoft .NET Framework 1.0 Software Development Kit, or a later release
    • Microsoft Visual Studio® .NET 2002 (to modify and rebuild the Web service if necessary)
    • Microsoft Internet Information Services (IIS) 5.0 or later

    Note  IIS should be installed before you set up the Microsoft .NET Framework SDK and Microsoft Visual Studio .NET. If you have installed or re-installed IIS after setting up the Microsoft .NET Framework SDK, you will experience unexpected behavior when you try to view ASP.NET pages. To fix this, register ASP.NET with IIS again by running the aspnet_regiis.exe utility. For more information, see Knowledge Base article 306005 , "HOWTO: Repair IIS Mapping After You Remove and Reinstall IIS."

    Configuring the research service

    The Google research service provides a Microsoft Visual C#® and a Microsoft Visual Basic® .NET version. The instructions below use the C# version for illustration. Make necessary adjustments to use the Visual Basic .NET version.

    1. Do one of the following:

      • If you have installed the Research SDK on the computer that hosts the IIS server ServerName, go to step 2.

      • If you have installed the Research SDK on a computer different from ServerName:

        1. Create a folder named GoogleResearchLibraryCSharp on ServerName. This is the research service folder.

          Note  To avoid access problems when running running the Google Web service, do not place the GoogleResearchLibraryCSharp folder in the My Documents folder.

        2. The source and run-time files are located in the Google research service folder and its subfolders at Drive:\Program Files\Microsoft Office 2003 Developer Resources\Microsoft Office 2003 Research Service SDK\Samples\Google Sample\GoogleResearchLibraryCSharp.

          Folder structure

          Root Folder Sub Folder Description
          \GoogleResearchLibraryCSharp   Root folder for the XML Web service and source code.
            \bin Assembly file for the research service.
            \Web References Web reference files for the C# Web service project.

          Copy the content of the GoogleResearchLibraryCSharp folder from the computer that the SDK is installed on to the GoogleResearchLibraryCSharp folder on ServerName.

    2. Make sure the default Web site in Internet Information Services (IIS) is running on the server computer ServerName.

      1. From the Microsoft Windows® Start menu, click Control Panel, click Administrative Tools, and then click Internet Information Services.
      2. In the left-hand pane, expand the node containing the name of your Web server, ServerName.
      3. Expand Web Sites.
      4. Right-click the Default Web Site node, and click Start. If Start is inactive, IIS is already running.
    3. Map the research service folder to a virtual directory.

      To map the research service folder to a virtual directory named GoogleCSharpService on ServerName:

      1. From the Microsoft Windows® Start menu, click Control Panel, and then double-click Administrative Tools.
      2. Double-click Internet Information Services.
      3. In the Internet Information Services folder tree, expand the folders for the local computer, the Web Sites directory, and the Default Web Site.
      4. Create a new virtual directory named GoogleCSharpService by right-clicking Default Web Site and selecting New and Virtual Directory. Follow the instructions in the Virtual Directory Creation Wizard.
    4. By default, the Google research service assumes the client computer and ServerName are the same computer, and it is configured to use http://localhost/ as its server. To change the server name so that the service can be accessed from a different computer, edit the Web.config file found in the research service folder. Edit the value attribute of the following add XML element

      <add key="ServerPath"
      value="http://localhost"/>
      

      by changing it to the name of your server. For example:

      <add key="ServerPath"
      value="http://www.MyServerName.com"/>
      
    5. If you use a firewall to gain access to the Internet, check with your organization's network administrator to see if there is any special firewall client software that needs to be installed, or any special connectivity settings that need to be set.

  2. Add the research service to the Research task pane

    Before you can search on the Google research service for the first time, you must add the research service to the Research task pane by using the URL http://ServerName/GoogleCSharpService/Registration.asmx. For more information about adding a research service, see Adding Services through the Office User Interface.

Google Web APIs

The Google research service uses the Google Web APIs, as documented at http://www.google.com/apis/. To access the Google Web APIs, you must create a Google account and obtain a license key from http://www.google.com/apis/. Your Google Account and license key entitle you to 1,000 automated queries per day. There is no charge for this key.

  1. Go to http://www.google.com/apis/ to obtain a license key.

  2. Update web.config with the license key. There are C# and Visual Basic .NET versions of the source for this research service, so update the corresponding web.config for the language of your choice:

    • For the C# version, the web.config file is located at Drive:\Program Files\Microsoft Office 2003 Developer Resources\Microsoft Office 2003 Research Service SDK\Samples\GoogleResearchLibraryCSharp.
    • For the Visual Basic .NET version, the web.config file is located at Drive:\Program Files\Microsoft Office 2003 Developer Resources\Microsoft Office 2003 Research Service SDK\Samples\GoogleResearchLibraryVBNet.

    Put your license key assigned to you by Google into the value field:

    <add
    key="GoogleKey" value="[INSERT YOUR KEY HERE - SEE
    README]"/>
    

    For example, this will look like:

    <add key="GoogleKey"
    value="abc123xyz/abc"/>
    

Searching the research service

Searching the Google research service is very similar to searching Google.com. In the Research task pane, under Search for, type the text that you would like to look up. Select Google Web Search (CSharp) as the research service if it has not yet been selected. The Research task pane will then display a list of search results.

Design of the research service

Under the Search namespace, the Google research service specifies the Web methods: Registration, Query, and Status. The pages http://ServerName/GoogleCSharpService/Registration.asmx and http://ServerName/GoogleCSharpService/Query.asmx provide brief descriptions of each of the methods and hyperlinks to the formal definitons of these methods.

Registration

This method is called when you first add the Google research service to the task pane. At that point, it sends a registration request. This method always returns a registration response, and Office then adds this research service to its lists of services. The registration response supports the Microsoft.Search.Registration.Response Schema.

Note that the QueryPath element refers to the location of the Query Web method for this research service at http://ServerName/GoogleCSharpService/Query.asmx.

Query

The bulk of the processing by this solution is handled by the QueryProcessor class. It has the following class structure:

public class QueryProcessor :
System.Web.Services.WebService [WebMethod()] 
public string Query(string queryXml) 
private string QueryGoogle(string queryString, int startAt)
[WebMethod()] public string Status() 

The public function Query that is marked with [WebMethod()] is the other key Web method for this research service. Each request from the client is passed into this function and stored in the queryXml parameter.

The Query function parses queryXml for search terms specified by the user. It then calls the internal method QueryGoogle to continue the search using the Google Web APIs.

After QueryGoogle obtains search results, it puts together and includes the results in a query response that supports the Microsoft.Search.Response Schema. It then passes the query response back to Query.

The Query function returns the query response to the Research task pane. The Research task pane then displays the list of search results.

Status

This method returns the status of the server that hosts the research service.

urn:Microsoft.Search

The Registration and Query Web methods wrap a Registration or Query response into the body of a SOAP message. These methods are specified with the following directive that defines the namespace used for the SOAP message:

<WebService(Namespace:="urn:Microsoft.Search")>

The Research task pane responds only to SOAP messages with this namespace.