|
⇤ ← Revision 1 as of 2005-04-05 09:56:09
Size: 3332
Comment: Axis Wiki in Japanese
|
← Revision 2 as of 2009-09-20 22:47:16 ⇥
Size: 3332
Comment: converted to 1.6 markup
|
| No differences found! | |
質問: 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();