CODE: Sequoia

Monday, February 20, 2006

My first Web Service experience

I'm a software engineer, and deal with C++ everyday. While it is fun, I have to admit I'm somewhat far from up-to-date topics such as "Web Service". In this president day weekend, I had a chance to jump into it. And, it was fantastic experience to know what is "Web Service". In short, "Web Service" enables me to access services of the Web site programatically. The first thing I did was going to Google and got Google API. http://www.google.com/apis/ I think what the API does explains what is "Web Service" very well. It allows me to use Google Search engine through my program. The API comes with WSDL file. Actually, I don't know what is it exactly yet, but it seems to describe:
  • What kinds of methods does Google exposes to us?
  • How to use these methods? What Parameters, What return type, etc.
For my first Web Service experience, I picked a method called "doSpellingSuggestion". It uses Google's spelling suggestion functionality. The WSDL file is language independent, and we can get C# version of "WSDL" out of it. The C# version of WSDL lets us to use the Google API through C# language. The conversion is done with wsdl.exe which comes with .NET framework SDK. % wsdl GoogleSearch.wsdl Then I got GoogleSearchService.cs . Next step is to write C# application program to use the API. BTW, the xxx... below is my Google license code.
using System;

public class GoogleSpell {
 static public void Main(){
   GoogleSearchService service = new GoogleSearchService();
   string result = service.doSpellingSuggestion("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "atmosphire");
   Console.WriteLine(result);
 }
}
Then compile the code with GoogleSearchService.cs, and run. Google checks the wrong spelling "atmosphire" and correct it to "atmosphere". Wow. It is that easy!

Sunday, February 19, 2006


Moto's picture Posted by Picasa