CXF

From Resin 3.0

(Difference between revisions)
Jump to: navigation, search
(First few steps - checkpoint)
 
(initial writeup - checkpoint)
Line 10: Line 10:
 
<li>Create the CXF webapp directory structure:
 
<li>Create the CXF webapp directory structure:
 
<br/><code>/usr/local/share/resin/webapps/cxf/WEB-INF/lib/</code>
 
<br/><code>/usr/local/share/resin/webapps/cxf/WEB-INF/lib/</code>
<br/><code>/usr/local/share/resin/webapps/cxf/WEB-INF/classes/test/</code>
+
<br/><code>/usr/local/share/resin/webapps/cxf/WEB-INF/classes/demo/</code>
 
</li>
 
</li>
 
<li>Download CXF from [http://incubator.apache.org/cxf/ http://incubator.apache.org/cxf/]</li>
 
<li>Download CXF from [http://incubator.apache.org/cxf/ http://incubator.apache.org/cxf/]</li>
Line 17: Line 17:
 
<br/><code>/usr/local/share/resin/webapps/cxf/WEB-INF/lib/</code>  
 
<br/><code>/usr/local/share/resin/webapps/cxf/WEB-INF/lib/</code>  
 
</li>
 
</li>
<li>Create the file <code>/usr/local/share/resin/webapps/cxf/WEB-INF/resin-web.xml</code>
+
<li>Create the configuration file <code>/usr/local/share/resin/webapps/cxf/WEB-INF/resin-web.xml</code>
 
<pre><web-app xmlns="http://caucho.com/ns/resin">
 
<pre><web-app xmlns="http://caucho.com/ns/resin">
 
   <servlet-mapping url-pattern='/StrLenTest' servlet-class='demo.StrLenTest'/>
 
   <servlet-mapping url-pattern='/StrLenTest' servlet-class='demo.StrLenTest'/>
Line 29: Line 29:
 
   </remote-client>
 
   </remote-client>
 
</web-app>
 
</web-app>
 +
</pre>
 +
</li>
 +
<li>Create the interface file <code>/usr/local/share/resin/webapps/cxf/WEB-INF/classes/demo/StrLen.java</code>
 +
<pre>
 +
package demo;
 +
 +
import javax.jws.WebMethod;
 +
import javax.jws.WebService;
 +
 +
@WebService
 +
public interface StrLen {
 +
  @WebMethod
 +
  public int strlen(String x);
 +
}
 +
</pre>
 +
</li>
 +
<li>Create the implementation file
 +
<code>/usr/local/share/resin/webapps/cxf/WEB-INF/classes/demo/StrLenImpl.java</code>
 +
<pre>
 +
package demo;
 +
 +
import javax.jws.WebService;
 +
 +
@WebService(endpointInterface="demo.StrLen")
 +
public class StrLenImpl
 +
{
 +
  public int strlen(String x)
 +
  {
 +
    return x.length();
 +
  }
 +
}
 +
</pre>
 +
</li>
 +
<li>Create a JSP file to access the service
 +
<code>/usr/local/share/resin/webapps/cxf/StrLenDemo.jsp</code>
 +
<pre>
 +
<%@ page import="javax.webbeans.In, demo.StrLen" %>
 +
<%
 +
@In StrLen strlenClient;
 +
%>
 +
strlen("hello, world") = <%= strlenClient.strlen("hello, world") %>
 
</pre>
 
</pre>
 
</li>
 
</li>
 
<li>Start Resin with <code>java -jar /usr/local/share/resin/lib/resin.jar</code></li>
 
<li>Start Resin with <code>java -jar /usr/local/share/resin/lib/resin.jar</code></li>
 
</ol>
 
</ol>

Revision as of 19:28, 23 January 2008

CXF and Resin

Resin features easy creation and deployment of CXF web services and clients, avoiding the need for complicated configuration.

(The following has been tested with Resin 3.1.5 and CXF 2.0.3)

  1. Download Resin from http://www.caucho.com/download
  2. Unzip Resin into /usr/local/share/resin
  3. Create the CXF webapp directory structure:
    /usr/local/share/resin/webapps/cxf/WEB-INF/lib/
    /usr/local/share/resin/webapps/cxf/WEB-INF/classes/demo/
  4. Download CXF from http://incubator.apache.org/cxf/
  5. Unzip CXF
  6. Copy all the jars included the CXF lib/ directory to
    /usr/local/share/resin/webapps/cxf/WEB-INF/lib/
  7. Create the configuration file /usr/local/share/resin/webapps/cxf/WEB-INF/resin-web.xml
    <web-app xmlns="http://caucho.com/ns/resin">
      <servlet-mapping url-pattern='/StrLenTest' servlet-class='demo.StrLenTest'/>
    
      <servlet-mapping url-pattern='/StrLen/*' servlet-class='demo.StrLenImpl'>
        <protocol type="cxf"/>
      </servlet-mapping>
    
      <remote-client class="demo.StrLen" name="StrLenClient">
        <url>cxf:http://localhost:8080/cxf/StrLen/StrLenImpl</url>
      </remote-client>
    </web-app>
    
  8. Create the interface file /usr/local/share/resin/webapps/cxf/WEB-INF/classes/demo/StrLen.java
    package demo;
    
    import javax.jws.WebMethod;
    import javax.jws.WebService;
    
    @WebService
    public interface StrLen {
      @WebMethod
      public int strlen(String x);
    }
    
  9. Create the implementation file /usr/local/share/resin/webapps/cxf/WEB-INF/classes/demo/StrLenImpl.java
    package demo;
    
    import javax.jws.WebService;
    
    @WebService(endpointInterface="demo.StrLen")
    public class StrLenImpl
    {
      public int strlen(String x)
      {
        return x.length();
      }
    }
    
  10. Create a JSP file to access the service /usr/local/share/resin/webapps/cxf/StrLenDemo.jsp
    <%@ page import="javax.webbeans.In, demo.StrLen" %>
    <%
    @In StrLen strlenClient;
    %>
    strlen("hello, world") = <%= strlenClient.strlen("hello, world") %>
    
  11. Start Resin with java -jar /usr/local/share/resin/lib/resin.jar
Personal tools