In this sample we show you how to create client and endpoint communication using WS-Reliable Messaging 1.1. Creating the WS-RM based service and client is very simple. The user needs to create regular JAX-WS service and client first. The last step is to configure WS-RM.
We will start with the following endpoint implementation:
package org.jboss.test.ws.jaxws.samples.wsrm.service;
import javax.jws.Oneway;
import javax.jws.WebMethod;
import javax.jws.WebService;
@WebService
(
name = "SimpleService",
serviceName = "SimpleService",
targetNamespace = "http://www.jboss.org/jbossws/ws-extensions/wsrm"
)
public class SimpleServiceImpl
{
@Oneway
@WebMethod
public void ping()
{
System.out.println("ping()");
}
@WebMethod
public String echo(String s)
{
System.out.println("echo(" + s + ")");
return s;
}
}
package org.jboss.test.ws.jaxws.samples.wsrm.service;
import javax.jws.Oneway;
import javax.jws.WebMethod;
import javax.jws.WebService;
@WebService
(
name = "SimpleService",
serviceName = "SimpleService",
targetNamespace = "http://www.jboss.org/jbossws/ws-extensions/wsrm"
)
public class SimpleServiceImpl
{
@Oneway
@WebMethod
public void ping()
{
System.out.println("ping()");
}
@WebMethod
public String echo(String s)
{
System.out.println("echo(" + s + ")");
return s;
}
}
Copy to ClipboardCopied!Toggle word wrapToggle overflow
Let's say that compiled endpoint class is in directory /home/username/wsrm/cxf/classes. Our next step is to generate JAX-WS artifacts and WSSDL.
Copy to ClipboardCopied!Toggle word wrapToggle overflow
The above command generates the following artifacts:
Compiled classes
Echo.class
Echo response.class
Ping.class
Java sources
Echo.java
EchoResponse.java
Ping.java
Contract artifacts
SimpleService.wsdl
The artifacts generated above will be part of the endpoint archive, but before we create the endpoint archive we need to reference generated WSDL from the endpoint. To achieve that we will use the wsdlLocation annotation attribute. Here's the updated endpoint implementation before it is packaged to the war file:
package org.jboss.test.ws.jaxws.samples.wsrm.service;
import javax.jws.Oneway;
import javax.jws.WebMethod;
import javax.jws.WebService;
@WebService
(
name = "SimpleService",
serviceName = "SimpleService",
wsdlLocation = "WEB-INF/wsdl/SimpleService.wsdl",
targetNamespace = "http://www.jboss.org/jbossws/ws-extensions/wsrm"
)
public class SimpleServiceImpl
{
@Oneway
@WebMethod
public void ping()
{
System.out.println("ping()");
}
@WebMethod
public String echo(String s)
{
System.out.println("echo(" + s + ")");
return s;
}
}
package org.jboss.test.ws.jaxws.samples.wsrm.service;
import javax.jws.Oneway;
import javax.jws.WebMethod;
import javax.jws.WebService;
@WebService
(
name = "SimpleService",
serviceName = "SimpleService",
wsdlLocation = "WEB-INF/wsdl/SimpleService.wsdl",
targetNamespace = "http://www.jboss.org/jbossws/ws-extensions/wsrm"
)
public class SimpleServiceImpl
{
@Oneway
@WebMethod
public void ping()
{
System.out.println("ping()");
}
@WebMethod
public String echo(String s)
{
System.out.println("echo(" + s + ")");
return s;
}
}
Copy to ClipboardCopied!Toggle word wrapToggle overflow
The created endpoint war archive consists of the following entries:
jar -tvf jaxws-samples-wsrm.war
0 Wed Apr 16 14:39:22 CEST 2008 META-INF/
106 Wed Apr 16 14:39:20 CEST 2008 META-INF/MANIFEST.MF
0 Wed Apr 16 14:39:22 CEST 2008 WEB-INF/
591 Wed Apr 16 14:39:20 CEST 2008 WEB-INF/web.xml
0 Wed Apr 16 14:39:22 CEST 2008 WEB-INF/classes/
0 Wed Apr 16 14:39:18 CEST 2008 WEB-INF/classes/org/
0 Wed Apr 16 14:39:18 CEST 2008 WEB-INF/classes/org/jboss/
0 Wed Apr 16 14:39:18 CEST 2008 WEB-INF/classes/org/jboss/test/
0 Wed Apr 16 14:39:18 CEST 2008 WEB-INF/classes/org/jboss/test/ws/
0 Wed Apr 16 14:39:20 CEST 2008 WEB-INF/classes/org/jboss/test/ws/jaxws/
0 Wed Apr 16 14:39:20 CEST 2008 WEB-INF/classes/org/jboss/test/ws/jaxws/samples/
0 Wed Apr 16 14:39:18 CEST 2008 WEB-INF/classes/org/jboss/test/ws/jaxws/samples/wsrm/
0 Wed Apr 16 14:39:18 CEST 2008 WEB-INF/classes/org/jboss/test/ws/jaxws/samples/wsrm/service/
0 Wed Apr 16 14:39:18 CEST 2008 WEB-INF/classes/org/jboss/test/ws/jaxws/samples/wsrm/service/jaxws/
1235 Wed Apr 16 14:39:18 CEST 2008 WEB-INF/classes/org/jboss/test/ws/jaxws/samples/wsrm/service/SimpleServiceImpl.class
997 Wed Apr 16 14:39:18 CEST 2008 WEB-INF/classes/org/jboss/test/ws/jaxws/samples/wsrm/service/jaxws/Echo.class
1050 Wed Apr 16 14:39:18 CEST 2008 WEB-INF/classes/org/jboss/test/ws/jaxws/samples/wsrm/service/jaxws/EchoResponse.class
679 Wed Apr 16 14:39:18 CEST 2008 WEB-INF/classes/org/jboss/test/ws/jaxws/samples/wsrm/service/jaxws/Ping.class
0 Wed Apr 16 14:39:22 CEST 2008 WEB-INF/wsdl/
2799 Wed Apr 16 14:39:20 CEST 2008 WEB-INF/wsdl/SimpleService.wsdl
jar -tvf jaxws-samples-wsrm.war
0 Wed Apr 16 14:39:22 CEST 2008 META-INF/
106 Wed Apr 16 14:39:20 CEST 2008 META-INF/MANIFEST.MF
0 Wed Apr 16 14:39:22 CEST 2008 WEB-INF/
591 Wed Apr 16 14:39:20 CEST 2008 WEB-INF/web.xml
0 Wed Apr 16 14:39:22 CEST 2008 WEB-INF/classes/
0 Wed Apr 16 14:39:18 CEST 2008 WEB-INF/classes/org/
0 Wed Apr 16 14:39:18 CEST 2008 WEB-INF/classes/org/jboss/
0 Wed Apr 16 14:39:18 CEST 2008 WEB-INF/classes/org/jboss/test/
0 Wed Apr 16 14:39:18 CEST 2008 WEB-INF/classes/org/jboss/test/ws/
0 Wed Apr 16 14:39:20 CEST 2008 WEB-INF/classes/org/jboss/test/ws/jaxws/
0 Wed Apr 16 14:39:20 CEST 2008 WEB-INF/classes/org/jboss/test/ws/jaxws/samples/
0 Wed Apr 16 14:39:18 CEST 2008 WEB-INF/classes/org/jboss/test/ws/jaxws/samples/wsrm/
0 Wed Apr 16 14:39:18 CEST 2008 WEB-INF/classes/org/jboss/test/ws/jaxws/samples/wsrm/service/
0 Wed Apr 16 14:39:18 CEST 2008 WEB-INF/classes/org/jboss/test/ws/jaxws/samples/wsrm/service/jaxws/
1235 Wed Apr 16 14:39:18 CEST 2008 WEB-INF/classes/org/jboss/test/ws/jaxws/samples/wsrm/service/SimpleServiceImpl.class
997 Wed Apr 16 14:39:18 CEST 2008 WEB-INF/classes/org/jboss/test/ws/jaxws/samples/wsrm/service/jaxws/Echo.class
1050 Wed Apr 16 14:39:18 CEST 2008 WEB-INF/classes/org/jboss/test/ws/jaxws/samples/wsrm/service/jaxws/EchoResponse.class
679 Wed Apr 16 14:39:18 CEST 2008 WEB-INF/classes/org/jboss/test/ws/jaxws/samples/wsrm/service/jaxws/Ping.class
0 Wed Apr 16 14:39:22 CEST 2008 WEB-INF/wsdl/
2799 Wed Apr 16 14:39:20 CEST 2008 WEB-INF/wsdl/SimpleService.wsdl
Copy to ClipboardCopied!Toggle word wrapToggle overflow