" /> Davanum Srinivas' weblog: October 2005 Archives

« September 2005 | Main | November 2005 »

October 13, 2005

REST API for Yahoo Web Search

Inspired by Dave Orchard's effort to represent Yahoo Web Search in WSDL 2.0, i was thinking about how we could support codegen in Axis2.0 for REST-style services. Before we can do that we need a REST-style API that's easy to use. So i ping-ed our REST guru, Mr. Mark Baker. Here's an API that we came up with.

Step #1: Use scomp in xmlbeans to generate code from the xsd. Let's assume that it generates com.yahoo.search.api.ResultSet class

Step #2: Write sample code to invoke the "webSearch"

import com.yahoo.search.api.ResultSet;

try {
Message m = new Message("http://api.search.yahoo.com/WebSearchService/V1/webSearch");
m.addParam("appid","YahooDemo");
m.addParam("query","madonna");
m.addParam("results","2");
m.setResultParam(ResultSet.class);
ResultSet set = (ResultSet) m.invoke("GET");
} catch (HTTPClientException e){
System.out.println("You did something wrong: " + e.getCode());
System.out.println("Error Message:" + m.getResponse().xpath("/Error/Message"));
} catch (HTTPServerException e){
System.out.println("The server did something wrong: " + e.getCode());
System.out.println("Error Message:" + m.getResponse().xpath("/Error/Message"));
}


Notes:

  • 4xx HTTP error codes are translated to HTTPClientException
  • 5xx HTTP error codes are translated to HTTPServerException
  • Yahoo Error Message details are here.
  • If the developer just needs tiny bit from the response and does not want to do databinding, they can just use xpath to extract the relevant portion using xpath. (similar to how we extract the error message)

Does this make sense? Comments? Concerns?

October 11, 2005

ANNOUNCE : Axis 1.3 Release

Greetings, Web Services fans.

The Axis team is pleased to announce the availability of Axis (Java)
version 1.3. This version gives Axis the ability to run inside applets,
more efficiently process attachments, and preliminary support for MTOM,
not to mention the usual round of bug fixes. More info is available in
the changelog.html in the release.

You can find the release at:

http://www.apache.org/dyn/closer.cgi/ws/axis/1_3/

The Axis webpage (which contains info on mailing lists, bug reports,
etc) can be found, as always, at:

http://ws.apache.org/axis

Thanks, and enjoy!

--Glen Daniels
on behalf of the Axis team

October 05, 2005

Planet WSO2

Aggregator with all our blogs - http://wso2.com/blogs/