|
The appearance of Visual Studio .NET at the Professional
Developers Conference in Orlando this July gave birth to a whole new world of
exposed http-addressable services and component methods available to developers
over the web. The Microsoft code name for this "bundle of joy", as it were,
is "webservices". If webservices were a stock, I wouldn't short it just yet.
It promises to be one of the most exciting new concepts on the web since Al
Gore invented it. If you're not sure why webservices holds such promise, look
at the diverse list of authors of the W3C SOAP 1.1 Specification and that should
give you a clue:
http://www.w3.org/TR/2000/NOTE-SOAP-20000508/
The Microsoft flavor of webservice is not only incredibly
easy to create using the Visual Studio IDE and the language of your choice in
the Common Language Runtime (CLR), but they are also callable through SOAP and
other methods including a straight HTTP GET with the parameter(s) name and value(s)
on the querystring.
Lets take a look at a sample webservice that Microsoft exposes
to the public, examine its interface, and write a HTTP page to access this service
and present the results. Actually, unlike most "examples", the page I have
in mind is one that is quite useful and that you might very well want to have
on your website. It's the MSDN Search Beta "Best Bets" webservice method. What
this does is take your search phrase and match it up to a cached set of "Best
Bet" matches at MSDN and return the result as well-formed XML.
Here is a link to the the webservice "disco" page so you
can see how a Microsoft webservice exposes itself:
http://beta.search.microsoft.com/search/
The webservice method we will be using is the second one,
"GetBestBets." To see what the result of a search will look like, click the
link below for a search on "XML":
http://beta.search.microsoft.com/search/MSComSearchService.asmx/GetBestBets?Query=XML
What we'll do now is write a
page with the least possible amount of code that will present a search form
and display the items from the result XML document in a nice table, converting
the "Title" element from each node into a nice hyperlink to its corresponding
"Url" element, in a nice HTML table just below the Search form. We'll do this
in a narrow 130 pixel wide table column so that the code can be inserted on
the left or right side column of your web page.
First let's take a look at all
the code, and then we'll walk through it:
|