Srikanth Technologies

Accessing Yahoo Search Web Service using JAXB and JSP

In this blog, I will explain steps required to access search web service of Yahoo using a JSP. Yahoo provides a service that can be accessed using simple URL. It needs application id, which can be obtained if you like. But in this example, I am using demo application id called YahooDemo.

For example, the following URL can be used to search for srikanthpragada.

http://search.yahooapis.com/WebSearchService/V1/webSearch?appid=YahooDemo&query=srikanthpragada

It returns results in the form of XML. The schema used for XML document is provided at the URL.

http://api.search.yahoo.com/WebSearchService/V1/WebSearchResponse.xsd

In case you want to use XPATH to search for results in XML document instead of using Java classes using JAXB, please read my blog regarding using Yahoo Search service at http://www.srikanthtechnologies.com/blog/yahoosearch.html

For more information about Yahoo Search Service, refer to Yahoo Search Service

Creating Java classes from XML schema using JAXB

The main theme of this example is to show how to use JAXB (Java Architecture For XML Binding). JAXB converts XML schema to Java classes. We use NetBeans 6.1 to create Java classes through JAXB by taking URL for schema.

Creating JSP to call Yahoo Search Service

The following steps use classes created by JAXB to receive the XML data sent by Yahoo Search Service and display data as hyperlinks to user.