Webサービスを利用するWebサービスクライアントの実装クラスを作成します。
Webサービスに対して1回の呼び出しをするWebサービスクライアントの実装クラスの作成例を次に示します。
package com.example.sample.client;
import com.example.sample.TestJaxWs;
import com.example.sample.TestJaxWsService;
import com.example.sample.UserDefinedException;
public class TestClient {
public static void main( String[] args ) {
try {
TestJaxWsService service = new TestJaxWsService();
TestJaxWs port = service.getTestJaxWs();
String returnValue = port.jaxWsTest1( "Invocation test.", 1003 );
System.out.println( "[RESULT] " + returnValue );
}
catch( UserDefinedException e ){
e.printStackTrace();
}
}
} |
作成したTestClient.javaは,UTF-8形式でc:¥temp¥jaxws¥works¥wsrm¥client¥src¥com¥example¥sample¥client¥ディレクトリに保存します。com.example.sample,TestJaxWs,TestJaxWsService,TestJaxWs,およびjaxWsTest1は,生成されたJavaソースのパッケージ名,クラス名,およびクラス内のメソッド名によって変わります。異なる構成のWebサービスを開発する場合には,パッケージ名,クラス名,およびクラス内のメソッド名の記述を見直す必要があります。