Apache CXF JAX-RS
ナビゲーションに移動
検索に移動
目次
Apache CXF JAX-RS
- http://cxf.apache.org/docs/jax-rs.html
- Apache CXF+SpringによるWebサービス開発(JAX-RS編)
手順のまとめ
Memo
Maven dependencies
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-frontend-jaxrs</artifactId>
- <version>2.4.1</version>
- </dependency>
Web.xml
- http://cxf.apache.org/docs/jaxrs-services-configuration.html#JAXRSServicesConfiguration-web.xml
Spring ContextLoaderListener
- <?xml version="1.0" encoding="ISO-8859-1"?>
- <!DOCTYPE web-app
- PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
- "http://java.sun.com/dtd/web-app_2_3.dtd">
- <web-app>
- <context-param>
- <param-name>contextConfigLocation</param-name>
- <param-value>WEB-INF/beans.xml</param-value>
- </context-param>
- <listener>
- <listener-class>
- org.springframework.web.context.ContextLoaderListener
- </listener-class>
- </listener>
- <servlet>
- <servlet-name>CXFServlet</servlet-name>
- <display-name>CXF Servlet</display-name>
- <servlet-class>
- org.apache.cxf.transport.servlet.CXFServlet
- </servlet-class>
- <load-on-startup>1</load-on-startup>
- </servlet>
- <servlet-mapping>
- <servlet-name>CXFServlet</servlet-name>
- <url-pattern>/*</url-pattern>
- </servlet-mapping>
- </web-app>
beans.xml
- <?xml version="1.0" encoding="UTF-8"?>
- <beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:jaxrs="http://cxf.apache.org/jaxrs"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd
- http://cxf.apache.org/jaxrs
- http://cxf.apache.org/schemas/jaxrs.xsd">
- <!-- do not use import statements if CXFServlet init parameters link to this beans.xml -->
- <import resource="classpath:META-INF/cxf/cxf.xml" />
- <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
- <jaxrs:server id="customerService" address="/service1">
- <jaxrs:serviceBeans>
- <ref bean="customerBean" />
- </jaxrs:serviceBeans>
- </jaxrs:server>
- <bean id="customerBean" class="demo.jaxrs.server.CustomerService" />
- </beans>
CXFServlet init parameters
- <?xml version="1.0" encoding="ISO-8859-1"?>
- <!DOCTYPE web-app
- PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
- "http://java.sun.com/dtd/web-app_2_3.dtd">
- <web-app>
- <servlet>
- <servlet-name>CXFServlet1</servlet-name>
- <display-name>CXF Servlet1</display-name>
- <servlet-class>
- org.apache.cxf.transport.servlet.CXFServlet
- </servlet-class>
- <init-param>
- <param-name>config-location</param-name>
- <param-value>/WEB-INF/beans1.xml</param-value>
- </init-param>
- <load-on-startup>1</load-on-startup>
- </servlet>
- <servlet>
- <servlet-name>CXFServlet2</servlet-name>
- <display-name>CXF Servlet2</display-name>
- <servlet-class>
- org.apache.cxf.transport.servlet.CXFServlet
- </servlet-class>
- <init-param>
- <param-name>config-location</param-name>
- <param-value>/WEB-INF/beans2.xml</param-value>
- </init-param>
- <load-on-startup>1</load-on-startup>
- </servlet>
- <servlet-mapping>
- <servlet-name>CXFServlet1</servlet-name>
- <url-pattern>/1/*</url-pattern>
- </servlet-mapping>
- <servlet-mapping>
- <servlet-name>CXFServlet2</servlet-name>
- <url-pattern>/2/*</url-pattern>
- </servlet-mapping>
- </web-app>
DataBinding
© 2006 矢木浩人