|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Want a new Job?
Chapters
Services
Feature Zones
|
IntroductionThis is a demonstration of a web based client for Google Web Services. This is my first attempt at ASP.NET technology. I have tried to make it fully customizable and open ended as far as possible. Key customization features are:
The app looks for cfg.xml in the current working directory which would be c:\winnt\system32 by default. Copy this file to that location. Advantage of having this is search query terms can be changed as and when requirements change, and same holds good for the results display. This application allows a user to go through the first 1000 results since Google places that restriction. What do you need to run the demo project?
What the Application doesStep 1:The application sends a SOAP message to the Google Server which in turn returns a Google proprietary data structure. The application then parses this data structure and creates an XML file. (Let's call it results.xml. Note: It could be any name you choose as long as it's in the cfg.xml.) Here is a small portion of it: <SearchResults attributes1=value1... >
<ResultSet>
<Item>
<summary />
<url>http://www.iqsoft.com/</url>
<snippet>PRODUCTIONS </snippet>
<title>Welcome to SAWStudio.com!</title>
<cachedsize>9k</cachedsize>
<relatedInformationPresent>True</relatedInformationPresent>
<hostName />
<directorytitle />
</Item>
</ResultSet>
</SearchResults>
<SearchResults>
Step 2:The application then transforms this XML file using the custom stylesheet (search.xsl) and writes the results of the transformation to the client browser. OK, so that's what the
Key areas of the source code:Search class in WebForm1.aspx.csThe The The <% Response.Write(getdata()) %>
Points of interest:There is only a single instance of the Google Search Service object which is initialized in Although the "Next" and "Previous" links could have been generated by the search.xsl file, there is no way for us to control the starting index value in the XSL other than incrementing it by
But the XSL would be blissfully unaware of what page we are on. The following code shows how it's been implemented: if( !Page.IsPostBack)
{
start = Request.Params["start"];
results = getdata(query,Convert.ToInt32(start));
}
else
results = getdata(query,0); //In this case start would always be 0.
Tracking is done using the querystring parameter Here is an example of how the Next link is generated, where start is the value of the querystring parameter if((nTotalCount - nNext) > 10)
{
Response.Write("<br></br><a href=\"webform1.aspx?type=Next&start=");
Response.Write(nNext);
Response.Write("&query=");
Response.Write(TextBox1.Text);
Response.Write("\"><b>Next</b></a><br></br>");
}
Well, I hope I have covered the key areas. Like any other program, I am certain there would be bugs and mistakes I may have made. Looking forward to your feedback so I may incorporate enhancements and bug fixes if any.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||