dominoGuru.com
Your Development & Design Resource
The most basic tutorial on interacting with Web Services you'll ever read...
01/11/2010 12:38 PM by Chris Toohey
I thought about putting together a very basic example of interacting with web services, but I wanted something that could be universally understood while still being completely applicable and -- in my opinion -- invaluable to an IBM Lotus Notes Domino Application developer. I immediately thought of an example that I've been using for quite some time that appears (and quite frankly is) ridiculously simple while illustrating the raw power available to developers. This example also approaches the subject of Web Service architectures... so today you get 2-for-1!
Synopsis
We will be creating a simple HTML Form that interacts with public Google Web Search web service.
Our simple HTML Form will submit an HTTP Request via the GET Method and rely on the usage of the Google Web Search Query String handler to accept our query. The Google Web Search web service will then perform the search and return the results to the screen via the Google search results UI.
Build
The good news here: Google's done all of the hard work for us. The Google Web Search web service is designed to accept (via GET or POST) submissions either from their own domain/site, or via 3rd-party.
For example, let's say we build a form that generates this URL:
http://www.google.com/search?q=test
search
, in the above example (and the Google Web Search web
service), is the HTTP Request consumer. Basically, you hit search
,
and it's designed to take the submitted values and perform whatever task the
Logic Controller of the Google Web Search web service defines. (See, I went a
little MVC on you there...)
So let's build a form that interacts with the Google Web Search:
<html>
<head>
<body>
<form name="foo" id="foo"
action="http://www.google.com/search" method="GET">
<label for="q">Query:</label>
<input type="input" name="q" id="q"
value="" />
<input type="submit" value="Search!" />
</form>
</body>
</html>
Pretty simple huh?
Conclusion
Understanding how to interact with an HTTP Request Consumer is the first step in developing and interacting with Web Services. Sure -- this is a very basic example of a public web service... but that's kind of the idea.
Consider this: use this same approach, but this time use AJAX and the Google Web Search API.
Understanding in web services development and architecture starts with the simple client-server exchange. This example simply does that exchange in a way that you can see what's happening: via your active browser window.