Show Table of Contents
8.2. Generating JAX-WS Client Artifacts
Before we write the regular JAX-WS client we need to generate client artifacts from WSDL. Here's the command to achieve that:
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
The artifacts that have been generated are below.
- Compiled classes
- Echo.classObjectFactory.classPing.classSimpleService_Service.classEchoResponse.classpackage-info.classSimpleService.classSimpleService_SimpleServicePort_Client.class
- Java sources
- Echo.javaObjectFactory.javaPing.javaSimpleService_Service.javaEchoResponse.javapackage-info.javaSimpleService.javaSimpleService_SimpleServicePort_Client.java
The last step is to write the regular JAX-WS client using generated artifacts.
Writing Regular JAX-WS Client
The following is the regular JAX-WS client using generated artifacts:
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
}
}
Now we have both endpoint and client implementations but without WS-Reliable Messaging in place. Our next goal is to turn on the WS-RM feature.

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.