A frontend client for a service on the Resin ESB
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
Configuring a service with JAXB
SOA/ESB
Flickr REST

This tutorial shows how to access services on the Resin Enterprise Service Bus (ESB) using J2EE injection. A servlet does frontend presentation for the results of an ESB service.

Demo

Files in this tutorial

WEB-INF/classes/example/HelloService.javaInterface for the hello service.
WEB-INF/classes/example/HelloServiceImpl.java
WEB-INF/classes/example/ServiceFrontendServlet.javaThe main service implementation.
WEB-INF/resin-web.xmlConfigures the environment
demo.jspClient JSP

Service Interface and Configuration

The service used in this example is the same hello world service used in the simple service tutorial. The interface used by the frontend is shown below.

HelloService.java
package example;

public interface HelloService {
  /**
   * Returns "hello, world".
   */
  public String hello();
}

Configuring the service is also the same as in the the simple service tutorial.

<servlet>
<servlet-mapping url-pattern="/hello/*"
                 servlet-class="example.HelloServiceImpl"
                 jndi-name="service/HelloService">

  <protocol type="hessian"/>
</servlet-mapping>

Frontend Client

The client in this case is simply a servlet that uses J2EE injection to access the service.

ServiceFrontendServlet.java
package example;

import java.io.*;
import javax.annotation.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class ServiceFrontendServlet extends HttpServlet {
  @Resource(name="hessian/HelloService")
  private HelloService _helloService;

  public void doGet(HttpServletRequest req, HttpServletResponse resp)
    throws IOException, ServletException
  {
    PrintStream out = new PrintStream(resp.getOutputStream());

    out.println("service result: " + _helloService.hello());
  }
}

Configuring the client is nearly the same as in the the simple service tutorial, the only difference being adding the mapping for the servlet.

Client configuration
<web-service-client jndi-name="hessian/HelloService">
  <url>hessian:${webApp.url}/hello/</url>
  <interface>example.HelloService</interface>
</web-service-client>

<servlet servlet-name="service-frontend" 
         servlet-class="example.ServiceFrontendServlet" />
<servlet-mapping url-pattern="/frontend/" servlet-name="service-frontend" />

Demo


Configuring a service with JAXB
SOA/ESB
Flickr REST
Copyright © 1998-2006 Caucho Technology, Inc. All rights reserved.
Resin ® is a registered trademark, and Quercustm, Ambertm, and Hessiantm are trademarks of Caucho Technology.