Library tutorials & articles
Implementing The Google Web Service In VB.NET
- Introduction
- The Google Web Service
- Implementing the Web Service
- Conclusion
The Google Web Service
Google is one web site that provides the public with web services, allowing applications to use features like search and spell checks. We shall now see how can we use this service in an application using Visual Basic .NET. But before we can access the Google web service, we need to create a Google account and obtain a license key, which will allow us to run about 1000 automated queries a day.
Jump over to http://www.google.com/apis/ to create a Google account. Once you have entered your email and password, Google will email you your license key, which will be used in our application sample application for this article.
Getting Started
Now that we’ve received our license key, we will create an application in Visual Basic .NET to create a customized search and a spell checker using Google's web service API's (application programming interface). Open Visual Studio .NET and create a new Windows Application Project. Call it googleapi and click OK:
Adding A Web Reference To The Google Web Service
Next, we need to add a web reference to the Google web service (this is almost like adding a reference to a COM/ActiveX object, but when we add a web reference we now have access to the XML web service on Google's server).
Open your solution explorer, right click on references, and click add web
reference. Alternatively you could select the project menu and click on the
add web reference menu item. In the address bar, type in http://api.Google.com/GoogleSearch.wsdl (please
make sure that you type it in exactly as shown, as this URL is case sensitive),
like so:
After you enter the URL and press enter, the Google web service is loaded and you should see a screen similar to the one shown in the example above. Lastly, click on the add reference button to add this web reference to our project.
Related articles
Related discussion
-
VB.NET Simple Client / Server Communication
by r0bbyw (3 replies)
-
How to write the category attribut in a class dynamically
by converter2009 (1 replies)
-
VB.NET: Hide and show table using radio buttons
by converter2009 (1 replies)
-
VB.Net Button Problem
by pysdex (0 replies)
-
Unable to access AxInterop.AcoPdflib.dll on 64 bit OS
by Shaila14041981 (0 replies)
Related podcasts
-
Introduction to Atlas
Get your feet wet with an introduction to Atlas. Atlas is the new part of the .NET framework specifically for web clients. Features include AJAX and web services support, new validation controls, behaviors, and an object orientation layer sitting on top of JavaScript.
Events coming up
-
Dec
8
December Silicon Valley Ruby Meetup
Moffett Field, United States
In a World of Middleware, Who Needs Monolithic Applications? by Jon Crosby With Rack emerging as the standard for composing web applications and services, most recently with Rails adoption, an architectural shift is taking place. Learn how to create next generation web services by reusing existing Rack middleware and supplementing with your own components and micro-frameworks like Sinatra. Bio : Jon likes music, the Open Web, Ruby, Erlang, Haskell, Objective-C, JavaScript and coffee.
I tired this in Visual Basic 9.0 .net 3.5 the code is slightly modified details are given below,
Public Class Google_Search
' for Google Search button
Private Sub BtnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSearch.Click
Dim MyLicenseKey As String
' Declare variable for the Google search service
Dim MyService As GoogleReference.GoogleSearchPort = New GoogleReference.GoogleSearchPortClient
' Declare variable for the Google Search Result
Dim MyResult As GoogleReference.GoogleSearchResult
' Please Type your license key here
MyLicenseKey = "tGCTJkYos3YItLYzI9Hg5quBRY8bGqiM"
' Execute Google search on the text enter and license key
MyResult = MyService.doGoogleSearch(MyLicenseKey, _
TxtSearch.Text, 0, 1, False, "", False, "", "", "")
' output the total Results found
LblTotalFound.Text = "Total Found : " & _
CStr(MyResult.estimatedTotalResultsCount)
End Sub
'For name search button
Private Sub BtnCheckSpelling_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnCheckSpelling.Click
Dim MyLicenseKey As String
' Declare variable for the Google search service
Dim MyService As GoogleReference.GoogleSearchPort = New GoogleReference.GoogleSearchPortClient
' Declare variable for the Google Search Result
Dim MyResult As String
'Please type in your key here
MyLicenseKey = "tGCTJkYos3YItLYzI9Hg5quBRY8bGqiM"
' Execute Google search on the text enter and license key
MyResult = MyService.doSpellingSuggestion(MyLicenseKey, TxtCheckSpelling.Text)
'Output Results
LblCorrectSpelling.Text = "Did you mean: " & MyResult
End Sub
End Class
With a huge pleasure I've found this article. Thank you.
This thread is for discussions of Implementing The Google Web Service In VB.NET.