SlideShare a Scribd company logo
1 of 119
Download to read offline
REVISITED

 KAZUHIRO   FUJIE
intro code
intro digit
intro digit
Try to Create a
WebServices Client


          Kazuhiro Fujie
    Itochu techno-science corporation
Follow the white rabbit.
Follow the white rabbit.
Follow the white rabbit.
quot; Have you ever had a dream,
 Neo, that you were so sure
           was real?
  What if you were unable to
wake from that dream, Neo?
   How would you know the
    difference between the
 dream world and the real. quot;

          Morpheus
quot; You take the blue pill, the
 story ends; you wake up in
    your bed and believe...
whatever you want to believe.
  You take the red pill, you
  stay in Wonderland; and I
   show you how deep the
      rabbit hole goes. quot;

           Morpheus
Red pill or Blue pill.
quot; Remember ... all I'm
offering you is the truth.
     Nothing more. quot;

         Morpheus
グラサン
Web Services Architecture
• よくみる図
                 Broker


                          publish
        find


 Requester                    Provider

               bind


• 初めて観た時は、何だか新しいモノのような気が
  したけど…
quot; There is no spoon. quot;


         Neo
There is no spoon.
Program
• 普通のアプリケーションプログラム
• 一つのマシンで実行する
• ローカルなプログラム

    Main program       Sub program
Program Code
 • ローカルなプログラムの場合、例えば…
/* メインプログラム。サブルーチンを呼び出す。 */
String result = doSpellingSuggestion(quot;britnay sparsquot;);
 :

/* サブルーチン*/
String doSpellingSuggestion(String phrase) {
     特定の機能を担うサブルーチン。
     例えば、スペル候補の処理などを行い結果を返り値として返す。
        return result;
}

 • 同じマシンでしか実行できない…
quot; He was so different.
  He was like you. quot;

      Persephone
Persephone
Separate Ways
• 分散環境のアプリケーションでは?
  – 別々のマシンで実行するために…

                    Socket…
                              Server
 Client




• Socket, PIPE, …
  – 自分で通信のやり取りの中味を考える必要がある。
RPC
      Remote Procedure Call
 • 基本的に同じように簡単に行いたい。
/* メインプログラム。サブルーチンを呼び出す。 */
String result = doSpellingSuggestion(quot;britnay sparsquot;);
 :
             APIのフック
                                       サーバー受信
              通信処理
                                       処理結果送信

/* サブルーチン*/
String doSpellingSuggestion(String phrase) {
     特定の機能を担うサブルーチン。
     例えば、スペル候補の処理などを行い結果を返り値として返す。
        return result;
}
distributed environment
• 分散環境コンピューティング
• プログラムが離れたマシンの上にあるサブ
  ルーチンを、同じマシン上にあるかのよう
  に簡易に呼び出すことができる。
• Remote Procedure Call (RPC)
  – 遠隔手続き呼び出し
• Distributed Object
  – 分散オブジェクト
Genealogy of distributed
      environment
• Sun RPC
  – ONC-RPC Open Network Computing
  – XDR (eXternal Data Representations)
• DCE RPC (OSF)
  – Distributed Computing Environment (DCE)
• CORBA (OMG)
  – CORBA (Common Object Request Broker Architecture)
  – CORBA IDL (Interface Definition Language)
  – IIOP (Internet Inter-ORB Protocol)
• Java RMI
  – Remote Method Invocation (RMI)
  – Java Interface
quot; I’ll let you in on a little secret.
Being the one is just like being
              love.
 No one can tell you you’re in
              love.
      You just knew it…
    through and through.
       Balls to bones. quot;

             The Oracle
Stub / Skeleton
 • 離れていても同じように。

Main program                     Sub program




 • なるべく簡単に出来るための…
Stub / Skeleton ( Tie )
 • そのための仕組み。
               Interface                  Interface
               Language                   Language
Main program                                            Sub program
                           Stub    Skeleton




               Runtime                        Runtime



                             Transport
Web Services
 • JAX-RPC
                WSDL                        WSDL
Web Service                                         Web Service
  Client
                                                   Implementation
Application             Stub
                               Tie (Skeleton)


              JAX-RPC                       JAX-RPC
              Runtime                       Runtime


                         SOAP/HTTP
Twins 1
Twins 2
Twins 3
Twins 4
quot; That’s a nice trick. quot;


         Trinity
Trinity
JAX-RPC
• Java APIs for XML-based RPC
  – JavaでSOAPとWSDLを使った開発ができる。
• Standards
  – JCPによる標準仕様であるJSR 101
• Interoperability
  – クライアントのAPI、ツールやランタイム実装な
    どについて決められてポータブルなアプリケー
    ションを実現できるようにの工夫がされている。
quot; I Love Candy. quot;

    The Oracle
The Oracle
quot; When I see 3 objectives,
   3 captains, 3 ships …
   I do not coincidence.
     I see providence.
      I see purpose. quot;

         Morpheus
3 objectives,
3 captains, 3 ships
The Magi
• 東方の三賢人
 – Gaspar (Caspar), Melchior, Balthazar
• 三種の神器
 – 洗濯機, 冷蔵庫, 白黒テレビ
• Webサービス
 – SOAP, WSDL, UDDI
Web Services Standards
• SOAP
 – Simple Object Access Protocol
• WSDL
 – Web Services Description Language
• UDDI
 – Universal Description, Discovery, and
   Integration
quot; Free your mind quot;

     Morpheus
Morpheus
Web Services Architecture
• もういちど。                UDDI registry


                                   publish
          find

                            WSDL
 Client                                 Service

                 SOAP



• UDDIを無視すれば、RPCと観ることも。
quot; That means buckle your
   seat belt, Dorothy,
 `cause Kansas is going`
       bye-bye.. quot;
         Cypher
Cypher
クライアントを作ってみる。

  Google Web APIs
quot; But this is not a reason,
    this is not a why,
The keymaker himself, his
very nature, is a means, it
     is not an end. quot;

         Merovingian
Google Web Services
• Google Web APIs (beta)
  – Google 提供のWebサービスのベータ版
  – スペルの候補を教えてくれる?みたい。
  – キーワードでの検索などができる?みたい。
• Webサービスのクライアントをつくってみる。
  – 標準であるJAX-RPC のAPIをつかう。
  – 予めStubを作成しておいて、それに面倒な事
    は、お任せしたプログラムを作成する。
Google Step 0/3
• JDK
  – http://java.sun.com/j2se/1.4/

• JWSDP
  – Java Web Services Developer Pack
  – http://java.sun.com/webservices/jwsdp/
  – JAX-RPC API, Runtime, Tools
Google Step 1/3
• サービスのWSDLを入手する。
  – Webサービスを利用するための情報
• Download the developer's kit
  – http://www.google.co.jp/apis/index.html

• アカウントの登録
• ライセンスの取得
  – 検索機能を利用するためのライセンスキー
Google Step 2/3
• スタブクラスの作成
 – WSDLインターフェースからスタブを生成する。
• 公開されているWSDL
 – http://api.google.com/GoogleSearch.wsdl

• ツールでスタブを生成。
 – wscompile で半自動生成。
Google Step 3/3
• クライアントプログラムの作成
 – 必要なパッケージのインポート。
 – スタブクラスのインスタンス生成。
 – エンドポイントアドレスの指定。
 – (遠隔オブジェクトの)メッセージの呼び出し。
• コンパイル
• 実行
Execution Result
quot; Okey, dokey. quot;

      Neo
Neo Jump
やってみましょう。

 Demonstration
quot; I know Kung Fu. quot;

        Neo
Neo
quot; Show me. quot;

  Morpheus
Show me
いまみたこと

 Revisited
WSDLをちょっとのぞく。

  Look into Web Services
   Description Language
WSDL Document Structure
               WSDL Document
                  Types

                  Message

                  Port Type
                      Operation
                  Binding

                  Service
                      Port
Google WSDL
  • http://api.google.com/GoogleSearch.wsdl

<?xml version=quot;1.0quot; ?>

 <!-- Revision 2002-08-16 -->
<definitions name=quot;GoogleSearchquot;
  targetNamespace=quot;urn:GoogleSearchquot;
  xmlns:typens=quot;urn:GoogleSearchquot;
  xmlns:xsd=http://www.w3.org/2001/XMLSchema
  xmlns:soap=http://schemas.xmlsoap.org/wsdl/soap/
  xmlns:soapenc=http://schemas.xmlsoap.org/soap/encoding/
  xmlns:wsdl=http://schemas.xmlsoap.org/wsdl/
  xmlns=quot;http://schemas.xmlsoap.org/wsdl/quot;>
<types>
       :
Google WSDL cont.
 • http://api.google.com/GoogleSearch.wsdl
 :
<!-- Messages for Google Web APIs - cached page, search, spelling.   -->
<message name=quot;doSpellingSuggestionquot;>
 <part name=quot;keyquot; type=quot;xsd:stringquot; />
 <part name=quot;phrasequot; type=quot;xsd:stringquot; />
</message>

<!-- Port for Google Web APIs, quot;GoogleSearchquot;   -->
<portType name=quot;GoogleSearchPortquot;>

<!-- Binding for Google Web APIs - RPC, SOAP over HTTP   -->
<binding name=quot;GoogleSearchBindingquot;
  type=quot;typens:GoogleSearchPortquot;>
:
Google WSDL cont.
  • http://api.google.com/GoogleSearch.wsdl

  :
<!-- Endpoint for Google Web APIs -->
 <service name=quot;GoogleSearchServicequot;>
   <port name=quot;GoogleSearchPortquot;
      binding=quot;typens:GoogleSearchBindingquot;>
    <soap:address location=
       quot;http://api.google.com/search/beta2quot; />
  </port>
 </service>
</definitions>
quot; It is purpose that created us.
   Purpose that connects us.
       Purpose that pull us.
          That guides us.
          That drives us.
   It is purpose that defines.
      Purpose that bind us.quot;

        Smith (not Agent)
スタブを用意する。

Generate Static Stub
Generate Stub
  • WSDLを基にスタブクラスを生成する。

wscompile -verbose -gen:client -d build config-wsdl.xml


  • スタブクラス生成について設定ファイルで
    指示できる。
     – ex. config-wsdl.xml
wscompile configuration
 • wscompile 設定ファイルの例

<?xml version=quot;1.0quot; encoding=quot;UTF-8quot; ?>
<configuration
   xmlns=quot;http://java.sun.com/xml/ns/jax-rpc/ri/configquot;>
   <wsdl location=quot;http://api.google.com/GoogleSearch.wsdlquot;
       packageName=quot;jp.co.ctc_g.atd.google.stubquot; />
</configuration>




 • ダウンロード済みWSDLを指定しても可。
quot; It’s starts so simply…
each line of the program
  creating a new effect,
   just like … poetry. quot;
        Merovingian
starts so simply
クライアントのコードを書く。

Coding a Static Stub Client
Static Stub 1/4
        Creates a Stub object
  • Stubオブジェクトを生成する。
Stub stub =
 (Stub) (new GoogleSearchService_Impl().getGoogleSearchPort());


  • 実装依存のオブジェクトからスタブを生成
    する。
  • 実装依存のオブジェクトは、wscompileに
    よって生成されたもの。
Static Stub 2/4
      Set a endpoint address
  • サービスのアドレスを設定する。
stub._setProperty
 (javax.xml.rpc.Stub.ENDPOINT_ADDRESS_PROPERTY,
   quot;http://api.google.com/search/beta2quot;);



  • アドレスはURLをStringで指定する。
     – http://api.google.com/search/beta2
Static Stub 3/4
      Cast stub to the service
        endpoint interface
  • サービスエンドポイントインターフェースに
    型変換する。
GoogleSearchPort google = (GoogleSearchPort)stub;



  • これで該当のメソッドを呼び出す事が可能。
Static Stub 4/4
              Coding a Client
 • クライアントコードの一部
Stub stub =
 (Stub) (new GoogleSearchService_Impl().getGoogleSearchPort());

endpointAddress = quot;http://api.google.com/search/beta2quot;;
stub._setProperty
   (javax.xml.rpc.Stub.ENDPOINT_ADDRESS_PROPERTY,
    endpointAddress);

 GoogleSearchPort google = (GoogleSearchPort)stub;

 // Call doSpellingSuggestion of Google Web Services
 String result
     = google.doSpellingSuggestion(googleLicenseKey, phrase );
 System.out.println( quot;==> Candidate : quot; + result );
quot; I wrote it myself. quot;


      Merovingian
Merovingian
quot; Have fun. quot;


  Persephone
Persephone
もういちどやってみましょう。

    Reloaded
quot; Almost no one comes down here.
    Unless, of course, there’s a
             problem.
   That’s new it is with people.
  Nobody cares how it works as
        long as it works. quot;

        Councillor Hamann
Councillor Hamann
tcpmon
 • SOAPで通信していることを視認する。
 • tcpmon モニタでやり取りを診る。
set CLASSPATH=%AXIS_HOME%¥lib¥axis.jar
java org.apache.axis.utils.tcpmon



 • Apache AXIS に付属。
 • 多少難在り。
Actual tcpmon
SOAP Request
<?xml version=quot;1.0quot; encoding=quot;UTF-8quot; ?>
 <env:Envelope
  xmlns:env=http://schemas.xmlsoap.org/soap/envelope/
  xmlns:xsd=http://www.w3.org/2001/XMLSchema
  xmlns:xsi=quot;http://www.w3.org/2001/XMLSchema-instancequot;
  xmlns:enc=http://schemas.xmlsoap.org/soap/encoding/
  xmlns:ns0=quot;urn:GoogleSearchquot;
  env:encodingStyle
            =quot;http://schemas.xmlsoap.org/soap/encoding/quot;>
 <env:Body>
   <ns0:doSpellingSuggestion>
    <key xsi:type=quot;xsd:stringquot;>XXXXX</key>
    <phrase xsi:type=quot;xsd:stringquot;>britnay spars</phrase>
   </ns0:doSpellingSuggestion>
  </env:Body>
 </env:Envelope>
SOAP Response

<?xml version=quot;1.0quot; encoding=quot;UTF-8quot; ?>
<SOAP-ENV:Envelope
 xmlns:SOAP-ENV=http://schemas.xmlsoap.org/soap/envelope/
 xmlns:xsi=http://www.w3.org/1999/XMLSchema-instance
 xmlns:xsd=quot;http://www.w3.org/1999/XMLSchemaquot;>
 <SOAP-ENV:Body>
  <ns1:doSpellingSuggestionResponse
   xmlns:ns1=quot;urn:GoogleSearch“
   SOAP-ENV:encodingStyle
        =quot;http://schemas.xmlsoap.org/soap/encoding/quot;>
   <return xsi:type=quot;xsd:stringquot;>britney spears</return>
  </ns1:doSpellingSuggestionResponse>
 </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
quot; Do you proceed? quot;


   Agent (not Smith)
Agents
ふろく

Appendix
クライアントの種類について

Call Model of Web Services
    Client with JAX-RPC
JAX-RPC Client Types
• Static Stub
  – 実行前にスタブを用意しておく。
• Dynamic Proxy
  – 実行前にインターフェースだけが必要。
  – 実行時にプロキシクラスを作成する。
• Dynamic Invocation Interface (DII)
  – 直接ランタイムにアクセスする。
  – 複雑なコーディング。
クライアントのコードを書く。
     其の弐
 Coding a Dynamic Proxy
          Client
Dynamic Proxy 1/2
     Creates a Service object
  • Proxy オブジェクトを生成する。
Service googleService =
 serviceFactory.createService(googleWsdlUrl,
           new QName(nameSpaceUri, serviceName));


  • WSDLアドレスはURLをStringで指定する。
     – http://api.google.com/GoogleSearch.wsdl
  • サービス名、名前空間はWSDLの記載を
    Stringで指定する。
Dynamic Proxy 2/2
    Creates a proxy with a
   service endpoint interface
  • インターフェースオブジェクトを生成する。
GoogleSearchPort googleProxy = (GoogleSearchPort)
  googleService.getPort(new QName(nameSpaceUri, portName),
  GoogleSearchPort.class);



  • getPort メソッドで呼び出す。
  • エンドポイントインターフェースは
    wscompile などで事前に用意が必要。
クライアントのコードを書く。
     其の参
  Coding a DII Client
DII 1/6
    Creates a Service object
 • Serviceオブジェクトを生成する。
Service service =
  factory.createService(new QName(qnameService));




 • サービス名はWSDLでの service name
   を Stringで指定する。
DII 2/6
        Creates a Call object
 • Call オブジェクトを生成する。
String qnamePort = quot;GoogleSearchPortquot;;

QName port = new QName(qnamePort);
Call call = service.createCall(port);


 • ポート名はWSDLでの port name を
   Stringで指定する。
DII 3/6
       Set a endpoint address
  • サービスエンドポイントアドレスを設定する。
call.setTargetEndpointAddress(quot;http://api.google.com/search/beta2quot;);



  • アドレスはURLをStringで指定する。
      – http://api.google.com/search/beta2
DII 4/6
              Set a properties
 • プロパティを設定する。

call.setProperty(Call.SOAPACTION_USE_PROPERTY,
                 new Boolean(true));
call.setProperty(Call.SOAPACTION_URI_PROPERTY, quot;quot;);
call.setProperty(ENCODING_STYLE_PROPERTY,
                 quot;http://schemas.xmlsoap.org/soap/encoding/quot;);



 • 詳細は、SOAP及びWSDLを参照の事。
DII 5/6
          Specify parameter

 • 返り値や引数の型や呼び出すメソッドを指
   定する。
QName QNAME_TYPE_STRING =
                new QName(NS_XSD, quot;stringquot;);
call.setReturnType(QNAME_TYPE_STRING);
call.setOperationName(
  new QName(BODY_NAMESPACE_VALUE, quot;doSpellingSuggestionquot;));
call.addParameter(quot;String_1quot;, QNAME_TYPE_STRING,
                     ParameterMode.IN);
call.addParameter(quot;String_2quot;, QNAME_TYPE_STRING,
                    ParameterMode.IN);
DII 6/6
    Invoke a remote method
  • メソッドを呼び出す。
String googleLicenseKey = “XXXXXXXXXXXXXXquot;;
String phrase = quot;britnay sparsquot;;
String[] params = { googleLicenseKey, phrase };
String result = (String)call.invoke(params);


  • ここではStringの配列で引数を渡す。
  • ここでの返り値はString。
quot; There is a difference
between knowing the road
    and following it. quot;

         Morpheus
Morpheus and Neo
終わりに

Conclusion
Round up
• WebServices は、RPCとも云える
• RPCは、Stub/Skeletonという仕組み
• JAX-RPCは、SOAPとWSDL
• WSDLは、インターフェース
• WSDLは、一番だいじ。
• WSDLからStubができる
• JAX-RPCでクライアントをつくる
Just after this

• サーバーであるサービスをつくる
• 相互運用性について考える
• WSDLを詳しくみる
• SOAPの構造、特徴を調べる
• そして、UDDI?
• BPELとは?
quot; But I can only show you
the door, you have to walk
        through it. quot;

         Morpheus
Morpheus and Neo
Bibliography
• XMLとJavaによるWebアプリケーション開
  発 第2版
 – 丸山 宏ほか
 – ISBN:4-89471-662-3
• Java Webサービス
 – David A.Chappell, Tyler Jewell (著), テ
   クノロジックアート (著), 長瀬 嘉秀 (翻訳)
 – ISBN4-87311-101-3
Philosophy
• EXISTENTIAL PHENOMENOLOGY
  AND THE BRAVE NEW WORLD OF
  THE MATRIX
 – HUBERT DREYFUS & STEPHEN
   DREYFUS
 – http://whatisthematrix.warnerbros.com/

• PHILOSOPHY AND THE MATRIX
 – http://whatisthematrix.warnerbros.com/rl_cm
   p/phi.html
Resources
• Java Technology and Web Services
  – http://java.sun.com/webservices/

• Java API for XML-Based RPC (JAX-
 RPC) Downloads & Specifications
  – http://java.sun.com/xml/downloads/jaxrpc.ht
    ml
Resources
• Google Web APIs (beta)
  – http://www.google.co.jp/apis/index.html

• Apache AXIS
  – http://ws.apache.org/axis/index.html
Resources
• Web Services Description
 Language (WSDL) 1.1
  – http://www.w3.org/TR/wsdl

• Simple Object Access Protocol
  (SOAP) 1.1
  – http://www.w3.org/TR/soap/
quot; You knew what that mean?
         It’s Latin.
  Means, ‘Know thyself’. quot;

         The Oracle
‘Know thyself’
TO BE CONCLUDED.

More Related Content

What's hot

yusukebe in Yokohama.pm 090909
yusukebe in Yokohama.pm 090909yusukebe in Yokohama.pm 090909
yusukebe in Yokohama.pm 090909
Yusuke Wada
 
Ss 36932418[1]
Ss 36932418[1]Ss 36932418[1]
Ss 36932418[1]
Ya Jinda
 
Cancer de-prostata-40601330[1]
Cancer de-prostata-40601330[1]Cancer de-prostata-40601330[1]
Cancer de-prostata-40601330[1]
Ludwing007
 
Web 2.0 Performance and Reliability: How to Run Large Web Apps
Web 2.0 Performance and Reliability: How to Run Large Web AppsWeb 2.0 Performance and Reliability: How to Run Large Web Apps
Web 2.0 Performance and Reliability: How to Run Large Web Apps
adunne
 

What's hot (17)

Implementing SSH in Java
Implementing SSH in JavaImplementing SSH in Java
Implementing SSH in Java
 
Seize The Cloud
Seize The CloudSeize The Cloud
Seize The Cloud
 
Ruby on Rails Tutorial Part I
Ruby on Rails Tutorial Part IRuby on Rails Tutorial Part I
Ruby on Rails Tutorial Part I
 
S2Flex2
S2Flex2S2Flex2
S2Flex2
 
yusukebe in Yokohama.pm 090909
yusukebe in Yokohama.pm 090909yusukebe in Yokohama.pm 090909
yusukebe in Yokohama.pm 090909
 
Web Security Horror Stories
Web Security Horror StoriesWeb Security Horror Stories
Web Security Horror Stories
 
20070329 Phpconf2007 Training
20070329 Phpconf2007 Training20070329 Phpconf2007 Training
20070329 Phpconf2007 Training
 
Mitigating CSRF with two lines of codes
Mitigating CSRF with two lines of codesMitigating CSRF with two lines of codes
Mitigating CSRF with two lines of codes
 
Mockingbirdの実装@拡張機能勉強会
Mockingbirdの実装@拡張機能勉強会Mockingbirdの実装@拡張機能勉強会
Mockingbirdの実装@拡張機能勉強会
 
HTML Parsing With Hpricot
HTML Parsing With HpricotHTML Parsing With Hpricot
HTML Parsing With Hpricot
 
Creating Responsive Experiences
Creating Responsive ExperiencesCreating Responsive Experiences
Creating Responsive Experiences
 
20081123-web2.0class
20081123-web2.0class20081123-web2.0class
20081123-web2.0class
 
Ss 36932418[1]
Ss 36932418[1]Ss 36932418[1]
Ss 36932418[1]
 
Practical django secuirty
Practical django secuirtyPractical django secuirty
Practical django secuirty
 
Cancer de-prostata-40601330[1]
Cancer de-prostata-40601330[1]Cancer de-prostata-40601330[1]
Cancer de-prostata-40601330[1]
 
Web 2.0 Performance and Reliability: How to Run Large Web Apps
Web 2.0 Performance and Reliability: How to Run Large Web AppsWeb 2.0 Performance and Reliability: How to Run Large Web Apps
Web 2.0 Performance and Reliability: How to Run Large Web Apps
 
Task 9
Task 9Task 9
Task 9
 

Viewers also liked

Viewers also liked (9)

Silent Running Side D
Silent Running Side DSilent Running Side D
Silent Running Side D
 
Revolutions The Appendix
Revolutions The AppendixRevolutions The Appendix
Revolutions The Appendix
 
Reloaded
ReloadedReloaded
Reloaded
 
Silent Running Side C
Silent Running Side CSilent Running Side C
Silent Running Side C
 
Silent Running Side A
Silent Running Side ASilent Running Side A
Silent Running Side A
 
Silent Running Prevue Trailer
Silent Running Prevue TrailerSilent Running Prevue Trailer
Silent Running Prevue Trailer
 
What is an Ansible?
What is an Ansible?What is an Ansible?
What is an Ansible?
 
Semantic Wiki: Social Semantic Web in Use
Semantic Wiki: Social Semantic Web in UseSemantic Wiki: Social Semantic Web in Use
Semantic Wiki: Social Semantic Web in Use
 
Where The Cloud Things Are
Where The Cloud Things AreWhere The Cloud Things Are
Where The Cloud Things Are
 

Similar to Revisited

Understanding Web Services
Understanding Web ServicesUnderstanding Web Services
Understanding Web Services
aru85
 
Understanding Web Services
Understanding Web ServicesUnderstanding Web Services
Understanding Web Services
aru85
 
企业级搜索引擎Solr交流
企业级搜索引擎Solr交流企业级搜索引擎Solr交流
企业级搜索引擎Solr交流
chuan liang
 
【13-C-4】 「もう業務はとまらない!オフライン機能を使った業務アプリケーションの実例と最新 Curl 情報」
【13-C-4】 「もう業務はとまらない!オフライン機能を使った業務アプリケーションの実例と最新 Curl 情報」【13-C-4】 「もう業務はとまらない!オフライン機能を使った業務アプリケーションの実例と最新 Curl 情報」
【13-C-4】 「もう業務はとまらない!オフライン機能を使った業務アプリケーションの実例と最新 Curl 情報」
devsumi2009
 
WindowsユーザのためのはじめてのPerlプログラミング
WindowsユーザのためのはじめてのPerlプログラミングWindowsユーザのためのはじめてのPerlプログラミング
WindowsユーザのためのはじめてのPerlプログラミング
Yosuke HASEGAWA
 
20090323 Phpstudy
20090323 Phpstudy20090323 Phpstudy
20090323 Phpstudy
Yusuke Ando
 
Five Minutes Introduction For Rails
Five Minutes Introduction For RailsFive Minutes Introduction For Rails
Five Minutes Introduction For Rails
Koichi ITO
 
11 Ban Net Scaler Xa
11 Ban Net Scaler Xa11 Ban Net Scaler Xa
11 Ban Net Scaler Xa
Liudmila Li
 
【12-D-6】 Silverlight によるハイグレードなLOB/BI実現のためのコンポーネント活用法
【12-D-6】 Silverlight によるハイグレードなLOB/BI実現のためのコンポーネント活用法【12-D-6】 Silverlight によるハイグレードなLOB/BI実現のためのコンポーネント活用法
【12-D-6】 Silverlight によるハイグレードなLOB/BI実現のためのコンポーネント活用法
devsumi2009
 
How To Create Custom DSLs By PHP
How To Create Custom DSLs By PHPHow To Create Custom DSLs By PHP
How To Create Custom DSLs By PHP
Atsuhiro Kubo
 
11 Net Scaler Xa1
11 Net Scaler Xa111 Net Scaler Xa1
11 Net Scaler Xa1
Liudmila Li
 

Similar to Revisited (20)

Understanding Web Services
Understanding Web ServicesUnderstanding Web Services
Understanding Web Services
 
Understanding Web Services
Understanding Web ServicesUnderstanding Web Services
Understanding Web Services
 
企业级搜索引擎Solr交流
企业级搜索引擎Solr交流企业级搜索引擎Solr交流
企业级搜索引擎Solr交流
 
XS Japan 2008 Xen Mgmt Japanese
XS Japan 2008 Xen Mgmt JapaneseXS Japan 2008 Xen Mgmt Japanese
XS Japan 2008 Xen Mgmt Japanese
 
【13-C-4】 「もう業務はとまらない!オフライン機能を使った業務アプリケーションの実例と最新 Curl 情報」
【13-C-4】 「もう業務はとまらない!オフライン機能を使った業務アプリケーションの実例と最新 Curl 情報」【13-C-4】 「もう業務はとまらない!オフライン機能を使った業務アプリケーションの実例と最新 Curl 情報」
【13-C-4】 「もう業務はとまらない!オフライン機能を使った業務アプリケーションの実例と最新 Curl 情報」
 
20090418 イケテルRails勉強会 第2部Air編
20090418 イケテルRails勉強会 第2部Air編20090418 イケテルRails勉強会 第2部Air編
20090418 イケテルRails勉強会 第2部Air編
 
Reification
ReificationReification
Reification
 
WindowsユーザのためのはじめてのPerlプログラミング
WindowsユーザのためのはじめてのPerlプログラミングWindowsユーザのためのはじめてのPerlプログラミング
WindowsユーザのためのはじめてのPerlプログラミング
 
20090323 Phpstudy
20090323 Phpstudy20090323 Phpstudy
20090323 Phpstudy
 
Five Minutes Introduction For Rails
Five Minutes Introduction For RailsFive Minutes Introduction For Rails
Five Minutes Introduction For Rails
 
20090418 イケテルRails勉強会 第1部Rails編
20090418 イケテルRails勉強会 第1部Rails編20090418 イケテルRails勉強会 第1部Rails編
20090418 イケテルRails勉強会 第1部Rails編
 
Web技術勉強会 第19回
Web技術勉強会 第19回Web技術勉強会 第19回
Web技術勉強会 第19回
 
11 Ban Net Scaler Xa
11 Ban Net Scaler Xa11 Ban Net Scaler Xa
11 Ban Net Scaler Xa
 
【12-D-6】 Silverlight によるハイグレードなLOB/BI実現のためのコンポーネント活用法
【12-D-6】 Silverlight によるハイグレードなLOB/BI実現のためのコンポーネント活用法【12-D-6】 Silverlight によるハイグレードなLOB/BI実現のためのコンポーネント活用法
【12-D-6】 Silverlight によるハイグレードなLOB/BI実現のためのコンポーネント活用法
 
Shibuya.abc - Gnashで遊ぼう
Shibuya.abc - Gnashで遊ぼうShibuya.abc - Gnashで遊ぼう
Shibuya.abc - Gnashで遊ぼう
 
How To Create Custom DSLs By PHP
How To Create Custom DSLs By PHPHow To Create Custom DSLs By PHP
How To Create Custom DSLs By PHP
 
Working With Rails
Working With RailsWorking With Rails
Working With Rails
 
Ribbit
RibbitRibbit
Ribbit
 
11 Net Scaler Xa1
11 Net Scaler Xa111 Net Scaler Xa1
11 Net Scaler Xa1
 
テンプレート管理ツール r3
テンプレート管理ツール r3テンプレート管理ツール r3
テンプレート管理ツール r3
 

More from Shunsaku Kudo (6)

Silent Running Side B
Silent Running Side BSilent Running Side B
Silent Running Side B
 
Silent Running Side E Appendix
Silent Running Side E AppendixSilent Running Side E Appendix
Silent Running Side E Appendix
 
Revolutions Side D
Revolutions Side DRevolutions Side D
Revolutions Side D
 
Revolutions Side C
Revolutions Side CRevolutions Side C
Revolutions Side C
 
Revolutions Side B
Revolutions Side BRevolutions Side B
Revolutions Side B
 
Revolutions Side A
Revolutions Side ARevolutions Side A
Revolutions Side A
 

Recently uploaded

Recently uploaded (20)

HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 

Revisited

  • 5. Try to Create a WebServices Client Kazuhiro Fujie Itochu techno-science corporation
  • 9. quot; Have you ever had a dream, Neo, that you were so sure was real? What if you were unable to wake from that dream, Neo? How would you know the difference between the dream world and the real. quot; Morpheus
  • 10. quot; You take the blue pill, the story ends; you wake up in your bed and believe... whatever you want to believe. You take the red pill, you stay in Wonderland; and I show you how deep the rabbit hole goes. quot; Morpheus
  • 11. Red pill or Blue pill.
  • 12. quot; Remember ... all I'm offering you is the truth. Nothing more. quot; Morpheus
  • 14. Web Services Architecture • よくみる図 Broker publish find Requester Provider bind • 初めて観た時は、何だか新しいモノのような気が したけど…
  • 15. quot; There is no spoon. quot; Neo
  • 16. There is no spoon.
  • 18. Program Code • ローカルなプログラムの場合、例えば… /* メインプログラム。サブルーチンを呼び出す。 */ String result = doSpellingSuggestion(quot;britnay sparsquot;); : /* サブルーチン*/ String doSpellingSuggestion(String phrase) { 特定の機能を担うサブルーチン。 例えば、スペル候補の処理などを行い結果を返り値として返す。 return result; } • 同じマシンでしか実行できない…
  • 19. quot; He was so different. He was like you. quot; Persephone
  • 21. Separate Ways • 分散環境のアプリケーションでは? – 別々のマシンで実行するために… Socket… Server Client • Socket, PIPE, … – 自分で通信のやり取りの中味を考える必要がある。
  • 22. RPC Remote Procedure Call • 基本的に同じように簡単に行いたい。 /* メインプログラム。サブルーチンを呼び出す。 */ String result = doSpellingSuggestion(quot;britnay sparsquot;); : APIのフック サーバー受信 通信処理 処理結果送信 /* サブルーチン*/ String doSpellingSuggestion(String phrase) { 特定の機能を担うサブルーチン。 例えば、スペル候補の処理などを行い結果を返り値として返す。 return result; }
  • 23. distributed environment • 分散環境コンピューティング • プログラムが離れたマシンの上にあるサブ ルーチンを、同じマシン上にあるかのよう に簡易に呼び出すことができる。 • Remote Procedure Call (RPC) – 遠隔手続き呼び出し • Distributed Object – 分散オブジェクト
  • 24. Genealogy of distributed environment • Sun RPC – ONC-RPC Open Network Computing – XDR (eXternal Data Representations) • DCE RPC (OSF) – Distributed Computing Environment (DCE) • CORBA (OMG) – CORBA (Common Object Request Broker Architecture) – CORBA IDL (Interface Definition Language) – IIOP (Internet Inter-ORB Protocol) • Java RMI – Remote Method Invocation (RMI) – Java Interface
  • 25. quot; I’ll let you in on a little secret. Being the one is just like being love. No one can tell you you’re in love. You just knew it… through and through. Balls to bones. quot; The Oracle
  • 26. Stub / Skeleton • 離れていても同じように。 Main program Sub program • なるべく簡単に出来るための…
  • 27. Stub / Skeleton ( Tie ) • そのための仕組み。 Interface Interface Language Language Main program Sub program Stub Skeleton Runtime Runtime Transport
  • 28. Web Services • JAX-RPC WSDL WSDL Web Service Web Service Client Implementation Application Stub Tie (Skeleton) JAX-RPC JAX-RPC Runtime Runtime SOAP/HTTP
  • 33. quot; That’s a nice trick. quot; Trinity
  • 35. JAX-RPC • Java APIs for XML-based RPC – JavaでSOAPとWSDLを使った開発ができる。 • Standards – JCPによる標準仕様であるJSR 101 • Interoperability – クライアントのAPI、ツールやランタイム実装な どについて決められてポータブルなアプリケー ションを実現できるようにの工夫がされている。
  • 36. quot; I Love Candy. quot; The Oracle
  • 38. quot; When I see 3 objectives, 3 captains, 3 ships … I do not coincidence. I see providence. I see purpose. quot; Morpheus
  • 40. The Magi • 東方の三賢人 – Gaspar (Caspar), Melchior, Balthazar • 三種の神器 – 洗濯機, 冷蔵庫, 白黒テレビ • Webサービス – SOAP, WSDL, UDDI
  • 41. Web Services Standards • SOAP – Simple Object Access Protocol • WSDL – Web Services Description Language • UDDI – Universal Description, Discovery, and Integration
  • 42. quot; Free your mind quot; Morpheus
  • 44. Web Services Architecture • もういちど。 UDDI registry publish find WSDL Client Service SOAP • UDDIを無視すれば、RPCと観ることも。
  • 45. quot; That means buckle your seat belt, Dorothy, `cause Kansas is going` bye-bye.. quot; Cypher
  • 48. quot; But this is not a reason, this is not a why, The keymaker himself, his very nature, is a means, it is not an end. quot; Merovingian
  • 49. Google Web Services • Google Web APIs (beta) – Google 提供のWebサービスのベータ版 – スペルの候補を教えてくれる?みたい。 – キーワードでの検索などができる?みたい。 • Webサービスのクライアントをつくってみる。 – 標準であるJAX-RPC のAPIをつかう。 – 予めStubを作成しておいて、それに面倒な事 は、お任せしたプログラムを作成する。
  • 50. Google Step 0/3 • JDK – http://java.sun.com/j2se/1.4/ • JWSDP – Java Web Services Developer Pack – http://java.sun.com/webservices/jwsdp/ – JAX-RPC API, Runtime, Tools
  • 51. Google Step 1/3 • サービスのWSDLを入手する。 – Webサービスを利用するための情報 • Download the developer's kit – http://www.google.co.jp/apis/index.html • アカウントの登録 • ライセンスの取得 – 検索機能を利用するためのライセンスキー
  • 52. Google Step 2/3 • スタブクラスの作成 – WSDLインターフェースからスタブを生成する。 • 公開されているWSDL – http://api.google.com/GoogleSearch.wsdl • ツールでスタブを生成。 – wscompile で半自動生成。
  • 53. Google Step 3/3 • クライアントプログラムの作成 – 必要なパッケージのインポート。 – スタブクラスのインスタンス生成。 – エンドポイントアドレスの指定。 – (遠隔オブジェクトの)メッセージの呼び出し。 • コンパイル • 実行
  • 55. quot; Okey, dokey. quot; Neo
  • 58. quot; I know Kung Fu. quot; Neo
  • 59. Neo
  • 60. quot; Show me. quot; Morpheus
  • 63. WSDLをちょっとのぞく。 Look into Web Services Description Language
  • 64. WSDL Document Structure WSDL Document Types Message Port Type Operation Binding Service Port
  • 65. Google WSDL • http://api.google.com/GoogleSearch.wsdl <?xml version=quot;1.0quot; ?> <!-- Revision 2002-08-16 --> <definitions name=quot;GoogleSearchquot; targetNamespace=quot;urn:GoogleSearchquot; xmlns:typens=quot;urn:GoogleSearchquot; xmlns:xsd=http://www.w3.org/2001/XMLSchema xmlns:soap=http://schemas.xmlsoap.org/wsdl/soap/ xmlns:soapenc=http://schemas.xmlsoap.org/soap/encoding/ xmlns:wsdl=http://schemas.xmlsoap.org/wsdl/ xmlns=quot;http://schemas.xmlsoap.org/wsdl/quot;> <types> :
  • 66. Google WSDL cont. • http://api.google.com/GoogleSearch.wsdl : <!-- Messages for Google Web APIs - cached page, search, spelling. --> <message name=quot;doSpellingSuggestionquot;> <part name=quot;keyquot; type=quot;xsd:stringquot; /> <part name=quot;phrasequot; type=quot;xsd:stringquot; /> </message> <!-- Port for Google Web APIs, quot;GoogleSearchquot; --> <portType name=quot;GoogleSearchPortquot;> <!-- Binding for Google Web APIs - RPC, SOAP over HTTP --> <binding name=quot;GoogleSearchBindingquot; type=quot;typens:GoogleSearchPortquot;> :
  • 67. Google WSDL cont. • http://api.google.com/GoogleSearch.wsdl : <!-- Endpoint for Google Web APIs --> <service name=quot;GoogleSearchServicequot;> <port name=quot;GoogleSearchPortquot; binding=quot;typens:GoogleSearchBindingquot;> <soap:address location= quot;http://api.google.com/search/beta2quot; /> </port> </service> </definitions>
  • 68. quot; It is purpose that created us. Purpose that connects us. Purpose that pull us. That guides us. That drives us. It is purpose that defines. Purpose that bind us.quot; Smith (not Agent)
  • 70. Generate Stub • WSDLを基にスタブクラスを生成する。 wscompile -verbose -gen:client -d build config-wsdl.xml • スタブクラス生成について設定ファイルで 指示できる。 – ex. config-wsdl.xml
  • 71. wscompile configuration • wscompile 設定ファイルの例 <?xml version=quot;1.0quot; encoding=quot;UTF-8quot; ?> <configuration xmlns=quot;http://java.sun.com/xml/ns/jax-rpc/ri/configquot;> <wsdl location=quot;http://api.google.com/GoogleSearch.wsdlquot; packageName=quot;jp.co.ctc_g.atd.google.stubquot; /> </configuration> • ダウンロード済みWSDLを指定しても可。
  • 72. quot; It’s starts so simply… each line of the program creating a new effect, just like … poetry. quot; Merovingian
  • 75. Static Stub 1/4 Creates a Stub object • Stubオブジェクトを生成する。 Stub stub = (Stub) (new GoogleSearchService_Impl().getGoogleSearchPort()); • 実装依存のオブジェクトからスタブを生成 する。 • 実装依存のオブジェクトは、wscompileに よって生成されたもの。
  • 76. Static Stub 2/4 Set a endpoint address • サービスのアドレスを設定する。 stub._setProperty (javax.xml.rpc.Stub.ENDPOINT_ADDRESS_PROPERTY, quot;http://api.google.com/search/beta2quot;); • アドレスはURLをStringで指定する。 – http://api.google.com/search/beta2
  • 77. Static Stub 3/4 Cast stub to the service endpoint interface • サービスエンドポイントインターフェースに 型変換する。 GoogleSearchPort google = (GoogleSearchPort)stub; • これで該当のメソッドを呼び出す事が可能。
  • 78. Static Stub 4/4 Coding a Client • クライアントコードの一部 Stub stub = (Stub) (new GoogleSearchService_Impl().getGoogleSearchPort()); endpointAddress = quot;http://api.google.com/search/beta2quot;; stub._setProperty (javax.xml.rpc.Stub.ENDPOINT_ADDRESS_PROPERTY, endpointAddress); GoogleSearchPort google = (GoogleSearchPort)stub; // Call doSpellingSuggestion of Google Web Services String result = google.doSpellingSuggestion(googleLicenseKey, phrase ); System.out.println( quot;==> Candidate : quot; + result );
  • 79. quot; I wrote it myself. quot; Merovingian
  • 81. quot; Have fun. quot; Persephone
  • 84. quot; Almost no one comes down here. Unless, of course, there’s a problem. That’s new it is with people. Nobody cares how it works as long as it works. quot; Councillor Hamann
  • 86. tcpmon • SOAPで通信していることを視認する。 • tcpmon モニタでやり取りを診る。 set CLASSPATH=%AXIS_HOME%¥lib¥axis.jar java org.apache.axis.utils.tcpmon • Apache AXIS に付属。 • 多少難在り。
  • 88. SOAP Request <?xml version=quot;1.0quot; encoding=quot;UTF-8quot; ?> <env:Envelope xmlns:env=http://schemas.xmlsoap.org/soap/envelope/ xmlns:xsd=http://www.w3.org/2001/XMLSchema xmlns:xsi=quot;http://www.w3.org/2001/XMLSchema-instancequot; xmlns:enc=http://schemas.xmlsoap.org/soap/encoding/ xmlns:ns0=quot;urn:GoogleSearchquot; env:encodingStyle =quot;http://schemas.xmlsoap.org/soap/encoding/quot;> <env:Body> <ns0:doSpellingSuggestion> <key xsi:type=quot;xsd:stringquot;>XXXXX</key> <phrase xsi:type=quot;xsd:stringquot;>britnay spars</phrase> </ns0:doSpellingSuggestion> </env:Body> </env:Envelope>
  • 89. SOAP Response <?xml version=quot;1.0quot; encoding=quot;UTF-8quot; ?> <SOAP-ENV:Envelope xmlns:SOAP-ENV=http://schemas.xmlsoap.org/soap/envelope/ xmlns:xsi=http://www.w3.org/1999/XMLSchema-instance xmlns:xsd=quot;http://www.w3.org/1999/XMLSchemaquot;> <SOAP-ENV:Body> <ns1:doSpellingSuggestionResponse xmlns:ns1=quot;urn:GoogleSearch“ SOAP-ENV:encodingStyle =quot;http://schemas.xmlsoap.org/soap/encoding/quot;> <return xsi:type=quot;xsd:stringquot;>britney spears</return> </ns1:doSpellingSuggestionResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
  • 90. quot; Do you proceed? quot; Agent (not Smith)
  • 93. クライアントの種類について Call Model of Web Services Client with JAX-RPC
  • 94. JAX-RPC Client Types • Static Stub – 実行前にスタブを用意しておく。 • Dynamic Proxy – 実行前にインターフェースだけが必要。 – 実行時にプロキシクラスを作成する。 • Dynamic Invocation Interface (DII) – 直接ランタイムにアクセスする。 – 複雑なコーディング。
  • 95. クライアントのコードを書く。 其の弐 Coding a Dynamic Proxy Client
  • 96. Dynamic Proxy 1/2 Creates a Service object • Proxy オブジェクトを生成する。 Service googleService = serviceFactory.createService(googleWsdlUrl, new QName(nameSpaceUri, serviceName)); • WSDLアドレスはURLをStringで指定する。 – http://api.google.com/GoogleSearch.wsdl • サービス名、名前空間はWSDLの記載を Stringで指定する。
  • 97. Dynamic Proxy 2/2 Creates a proxy with a service endpoint interface • インターフェースオブジェクトを生成する。 GoogleSearchPort googleProxy = (GoogleSearchPort) googleService.getPort(new QName(nameSpaceUri, portName), GoogleSearchPort.class); • getPort メソッドで呼び出す。 • エンドポイントインターフェースは wscompile などで事前に用意が必要。
  • 98. クライアントのコードを書く。 其の参 Coding a DII Client
  • 99. DII 1/6 Creates a Service object • Serviceオブジェクトを生成する。 Service service = factory.createService(new QName(qnameService)); • サービス名はWSDLでの service name を Stringで指定する。
  • 100. DII 2/6 Creates a Call object • Call オブジェクトを生成する。 String qnamePort = quot;GoogleSearchPortquot;; QName port = new QName(qnamePort); Call call = service.createCall(port); • ポート名はWSDLでの port name を Stringで指定する。
  • 101. DII 3/6 Set a endpoint address • サービスエンドポイントアドレスを設定する。 call.setTargetEndpointAddress(quot;http://api.google.com/search/beta2quot;); • アドレスはURLをStringで指定する。 – http://api.google.com/search/beta2
  • 102. DII 4/6 Set a properties • プロパティを設定する。 call.setProperty(Call.SOAPACTION_USE_PROPERTY, new Boolean(true)); call.setProperty(Call.SOAPACTION_URI_PROPERTY, quot;quot;); call.setProperty(ENCODING_STYLE_PROPERTY, quot;http://schemas.xmlsoap.org/soap/encoding/quot;); • 詳細は、SOAP及びWSDLを参照の事。
  • 103. DII 5/6 Specify parameter • 返り値や引数の型や呼び出すメソッドを指 定する。 QName QNAME_TYPE_STRING = new QName(NS_XSD, quot;stringquot;); call.setReturnType(QNAME_TYPE_STRING); call.setOperationName( new QName(BODY_NAMESPACE_VALUE, quot;doSpellingSuggestionquot;)); call.addParameter(quot;String_1quot;, QNAME_TYPE_STRING, ParameterMode.IN); call.addParameter(quot;String_2quot;, QNAME_TYPE_STRING, ParameterMode.IN);
  • 104. DII 6/6 Invoke a remote method • メソッドを呼び出す。 String googleLicenseKey = “XXXXXXXXXXXXXXquot;; String phrase = quot;britnay sparsquot;; String[] params = { googleLicenseKey, phrase }; String result = (String)call.invoke(params); • ここではStringの配列で引数を渡す。 • ここでの返り値はString。
  • 105. quot; There is a difference between knowing the road and following it. quot; Morpheus
  • 108. Round up • WebServices は、RPCとも云える • RPCは、Stub/Skeletonという仕組み • JAX-RPCは、SOAPとWSDL • WSDLは、インターフェース • WSDLは、一番だいじ。 • WSDLからStubができる • JAX-RPCでクライアントをつくる
  • 109. Just after this • サーバーであるサービスをつくる • 相互運用性について考える • WSDLを詳しくみる • SOAPの構造、特徴を調べる • そして、UDDI? • BPELとは?
  • 110. quot; But I can only show you the door, you have to walk through it. quot; Morpheus
  • 112. Bibliography • XMLとJavaによるWebアプリケーション開 発 第2版 – 丸山 宏ほか – ISBN:4-89471-662-3 • Java Webサービス – David A.Chappell, Tyler Jewell (著), テ クノロジックアート (著), 長瀬 嘉秀 (翻訳) – ISBN4-87311-101-3
  • 113. Philosophy • EXISTENTIAL PHENOMENOLOGY AND THE BRAVE NEW WORLD OF THE MATRIX – HUBERT DREYFUS & STEPHEN DREYFUS – http://whatisthematrix.warnerbros.com/ • PHILOSOPHY AND THE MATRIX – http://whatisthematrix.warnerbros.com/rl_cm p/phi.html
  • 114. Resources • Java Technology and Web Services – http://java.sun.com/webservices/ • Java API for XML-Based RPC (JAX- RPC) Downloads & Specifications – http://java.sun.com/xml/downloads/jaxrpc.ht ml
  • 115. Resources • Google Web APIs (beta) – http://www.google.co.jp/apis/index.html • Apache AXIS – http://ws.apache.org/axis/index.html
  • 116. Resources • Web Services Description Language (WSDL) 1.1 – http://www.w3.org/TR/wsdl • Simple Object Access Protocol (SOAP) 1.1 – http://www.w3.org/TR/soap/
  • 117. quot; You knew what that mean? It’s Latin. Means, ‘Know thyself’. quot; The Oracle