<document>
<deftable>
File Description
Interface for the hello service.
The main service implementation.
Configures the environment
Client JSP
</deftable>

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.

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-mapping url-pattern="/hello/*" servlet-class="example.HelloServiceImpl" jndi-name="service/HelloService"> <protocol uri="hessian:"/> </servlet-mapping>

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

package example; import java.io.*; import javax.annotation.*; import javax.servlet.*; import javax.servlet.http.*; public class ServiceFrontendServlet extends HttpServlet { @Named("hessian") 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.

<remote-client name="hessian"> <uri>hessian:url=${webApp.url}/hello/</uri> <interface>example.HelloService</interface> </remote-client> <servlet servlet-name="service-frontend" servlet-class="example.ServiceFrontendServlet" /> <servlet-mapping url-pattern="/frontend/" servlet-name="service-frontend" />
</document>