?? index.xtp
字號:
<document> <header> <product>resin</product> <title>Configuring a Service on the Resin ESB using JAXB</title> <description> <p>A service on the Resin ESB can be configured easily using JAXB. </p> </description> <type>tutorial</type> <tutorial-startpage>demo.jsp</tutorial-startpage> </header> <body> <summary/> <s1><p>Services on the Resin ESB can be configured easily using JAXB.</p></s1><s1 title="Files in this tutorial"><deftable><tr><td><viewfile-link file="WEB-INF/classes/example/HelloService.java"/> </td><td>Interface for the hello service.</td></tr><tr><td><viewfile-link file="WEB-INF/classes/example/HelloServiceImpl.java"/> </td><td>The main service implementation.</td></tr><tr><td><viewfile-link file="WEB-INF/resin-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="Service Implementation"><p>The HelloService implementation for this tutorial still conforms to thesame API as in the <a href="../soa-hello-world/index.xtp">Simple Service tutorial</a>, but now has an annotated field to allow the hello message to be changed via JAXBconfiguration.</p><example title="HelloServiceImpl.java">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")@XmlRootElementpublic class HelloServiceImpl implements HelloService { @XmlElement(name="hello") private String _hello; /** * Returns "hello, world". */ @WebMethod public String hello() { return _hello; }}</example></s1><s1 title="Remote Interface"><p>The Java interface describes the remote API. The API here is the sameas in the <a href="../soa-hello-world/index.xtp">Simple Service tutorial</a>.</p><example title="HelloService.java">package example;public interface HelloService { /** * Returns "hello, world". */ public String hello();}</example></s1><s1 title="Service configuration"><p>The configuration of this service is almost identical to the <a href="../soa-hello-world/index.xtp">Simple Service tutorial</a>, but nowincludes data to be unmarshalled into the service. Specifically, the hellofield is initialized from the <init> child tag of <web-service>.</p><example title="<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></example><p>Since the service API has not changed, the <web-service-client> tagand its contents remain unchanged from the<a href="../soa-hello-world/index.xtp">Simple Service tutorial</a>.</p><example title="<web-service-client>"><web-service-client jndi-name="hessian/HelloService"> <url>hessian:${webApp.url}/hello/</url> <interface>example.HelloService</interface></web-service-client></example></s1><s1 title="Java Client"><p>The client can now connect to the HelloService using any supportedencoding simply by doing a lookup in JNDI. The message returned now is the one initialized via JAXB.</p><example title="demo.jsp"><%@ 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></example><results>From Hessian: hola mundoFrom VM: hola mundo</results></s1> </body></document>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -