「Apache CXF JAX-RS」の版間の差分
ナビゲーションに移動
検索に移動
1行目: | 1行目: | ||
− | ==Apache CXF JAX-RS== | + | ==[[Apache CXF JAX-RS]]== |
*http://cxf.apache.org/docs/jax-rs.html | *http://cxf.apache.org/docs/jax-rs.html | ||
− | *Apache CXF+ | + | *Apache CXF+Springによる[[Webサービス]]開発(JAX-RS編) |
**http://opensquare.jp/blog/?p=1108 | **http://opensquare.jp/blog/?p=1108 | ||
8行目: | 8行目: | ||
==Memo== | ==Memo== | ||
− | ===Maven dependencies=== | + | ===[[Maven]] dependencies=== |
*http://mvnrepository.com/artifact/org.apache.cxf/cxf-rt-frontend-jaxrs/2.4.1 | *http://mvnrepository.com/artifact/org.apache.cxf/cxf-rt-frontend-jaxrs/2.4.1 | ||
<dependency> | <dependency> | ||
17行目: | 17行目: | ||
===Web.xml=== | ===Web.xml=== | ||
− | *http://cxf.apache.org/docs/jaxrs- | + | *http://cxf.apache.org/docs/jaxrs-ser[[vi]]ces-configuration.html#JAXRSSer[[vi]]cesConfiguration-web.xml |
− | ====Spring ContextLoaderListener==== | + | ====[[Spring]] ContextLoaderListener==== |
<?xml version="1.0" encoding="ISO-8859-1"?> | <?xml version="1.0" encoding="ISO-8859-1"?> | ||
<!DOCTYPE web-app | <!DOCTYPE web-app | ||
− | PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" | + | PUBLIC "-//Sun Microsystems, Inc.//[[DTD]] Web Application 2.3//EN" |
"http://java.sun.com/dtd/web-app_2_3.dtd"> | "http://java.sun.com/dtd/web-app_2_3.dtd"> | ||
<web-app> | <web-app> | ||
54行目: | 54行目: | ||
<?xml version="1.0" encoding="UTF-8"?> | <?xml version="1.0" encoding="UTF-8"?> | ||
<beans xmlns="http://www.springframework.org/schema/beans" | <beans xmlns="http://www.springframework.org/schema/beans" | ||
− | xmlns:xsi="http://www.w3.org/2001/ | + | xmlns:xsi="http://www.w3.org/2001/[[XML]]Schema-instance" |
xmlns:jaxrs="http://cxf.apache.org/jaxrs" | xmlns:jaxrs="http://cxf.apache.org/jaxrs" | ||
xsi:schemaLocation=" | xsi:schemaLocation=" | ||
67行目: | 67行目: | ||
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" /> | <import resource="classpath:META-INF/cxf/cxf-servlet.xml" /> | ||
− | <jaxrs:server id=" | + | <jaxrs:server id="customerSer[[vi]]ce" address="/ser[[vi]]ce1"> |
− | <jaxrs: | + | <jaxrs:ser[[vi]]ceBeans> |
<ref bean="customerBean" /> | <ref bean="customerBean" /> | ||
− | </jaxrs: | + | </jaxrs:ser[[vi]]ceBeans> |
</jaxrs:server> | </jaxrs:server> | ||
− | <bean id="customerBean" class="demo.jaxrs.server. | + | <bean id="customerBean" class="demo.jaxrs.server.CustomerSer[[vi]]ce" /> |
</beans> | </beans> | ||
====CXFServlet init parameters==== | ====CXFServlet init parameters==== | ||
79行目: | 79行目: | ||
<!DOCTYPE web-app | <!DOCTYPE web-app | ||
− | PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" | + | PUBLIC "-//Sun Microsystems, Inc.//[[DTD]] Web Application 2.3//EN" |
"http://java.sun.com/dtd/web-app_2_3.dtd"> | "http://java.sun.com/dtd/web-app_2_3.dtd"> | ||
<web-app> | <web-app> |
2020年2月16日 (日) 04:22時点における最新版
目次
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 矢木浩人