// 下階層用テンプレート
#topicpath
----
//ここにコンテンツを記述します。
#contents

***Google Web APIsってなんなの [#l56885ab]
Google Web APIsとはGoogleの検索機能をWebサービスAPIを通じて使用できるというモノです。なんだか、とても楽しいことができる気がします。


**とりあえず、使ってみる。 [#le1bea50]
ライセンスの取得(無料)と、APIのダウンロードをするだけみたいです。
http://www.google.com/apis/index.htmlにアクセスし、メニューより
-ライセンスの取得
-APIのダウンロード
をすることができます。

***サンプルをたたいてみる。 [#j2a30797]
ダウンロードしたファイル内にはサンプルが含まれています。とりあえず使ってみました。
 java -cp googleapi.jar com.google.soap.search.GoogleAPIDemo 
 "ライセンスキー" search "きのさいと"
ってやってみると、結果が返ってきました。。

 Parameters:
 Client key = xxxxxxxxxxxxxxxxxxxxx
 Directive  = search
 Args       = きのさいと
 Google Search Results:
 ======================
 {
 TM = 0.632057
 Q  = "きのさいと"
 CT = ""
 TT = ""
 CATs =
   {
   <EMPTY>
   }
 Start Index = 1
 End   Index = 10
 Estimated Total Results Number = 21
 Document Filtering = true
 Estimate Correct = false
 Rs =
   {
   
   [
   URL  = "http://kino.mine.nu/pukiwiki/index.php"
   URL  = "http://www.masatom.in/pukiwiki/index.php"
   Title = "FrontPage - <b>きの</b><b>さいと</b> Wiki"
   Snippet = " <b>...</b> クラス図の基礎(3). edit ページ名
   変更. 使用中のひと:2<br> 人. ようこそ「<b>きの</b>
   <b>さいと</b>」へ. このサイトはMasatomi KINO <b>...</b>  "
   Directory Category = {SE="", FVN=""}
   Directory Title = ""
   Summary = ""
   Cached Size = "46k"
   Related information present = true
   Host Name = ""
   ],
   
 
   [
   URL  = "http://search.goo.ne.jp/web.jsp?TAB=&MT=frontpage+apache"
   Title = "[frontpage apache] goo ウェブ検索結果"
   Snippet = " <b>...</b> サイトとして動かす方 法。. ...
   http://qwik.jp/ - 7k - キャッ<br> シュ - 別ウィンドウ
   表示. 7 FrontPage - <b>きの</b><b>さいと</b>
    Wiki ... JDIC <b>...</b>  "
   Directory Category = {SE="", FVN=""}
   Directory Title = ""
   Summary = ""
   Cached Size = "36k"
   Related information present = true
   Host Name = ""
   ],
   
 
   
   URL  = "http://yoichiro.cocolog-nifty.com/eclipse/"
   Title = "Eclipseプラグイン開発"
   Snippet = "Eclipseプラグイン開発. Eclipseプラグイン
   開発は至難の業!?<br>日々の苦悩から技術を蓄積する
   ために綴る日記です。. <b>...</b>  "
   Directory Category = {SE="", FVN=""}
   Directory Title = ""
   Summary = ""
   Cached Size = "38k"
   Related information present = true
   Host Name = ""
   ]
   }
 }
これはおもろいかもー


**Apache Axisを使う [#ea78a4dc]
http://archive.apache.org/dist/ws/axis/1_2RC2/ よりダウンロードしてApache Axisのランタイムを使ってみました。

***WSDLからJavaスタブを作る [#zbb6ea53]
 java org.apache.axis.wsdl.WSDL2Java -p nu.mine.kino.googleapis GoogleSearch.wsdl
パスはあらかじめライブラリに通しておきましょう((Eclipse上でJavaアプリ実行をやるのが楽かな))。

ちなみに引数でwsdlを指定しますがhttp://で始めればインタネット上のファイルを指定することもできます。

***Axisランタイムのサンプルプログラム [#p0578bf7]
 public class TestMain {
   public static void main(String[] args) throws ServiceException,
       RemoteException {
 
     GoogleSearchServiceLocator locator = new GoogleSearchServiceLocator();
     //    locator.setGoogleSearchPortEndpointAddress();
 
     GoogleSearchPort googleSearch = locator.getGoogleSearchPort();
 
     GoogleSearchResult result = googleSearch.doGoogleSearch(
         "xxxxxxxxxxxxxx", "きのさいと", 1, 10, false, "",
         false, "", "", "");
     ResultElement[] elements = result.getResultElements();
     for (int i = 0; i < elements.length; i++) {
       ResultElement element = elements[i];
       System.out.println("-----------------------------------");
       System.out.println("タイトル: " + element.getTitle());
       System.out.println("URL: " + element.getURL());
       System.out.println("サマリー: " + element.getSummary());
     }
   }
 }

***プロクシ越えとか [#c880d77f]
プロクシーとか、プロクシ認証とかの設定方法がわかりません。とりあえず、[[Java/TIPS集#u29f0f6c]]













**関連リンク [#c38da36a]
-[[Apache Axis 日本語サイト:http://ws.apache.org/axis/jp/]]
-[[試して学ぶJ2EE:http://www.javadeveloper.jp/members/regular/Rensai.category_rensai_article_j2ee_issue_11.dhtml]]


----
この記事は
#vote(おもしろかった,そうでもない)
-http://myblog.es/bthvan  <a href="http://myblog.es/bthvan">bathroom vanities</a> bathroom vanities -- [[bathroom vanities]] &new{2006-12-15 12:18:07 (金)};
-http://myblog.es/criscard  <a href="http://myblog.es/criscard">christmas cards</a> christmas cards -- [[christmas cards]] &new{2006-12-15 12:55:12 (金)};
-http://urlkick.com/e2c   <a href="http://urlkick.com/e2c">free ringtones</a> free ringtones -- [[free ringtones]] &new{2006-12-16 05:24:09 (土)};

#comment
#vote(おもしろかった[1],そうでもない[1])
#topicpath


SIZE(10){現在のアクセス:&counter;}


トップ   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS