35.5.3 Webサービスクライアントの実装クラスにシーケンス終了処理を追加する

Webサービスクライアントの実装クラスに,シーケンス終了処理を追加します。シーケンス終了処理の追加例を次に示します。

package com.example.sample.client;

import com.example.sample.TestJaxWs;
import com.example.sample.TestJaxWsService;
import com.example.sample.UserDefinedException;
import com.sun.xml.ws.Closeable;

public class TestClient {
   public static void main( String[] args ) {
       TestJaxWsService service = null;
       TestJaxWs port = null;
       try {
           service = new TestJaxWsService();
           port = service.getTestJaxWs();
           
           String returnValue = port.jaxWsTest1( "Invocation test.", 1003 );
           
           System.out.println( "[RESULT] " + returnValue );
       }
       catch( UserDefinedException e ){
           e.printStackTrace();
       }
       finally {
           if( port != null ) {
               ((Closeable)port).close();
           }
       }
   }

}