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
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
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
The last step is to write 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
}
}
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
}
}
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
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.