⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 index.xtp

📁 RESIN 3.2 最新源码
💻 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 &lt;init> child tag of &lt;web-service>.</p><example title="<web-service>">&lt;servlet-mapping url-pattern="/hello/*"                 servlet-class="example.HelloServiceImpl">                 jndi-name="service/HelloService">  &lt;init>    &lt;hello>hola mundo&lt;/hello>  &lt;/init>  &lt;protocol type="hessian"/>&lt;/servlet-mapping></example><p>Since the service API has not changed, the &lt;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>">&lt;web-service-client jndi-name="hessian/HelloService">  &lt;url>hessian:${webApp.url}/hello/&lt;/url>  &lt;interface>example.HelloService&lt;/interface>&lt;/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">&lt;%@ page import="com.caucho.naming.Jndi" %>&lt;%@ page import="example.HelloService" %>&lt;%HelloService hessianHello = (HelloService) Jndi.lookup("hessian/HelloService");HelloService vmHello = (HelloService) Jndi.lookup("service/HelloService");%>&lt;pre>From Hessian: &lt;%= hessianHello.hello() %>From VM: &lt;%= vmHello.hello() %>&lt;/pre></example><results>From Hessian: hola mundoFrom VM: hola mundo</results></s1>  </body></document>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -