Search Me…

Search Me…

  • Comments 1

Ashish pointed you at the Windows Live Dev center, so I thought I would give you an idea how easy it is to use the web services in your own applications by showing you how to leverage Windows Live Search to provide search functionality on YOUR web site.

You need to start the process by going to http://search.msn.com/developer and provisioning yourself an "Application ID" which is your unique key to call the web service. It is a very quick process that gives you a string of characters that you need to pass with each call.

Once you have that, calling the search web service is as easy as adding a "web reference" to http://soap.search.msn.com/webservices.asmx?wsdl and dropping in a few lines of code.

For this example, we will call the search service when users click the "Search" button on our ASP .NET web site and then bind the results to a GridView control.

protected void Search_OnClick(object sender, EventArgs e)

{

SearchRequest searchRequest = new SearchRequest();

searchRequest.AppID = "<insert your unique AppID here>";

searchRequest.CultureInfo = "en-US";

searchRequest.Query = string.Format("{0} site:www.mysite.com", Textbox1.Text);

 

SourceRequest webSource = new SourceRequest();

webSource.Source = SourceType.Web;

searchRequest.Requests = new SourceRequest[] { webSource };

 

MSNSearchService s = new MSNSearchService();

SearchResponse searchResponse = s.Search(searchRequest);

 

GridView1.DataSource = searchResponse.Responses[0].Results;

DataBind();

}

Pretty powerful stuff – dive in and give it a try, maybe on your own console app…

Page 1 of 1 (1 items)
Leave a Comment
  • Please add 5 and 4 and type the answer here:
  • Post