📄 index.xtp
字号:
<document> <header> <product>resin</product> <title>Burlap Addition</title> <description> <p>The addition example creates a Burlap web serviceswith a servlet and uses that web service from aJSP client.</p> </description> <type>tutorial</type> <tutorial-startpage>demo.jsp</tutorial-startpage> </header> <body> <summary/><s1><p>Burlap is a lightweight XML RPC protocol. Burlap is designed to beself-describing, eliminating the requirement for external IDLs or WSDL files.Because it is as small as possible and language-independent,non-Java Burlap implementations are can easily develop comprehensivetest suites.</p><p>This tutorial only requires the open source Java implementation ofthe Burlap client and server included in the Hessian distribution. It can be downloadedfrom <a href="http://caucho.com/hessian/">http://www.caucho.com/hessian/</a>for non-Resin clients and servers.</p><p>Because Resin's EJB implementation can use Burlap as itsremote procedure call protocol, EJB developers can easily exposeservices to clients from other languages.</p><p>Because EJB clients and servers are written without knowledge of theunderlying protocol, even if you intend to deploy with another protocol,like RMI/IIOP, you can develop using Resin's Burlap.</p><p>The <a href="doc|burlap-1.0-spec.xtp">Burlap 1.0 spec</a> describesthe full Burlap protocol.</p></s1><s1 title="Files in this tutorial"><deftable><tr> <td><viewfile-link file="WEB-INF/classes/example/MathService.java"/></td> <td>Interface for the math service.</td></tr><tr> <td><viewfile-link file="WEB-INF/classes/example/BurlapMathService.java"/></td> <td>The main service implementation.</td></tr><tr> <td><viewfile-link file="WEB-INF/web.xml"/></td> <td>Configures the environment</td></tr><tr> <td><viewfile-link file="demo.jsp"/></td> <td>Client JSP</td></tr></deftable></s1><s1 title="The Burlap Protocol"><p>A Burlap call is just an HTTP POST to a URL. The arguments areserialized into the Burlap XML format and passed to the server.</p><p>Most applications will never need to look at the Burlapprotocol, but it's simple enough that a basic example can help showwhat's happening underneath the API.</p><example title="Burlap call"><burlap:call> <method>add</method> <int>2</int> <int>3</int></burlap:call></example><example title="Burlap reply"><burlap:reply> <int>5</int></burlap:reply></example><p>The call does not need to specify the service name because theservice is uniquely specified by the URL.</p><p>The following Addition example shows how to create a basicserver so you can test Burlap.</p></s1><s1 title="A Burlap Example"><p>Using Burlap requires three components:</p><ol><li>A remote interface</li><li>The server implementation</li><li>The client (JSP or servlet)</li></ol><p>The remote interface is used by the Hessian proxyfactory to create a proxy stub implementing the service's interface.</p></s1><s1 title="Service Implementation"><p>Resin's Burlap provides a simple way of creating a server. Just extend<code>BurlapServlet</code> with your remote methods. The Burlap call will justbe a POST to that servlet. BurlapServlet will introspect theservice and expose the methods.</p><example title="BurlapMathService.java">package example;import com.caucho.burlap.server.BurlapServlet;public class BurlapMathService extends BurlapServlet { public int add(int a, int b) { return a + b; }}</example></s1><s1 title="Remote Interface"><p>The Java interface describes the remote API. This example has anaddition method, <var>add()</var>.</p><p>Resin's proxy client implementation uses the remote interface toexpose the API to the proxy stub. Strictly speaking, though,the Java remote interface is not required for Burlap. A non-Java clientwill not use the Java interface, except possibly as documentation.</p><example title="MathService.java">package example;public interface MathService { public int add(int a, int b);}</example></s1><s1 title="Java Client"><p>RPC clients follow the following steps in using a remote object:</p><ol><li>Determine the URL of the remote object.</li><li>Obtain a proxy stub from a proxy factory.</li><li>Call methods on the proxy stub.</li></ol><example title="client.jsp"><%@ page import="com.caucho.burlap.client.BurlapProxyFactory" %><%@ page import="example.MathService" %><%BurlapProxyFactory factory = new BurlapProxyFactory();// http://localhost:8080/resin-doc/tutorial/burlap-add/burlap/mathString url = ("http://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath() + "/burlap/math");MathService math = (MathService) factory.create(MathService.class, url);out.println("3 + 2 = " + math.add(3, 2));%></example><results>3 + 2 = 5</results></s1> </body></document>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -