次の方法で共有


MSNSearchService クラス (Search)

Live Search Web サービス要求のトップレベルのクラスです。

構文

public MSNSearchService ()

メソッド

名前 説明

MSNSearchService.Search メソッド (Search)

Live Search エンジンに検索要求を送信します。SearchResponse オブジェクト。

解説

MSNSearchService オブジェクトは、MSNSearchService.Search メソッドへの入力パラメータとして SearchRequest オブジェクトを 1 つ受け付けます。各 SearchRequest オブジェクトには、複数の SourceRequest オブジェクトを格納することができます。検索は、MSNSearchService オブジェクトの Service メソッドへのパラメータとして SearchRequest を渡すことにより実行されます。

SearchRequest は単一の SearchResponse に対応し、これには、要求のソースごとに 1 つの SourceResponse オブジェクトが格納されます。

注意

Search メソッドは、同期検索要求を実行しますが、プロキシの生成に使用される SOAP Toolkit によっては、非同期メソッドも使用できます。

この例では、既定のパラメータを使用して Web 検索を実行し、その情報をコンソール ウィンドウに表示します。下記では、MSNSearchService オブジェクトを太字で示しています。

try
{
    MSNSearchService s = new MSNSearchService();
SearchRequest searchRequest = new SearchRequest();
int arraySize = 1;
SourceRequest[] sr = new SourceRequest[arraySize];

sr[0] = new SourceRequest();
sr[0].Source = SourceType.Web;

searchRequest.Query = "Live Search";
searchRequest.Requests = sr;
// Developer Provisioning System で指定されたアプリケーション ID を 二重引用符で囲って 
// SearchRequest の AppID の値として入力します。
searchRequest.AppID = "YOUR_APP_ID_GOES_HERE";
searchRequest.CultureInfo = "en-US";
SearchResponse searchResponse;

searchResponse = s.Search(searchRequest);

foreach (SourceResponse sourceResponse in searchResponse.Responses)
    {
Result[] sourceResults = sourceResponse.Results;
if (sourceResponse.Total > 0)
        {
Console.WriteLine(sourceResponse.Source.ToString() + " - 結果総数:" + sourceResponse.Total.ToString());
Console.WriteLine();
        }
foreach (Result sourceResult in sourceResults)
        {
if ((sourceResult.Title != null) && (sourceResult.Title != String.Empty))
Console.WriteLine("タイトル:" + sourceResult.Title);
if ((sourceResult.Description != null) && (sourceResult.Description != String.Empty))
Console.WriteLine("説明:" + sourceResult.Description);
if ((sourceResult.Url != null) && (sourceResult.Url != String.Empty))
Console.WriteLine("URL:" + sourceResult.Url);
Console.WriteLine("*****************************************************");
        }
    }
Console.WriteLine("終了するにはいずれかのキーを押してください。");
Console.ReadLine();
}
catch (SoapException fault)
{
Console.WriteLine(fault.Detail.InnerText.ToString());
Console.WriteLine("終了するにはいずれかのキーを押してください。");
Console.ReadLine();
}
catch (WebException webx)
{
Console.WriteLine(webx.ToString());
}

以下の出力の例は、このクエリの結果を示します。

Web - 結果総数: 64272757

タイトル:Live Search

説明:Next generation search engine and customizable web portal with news, high-def maps with live traffic, classifieds, and more.

URL:http://www.live.com/

*****************************************************

タイトル:Live Search

説明:Type search term Search ...

URL:http://www.live.com/?scope=maps

*****************************************************

タイトル:Live Local Search

説明:Combines online mapping and local search, uses a scratch pad to take notes, and allows to search questions in a geographical context.

URL:http://local.live.com/

*****************************************************

タイトル:Windows Live Ideas - Homepage

説明:Live Search for mobile - Find just the information you're looking for, no matter where it lives Windows Live for Windows Mobile - Delivering your world of relationships, information, and interests on ...

URL:http://ideas.live.com/

*****************************************************

タイトル:Windows Live Product Search Beta

説明:Refine results by related terms, brand, and seller, and sort by price

URL:http://ideas.live.com/programpage.aspx?versionId=29d745fb-e11a-4228-a48b-5c

1e443ea089

*****************************************************

タイトル:Enterprise Search

説明:Enterprise Search ...Enterprise Search.Information is scattered across the Web, on different computers, devices, intranets ...

URL:https://www.microsoft.com/livesearch/default.mspx

*****************************************************

タイトル:Live Search URL Submission

説明:Generally our web crawler, MSNBot, can find most pages on the Internet.However if your site does not appear on Live Search, you can send us the ad

dress (URL).Type the characters from the picture In ...

URL:http://search.live.com/docs/submit.aspx?FORM=SUNO

*****************************************************

タイトル:Live Search Maps Collection Hub

説明:Welcome to collections.live.com Use Live Search Maps to chart and comment on your favorite restaurants, prepare a guided tour of your hometown, show fellow riders the best bike routes, or plot the ...

URL:http://collections.live.com/

*****************************************************

タイトル:Live Search for mobile

説明:Download free software to your phone to get maps and directions, live traffic and more.

URL:http://mobile.search.live.com/about/

*****************************************************

タイトル:Use Live Search to support Children's Hospital

説明:Live Search contributes to Children's Hospital for each search done from this page ...Live Search and Team Seattle are partnering to benefit Children's Hospital - and you can help.Live ...

URL:http://teamseattle.live.com/Search/Charity/TeamSeattle/Default.aspx

*****************************************************

終了するにはいずれかのキーを押してください。