Streamline your search with Yahoo! Web Services and AJAX
Google - not the only fruit
Hands on Despite what you might read and hear about Google's web dominance, this is not Google-owned world. Yahoo! may be playing second fiddle to the internet's favorite search and ads service, but it still plays one hell of a tune in terms of numbers of users and the services it offers.
If you use Yahoo! for your web search, then Yahoo! provides web services that may be included in web applications to generate dynamic content for an input.
Limits of AJAX
AJAX is a web technique to transfer XML data between a browser and a server without reloading the web page. Ajax is implemented using the
A limitation of
XMLHttpRequest is that AJAX requests may be made only to the same web server that serves the web page from where the AJAX request is sent. If the web application is running on one server and the web service is on another server a
XMLHttpRequest request does not get sent. Various methods are available to send an AJAX request to a remote server some of which are digitally signing your scripts and using an alternative
XMLHttpRequest API. One of the methods, which we shall discuss in this article, is to use a proxy web server that routes AJAX requests from the web application to the web service.
Yahoo! Web Services provide various web search services and content that may be included to develop dynamic web applications. Yahoo! Web Search AJAX Web Services have an advantage over the Google web search AJAX web services. Yahoo! Web Services have the provision to search within a context; contextual web search. For example, search for the term "Eclipse" in the context of "Java IDE". The various Web Search Web Services provided by Yahoo! are discussed in following Table.
|Context search||The contextual web search service returns web pages that match a query within a specified context|
|Related suggestion||Provides suggestions for related queries based on the submitted query|
|Spelling suggestion||Provides suggested spellings for a specified term|
|Web search||Provides a web search service using REST (Representational State Transfer)|
Before Yahoo! Web Service may be used, register with Yahoo Web Services to obtain an application identity with which Yahoo! Web Services may be accessed.
Create a web application
First, create a JDeveloper application,
WebSearchApp, and project,
WebSearchWebService. Create a JSP file,
input.jsp, in the project. The web application URL, which is used to register with Yahoo! Web Services, is
http://127.0.0.1:8988/WebSearchApp-WebSearchWebService-context-root/input.jsp. In the web application we shall use the Contextual Web Search service to submit a context-base web search query.
The request URL for the contextual web search web service is
http://search.yahooapis.com/WebSearchService/V1/contextSearch. The required request parameters to a contextual web search query are
context. The value of the
appid parameter is the application ID provided by Yahoo! Web Services and the context parameter specifies the context string in which the web search query is sent.
Sponsored: The Nuts and Bolts of Ransomware in 2016