Share via


Search Me…

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 https://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 https://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…

Comments