Click here to Skip to main content
13,290,556 members (72,256 online)
Click here to Skip to main content
Add your own
alternative version


76 bookmarked
Posted 25 Jan 2003

ASP.NET web client for Google Web API

, 25 Jan 2003
Rate this:
Please Sign up or sign in to vote.
Exploring Google Web API
<!-- Article Starts - DO NOT ADD HTML/BODY START TAGS--> <!-- Download Links --> <!-- Article image -->

Sample Image - GoogleWebClient.gif

<!-- Add the rest of your HTML here -->


Recently I got an opportunity to explore the Google Web API which can be downloaded from the Google site. So I decided to code the web-client which is very easy and interesting too!  The article focuses on developing the Web-Client with which you can search items from your site itself.

Installation & Setup

You must download the google web api first! Then follow the instructions below. 

  1. Create the folder like "Net" within "wwwroot" folder and make that folder web application.
  2. Create "bin" sub-folder within the "Net" folder.
  3. Make GoogleProxy.cs using the WSDL tool and compile GoogleProxy.cs into the .net assembly using csc command to generate the proxy. 
    1. >wsdl 
      /l:cs /o:GoogleProxy.cs <a href="http://localhost/Net/GoogleSearch.wsdl">http://localhost/Net/GoogleSearch.wsdl</a> <br>

      This generates the GoogleProxy.cs. "GoogleSearch.wsdl" is found in the API you have downloaded.
    2. >csc /out:GoogleProxy.dll /t:library /r:system.dll, system.web.dll, 

      This generates the .net assembly, GoogleProxy.dll. Copy the dll file into "bin" folder. Your ASP.NET page will ultimately call the web-callable methods and properties exposed by this dll.
  4. Write GoogleClient.aspx file to create the UI and to consume the services exposed by google web api, to be precise GoogleProxy.dll in our case.
  5. Browse http://localhost/Net/GoogleClient.aspx. That's it!

Why proxy?

A proxy resides on the consumer's machine and acts as a rely between the consumer and the web service. When we build the proxy, we use WSDL file to create a map that tells the consumer what methods are available and how to call them. The consumer then calls the web method that is mapped in the proxy, which in turn, makes calls to the actual web service over the Internet. The proxy handles all of the network-related work and sending of data, as well as managing the underlying WSDL so the consumer doesn't have to. When we reference the web service in the consumer application, it looks as if it's part of the consumer application itself.

Using the code

The code is pretty straight forward.

<%@ Page Language="C#" %>
<@ import Namespace="GoogleWebService" >
//Remember,GoogleWebService is the namespace you named while creating the proxy!
<script runat="server">

    string key="licence key you got from google";
    /* I have declared the key string variable as global variable 
       since the key variable is to be passed every time you call the methods.
    void Page_Load()
        //Label to display the Spelling Suggestion
        //Label to display the Estimated total result count
        //Label to display the server time to return the search results, 
        //measured in seconds.
    void btnSearch_Click(Object sender, EventArgs e) {
    //creating the instance of  the GoogleSearch class to invoke required methods
    GoogleSearchService obj=new GoogleSearchService();
    //spelling checking and suggesting if entered wrong
    string suggestion=obj.doSpellingSuggestion(key,Request.Form["txtPhrase"]);
    if (suggestion!=null)
            lblSpellSug.Text="Suggestion: "+ suggestion;
    //searching the phrase.....
    //Regarding the parameters refer to the Google API
    GoogleSearchResult res=obj.doGoogleSearch(key, Request.Form["txtPhrase"], 
                                              0, 10, false,"",false,"","","");
    lblResultCount.Text="Est. Total Result Count: " + 
    //to display the total estimated result count
    lblSearchTime.Text= "Search Time: " + Convert.ToString(res.searchTime) + 
                        "sec";//search Time
    //displaying the results Returned by the Search in tabular using the Table control.
    ResultElement[] result=res.resultElements;
    foreach(ResultElement r in result)
            //formatting the Server control Table
            TableRowCollection trCol=ResultTable.Rows; 
            //ResultTable is the instance created for Table class
            //creating new Table Row and adding to the TableRowCollection
            TableRow tr=new TableRow();

            TableCellCollection tcCol=tr.Cells;
            //creating new Table Cell, assigning the title and the summary 
            //of the search result.
            TableCell tc=new TableCell();
            tc.Text="<a href="+ r.URL +">"+  r.title + "</a>" + "<BR>" +  r.summary;


Let's share the solution.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Software Developer
United Kingdom United Kingdom
Milan has been developing commercial applications over a decade primarily on Windows platform. When not programming, he loves to test his physical endurance - running far away to unreachable distance or hiking up in the mountains to play with Yaks and wanting to teach 'Yeti' programming!

You may also be interested in...

Comments and Discussions

GeneralMy vote of 1 Pin
Member 1214588325-Nov-15 2:57
memberMember 1214588325-Nov-15 2:57 
GeneralMy vote of 1 Pin
aravindhlogesh10-Apr-13 7:30
memberaravindhlogesh10-Apr-13 7:30 
QuestionPls Can anyone tell whats the correct url of google web API ? Pin
bdmukta27-Jun-09 22:23
memberbdmukta27-Jun-09 22:23 
Questionhi plz help me how to download? Pin
Member 39312778-Feb-08 20:53
memberMember 39312778-Feb-08 20:53 
GeneralRe: hi plz help me how to download? Pin
sonj7-Apr-08 21:36
membersonj7-Apr-08 21:36 
GeneralRe: hi plz help me how to download? Pin
Uwe Keim10-Apr-08 3:00
sitebuilderUwe Keim10-Apr-08 3:00 
QuestionHow to download ? Pin
vickees10-Dec-07 23:48
membervickees10-Dec-07 23:48 
GeneralMilan I need Help Please Pin
joey272726-Apr-07 13:54
memberjoey272726-Apr-07 13:54 
Questionplz give me exact path to follow up Pin
HimanshuJain13-Mar-07 21:30
memberHimanshuJain13-Mar-07 21:30 
GeneralDataBinder.Eval() Pin
TheEagle26-Jun-06 2:51
memberTheEagle26-Jun-06 2:51 
GeneralMining Google Web Services: Building Applications with the Google API Pin
Anonymous21-Aug-05 21:51
sussAnonymous21-Aug-05 21:51 
GeneralRe: Mining Google Web Services: Building Applications with the Google API Pin
milan22-Aug-05 0:20
membermilan22-Aug-05 0:20 
Generalif I use web matrix....... Pin
lily8211-Feb-05 19:31
memberlily8211-Feb-05 19:31 
GeneralRe: if I use web matrix....... Pin
milan13-Feb-05 18:21
membermilan13-Feb-05 18:21 
GeneralOnly Title is Displayed?! Pin
at2oo11-Dec-04 4:39
memberat2oo11-Dec-04 4:39 
Questionwhat if there is firewall authetication Pin
dehran master3-Nov-04 5:04
memberdehran master3-Nov-04 5:04 
GeneralAsp.Net Error Underlying Connection was Closed. Unable to connect to remote server Pin
Leo Paul1-Jul-04 21:16
memberLeo Paul1-Jul-04 21:16 
GeneralRe: Asp.Net Error Underlying Connection was Closed. Unable to connect to remote server Pin
dathq6-Jul-04 18:05
memberdathq6-Jul-04 18:05 
GeneralRe: Asp.Net Error Underlying Connection was Closed. Unable to connect to remote server Pin
dathq6-Jul-04 18:05
memberdathq6-Jul-04 18:05 
GeneralRe: Asp.Net Error Underlying Connection was Closed. Unable to connect to remote server Pin
NITH8-Dec-04 23:13
memberNITH8-Dec-04 23:13 
How can I go though our firewall without attaching to an instance of WebProxy?
GeneralTo get the default printer name of a client machine Pin
Rajesh k Chandran30-Jun-04 18:17
memberRajesh k Chandran30-Jun-04 18:17 
GeneralThe underlying connection was closed: Unable to connect to the remote server. Pin
RockOn4-Dec-03 8:45
memberRockOn4-Dec-03 8:45 
GeneralRe: The underlying connection was closed: Unable to connect to the remote server. Pin
Anonymous3-Jun-04 4:42
sussAnonymous3-Jun-04 4:42 
GeneralInnocent question Pin
Aron Pilhofer26-Jun-03 3:10
sussAron Pilhofer26-Jun-03 3:10 
GeneralRe: Innocent question Pin
milan26-Jun-03 19:49
membermilan26-Jun-03 19:49 
GeneralException from service object Pin
Mahmoud Nasr Ahmed4-Jun-03 10:28
memberMahmoud Nasr Ahmed4-Jun-03 10:28 
GeneralRe: Exception from service object Pin
Mahmoud Nasr Ahmed4-Jun-03 13:05
memberMahmoud Nasr Ahmed4-Jun-03 13:05 
GeneralException from service object: Invalid authorization key: get the licence key for the google Pin
Mahmoud Nasr Ahmed4-Jun-03 10:25
memberMahmoud Nasr Ahmed4-Jun-03 10:25 
General"namespace name 'GoogleWebService' could not be found" error Pin
Tulsi29-Mar-03 17:30
sussTulsi29-Mar-03 17:30 
GeneralRe: "namespace name 'GoogleWebService' could not be found" error Pin
milan30-Mar-03 18:06
membermilan30-Mar-03 18:06 
GeneralNiCE... Pin
rxFTP2-Feb-03 21:20
memberrxFTP2-Feb-03 21:20 
GeneralRe: NiCE... Pin
milan2-Feb-03 21:53
membermilan2-Feb-03 21:53 
GeneralPerformance and Scability Suggestion Pin
Heath Stewart26-Jan-03 4:31
memberHeath Stewart26-Jan-03 4:31 
GeneralRe: Performance and Scability Suggestion Pin
milan26-Jan-03 18:34
membermilan26-Jan-03 18:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.171207.1 | Last Updated 26 Jan 2003
Article Copyright 2003 by milan
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid