Axis2サンプル実行

Webサービスのデプロイ

Standard Distribution(axis2-std-0.94-bin.zip)をダウンロードして展開し、sample/userguide にあるサンプルをAxisサーバにデプロイします(aar=Axis Archive)。

AxisサーバへのデプロイはWeb管理画面から可能です。
http://localhost:8080/axis2/admin.jsp

ユーザid:admin、パスワード:axis2 でログインし、「Upload Service」で、MyService.aar をアップロードします。アップロードが完了すると、「Available Services」で MyService が表示され、サービスが追加されたことが確認できます。

Webサービスの実行

userguide のサンプルにはクライアントのソースもあり、Ant で実行することが可能です。
  >ant testEchoBlockingClient

testEchoBlockingClient:
     [java] - Deploying module : addressing
     [java] - Starting to process SOAP 1.1 message
     [java] Axis2 Echo String 

  >ant testEchoNonBlockingClient

testEchoNonBlockingClient:
     [java] - Deploying module : addressing
     [java] - Starting to process SOAP 1.1 message
     [java] 
            
              
                
                  http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous
                
                
                  http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous
                
                
                  http://127.0.0.1:8080/axis2/services/MyService
                
                
                  DCA7D3C239E15C0B87113819808412518
                
                
                  89A25C7AC0B96F1E0D11381980839531
                
              
              
                
                  Axis2 Echo String 
                
              
            

Blocking は同期、NonBlocking は非同期のモデルです。

クライアントコードの確認

Blocking(同期)の場合は、以下のように実行します。

OMElement payload = ClientUtil.getEchoOMElement();
Options options = new Options();
options.setTo(targetEPR);
options.setTransportInProtocol(Constants.TRANSPORT_HTTP);

//Blocking invocation
ServiceClient sender = new ServiceClient();
sender.setOptions(options);
OMElement result = sender.sendReceive(payload);

また、NonBlocking(非同期)の場合は、以下のように実行します。

OMElement payload = ClientUtil.getEchoOMElement();
Options options = new Options();
options.setTo(targetEPR);
options.setTransportInProtocol(Constants.TRANSPORT_HTTP);

//Non-Blocking Invocation
ServiceClient sender = new ServiceClient();
sender.setOptions(options);
sender.sendReceiveNonblocking(payload, callback);

※前後の処理を省略しているので、詳細は以下のファイルを確認してください。
samples/userguide/src/userguide/clients/EchoBlockingClient.java
samples/userguide/src/userguide/clients/EchoNonBlockingClient.java