In order to implement this access we must have the following prerequisite libraries available for use:

Jakarta Commons HttpClient

Castor

The quick outline of the steps required is as follows:

First we query the NCBI blast query, after which we receive a reply containing the number of seconds left for processing this request, or an error message if the query was malformed.

After that wait period is expired, we again query the server for the status of our request, and if the reply is positive we proceed to the final request results. Otherwise we wait for the request to complete, and then proceed.

After waiting we are making another query to check if our request has been processed:

UrlQuery getQuery = new UrlQuery();

getQuery.setNameValue("RID", rid);

getQuery.setNameValue("CMD", "GET");

After which we get another HTML code containing something like this:

Now we need to retrieve the Status value which can be either WAITING, READY, UNKNOWN or ERROR.

WAITING - we need to wait a few more seconds

READY - request has been processed

UNKNOWN - request has been lost

ERROR - our request was malformed, we made an error during issuing our request

If we got Status=WAITING, then we will wait for couple of more seconds, and resend the query, and if the Status=READYwe can create a query for retrieving the final result data in a form of an XML document.