You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ws.apache.org by Apache Wiki <wi...@apache.org> on 2005/04/05 11:56:09 UTC

[Ws Wiki] Update of "ja/axis/AxisClientConfiguration" by ToshiyukiKimura

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Ws Wiki" for change notification.

The following page has been changed by ToshiyukiKimura:
http://wiki.apache.org/ws/ja/axis/AxisClientConfiguration

The comment on the change is:
Axis Wiki in Japanese

New page:
##language:ja

'''質問: Axis クライアントでどのようにしてハンドラを設定すればいいのですか?'''

サービスオブジェクトをインスタンス化する際に、自分用の{{{EngineConfiguration}}}を提供します。自分用の設定を構築する方法はいくつかあります。

サーバ側のデプロイメントディスクリプタのように、WSDD-XML を使用する。 
この例は{{{HTTP-transport-chain}}}のリクエストフローとレスポンスフローにおける{{{SimpleSessionHandler}}}を設定します。

{{{
     <deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="..." >
       <handler type="java:org.apache.axis.handlers.SimpleSessionHandler"
                name="SimpleSessionHandler"/>
       <transport name="http"
                  pivot="java:org.apache.axis.transport.http.HTTPSender">
         <requestFlow><handler type="SimpleSessionHandler"/></requestFlow>
         <responseFlow><handler type="SimpleSessionHandler"/></responseFlow>
       </transport>"
     </deployment>
}}}

この与えられた文字列から{{{EngineConfiguration}}}を得るコードは次のようになります。 

{{{
     EngineConfiguration clientConfig = (EngineConfiguration) new XMLStringProvider(WSDDString);
}}}

{{{EngineConfiguration}}}インターフェースを実装する自分用のクラスを構築します。 
部分的に設定可能な既存の{{{EngineConfiguration}}}クラスを使用します。 
例えば{{{SimpleProvider}}}は{{{Transport chain}}}のデプロイを認めます。 
以下の例は上記の WSDD と同じことを行います。

{{{
     import org.apache.axis.configuration.SimpleProvider;
     import org.apache.axis.EngineConfiguration;
     import org.apache.axis.Handler;
     import org.apache.axis.SimpleChain;
     import org.apache.axis.SimpleTargetedChain;
     import org.apache.axis.handlers.SimpleSessionHandler;
     import org.apache.axis.transport.http.HTTPSender;
     import org.apache.axis.transport.http.HTTPTransport;

     EngineConfiguration createClientConfig()
     {
       SimpleProvider clientConfig=new SimpleProvider();
       Handler sessionHandler=(Handler)new SimpleSessionHandler();
       SimpleChain reqHandler=new SimpleChain();
       SimpleChain respHandler=new SimpleChain();
       reqHandler.addHandler(sessionHandler);
       respHandler.addHandler(sessionHandler);
       Handler pivot=(Handler)new HTTPSender();
       Handler transport=new SimpleTargetedChain(reqHandler, pivot, respHandler);
       clientConfig.deployTransport(HTTPTransport.DEFAULT_TRANSPORT_NAME,transport);

       return clientConfig;   
     }
}}}

{{{WSDL2Java}}}が生成したコードを使用する際、{{{(Service を拡張した) XYServiceLocator}}}は設定を与えるコンストラクタを提供しません。生成されたコードを修正したくなければ、以下のようにして対処することができます。

{{{
        EngineConfiguration clientConfig=getClientConfig();
       XYServiceLocator service=new XYServiceLocator();
       service.setEngineConfiguration(clientConfig);
       service.setEngine(new AxisClient(clientConfig));
       XY myservice=service.getmyservice();
}}}