CXF
From Resin 3.0
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)
- Download Resin from http://www.caucho.com/download
- Unzip Resin into
/usr/local/share/resin
- Create the CXF webapp directory structure:
mkdir -p /usr/local/share/resin/webapps/cxf/WEB-INF/lib/
mkdir -p /usr/local/share/resin/webapps/cxf/WEB-INF/classes/demo/
- Download CXF from http://incubator.apache.org/cxf/
- Unzip CXF
- Copy all the jars included the CXF lib/ directory to
/usr/local/share/resin/webapps/cxf/WEB-INF/lib/
- 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='/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>
- 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); }
- 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(); } }
- 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") %>
- Start Resin with
java -jar /usr/local/share/resin/lib/resin.jar