![]() | ![]() | ![]() |
| |||||||||||||||
![]() | ||||||||||||||||||
![]() | ![]() | |||||||||||||||||
Resin 3.1 Documentation Examples Changes Quercus Database Amber EJB SOA/ESB IoC JMS Servlet JMX Hessian Security Simple Service Configuring a service with JAXB An ESB client Flickr REST JAX-WS example |
A service on the Resin ESB can be configured easily using JAXB. Services on the Resin ESB can be configured easily using JAXB. Files in this tutorial
Service ImplementationThe HelloService implementation for this tutorial still conforms to the same API as in the Simple Service tutorial, but now has an annotated field to allow the hello message to be changed via JAXB configuration. package example; import javax.jws.WebMethod; import javax.jws.WebService; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; @WebService(endpointInterface="example.HelloService") @XmlRootElement public class HelloServiceImpl implements HelloService { @XmlElement(name="hello") private String _hello; /** * Returns "hello, world". */ @WebMethod public String hello() { return _hello; } } Remote InterfaceThe Java interface describes the remote API. The API here is the same as in the Simple Service tutorial. package example; public interface HelloService { /** * Returns "hello, world". */ public String hello(); } Service configurationThe configuration of this service is almost identical to the Simple Service tutorial, but now includes data to be unmarshalled into the service. Specifically, the hello field is initialized from the <init> child tag of <web-service>. <servlet-mapping url-pattern="/hello/*" servlet-class="example.HelloServiceImpl"> jndi-name="service/HelloService"> <init> <hello>hola mundo</hello> </init> <protocol type="hessian"/> </servlet-mapping> Since the service API has not changed, the <web-service-client> tag and its contents remain unchanged from the Simple Service tutorial. <web-service-client jndi-name="hessian/HelloService"> <url>hessian:${webApp.url}/hello/</url> <interface>example.HelloService</interface> </web-service-client> Java ClientThe client can now connect to the HelloService using any supported encoding simply by doing a lookup in JNDI. The message returned now is the one initialized via JAXB. <%@ page import="com.caucho.naming.Jndi" %> <%@ page import="example.HelloService" %> <% HelloService hessianHello = (HelloService) Jndi.lookup("hessian/HelloService"); HelloService vmHello = (HelloService) Jndi.lookup("service/HelloService"); %> <pre> From Hessian: <%= hessianHello.hello() %> From VM: <%= vmHello.hello() %> </pre> From Hessian: hola mundo From VM: hola mundo
|