8.2. JAX-WS クライアントアーティファクトの生成

通常の JAX-WS クライアントを記述する前に、WSDL からクライアントアーティファクトを生成する必要があります。これを実現するコマンドは以下のとおりです。
cd $JBOSS_HOME/bin
./wsconsume.sh --keep \          
   --package=org.jboss.test.ws.jaxws.samples.wsrm.generated \
   --output=/home/username/wsrm/cxf/wsconsume/generated/classes \
   --source=/home/username/wsrm/cxf/wsconsume/generated/src \
   /home/username/wsrm/cxf/wsprovide/generated/wsdl/SimpleService.wsdl
生成されたアーティファクトは以下のとおりです。
コンパイルされたクラス
Echo.class
ObjectFactory.class
Ping.class
SimpleService_Service.class
EchoResponse.class
package-info.class
SimpleService.class
SimpleService_SimpleServicePort_Client.class
Java ソース
Echo.java
ObjectFactory.java
Ping.java
SimpleService_Service.java
EchoResponse.java
package-info.java
SimpleService.java
SimpleService_SimpleServicePort_Client.java
最後の手順は、生成されたアーティファクトを使用して通常の JAX-WS クライアントを記述することです。
通常の JAX-WS クライアントの記述

以下は、生成されたアーティファクトを使用した通常の JAX-WS クライアントです。

package org.jboss.test.ws.jaxws.samples.wsrm.client;

import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import org.jboss.test.ws.jaxws.samples.wsrm.generated.SimpleService;

public final class SimpleServiceTestCase
{

   private static final String serviceURL = "http://localhost:8080/jaxws-samples-wsrm/SimpleService";
   
   public static void main(String[] args) throws Exception
   {
      // create service
      QName serviceName = new QName("http://www.jboss.org/jbossws/ws-extensions/wsrm", "SimpleService");
      URL wsdlURL = new URL(serviceURL + "?wsdl");
      Service service = Service.create(wsdlURL, serviceName);
      SimpleService proxy = (SimpleService)service.getPort(SimpleService.class);
      
      // invoke methods
      proxy.ping(); // one way call
      proxy.echo("Hello World!"); // request responce call
   }
   
}
この時点で、エンドポイントおよび clinet 実装の両方が存在しますが、WS-Reliable Messaging は使用されません。次の目標は、WS-RM 機能を有効にすることです。