REST CXF

07.Web 2011.05.13 18:02
Apache CXF vs. Apache AXIS2

REST
부서적인 레이어나 세션과닐를 추가하지 않고 HTTP를 통해 data를 전송하는 framework

HTTP 프로토콜의  

GET, PUT, POST, DELETE 메서드 지원 (CRUD)


Spring 3.0 + Cxf (JAX-WS) 예제 적용
참조 : http://oldprogrammer.tistory.com/

STS + Apache Tomcat 7.0 | cxf 2.4.0 

web.xml

        <display-name>testWebPjt</display-name>


<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>

<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>


 

bean.xml

<!-- CXF 관련 설정 -->

<import resource="classpath:META-INF/cxf/cxf.xml" />

<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />

<import resource="classpath:META-INF/cxf/cxf-extension-http-binding.xml" />

<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />


<!-- The service bean -->

<bean id="personService" class="demo.rest.spring.PeopleServiceImpl" />


<jaxws:endpoint id="getPerson" implementor="#personService"

implementorClass="demo.rest.spring.PeopleServiceImpl" address="/persons"

bindingUri="http://apache.org/cxf/binding/http">

<jaxws:serviceFactory>

<ref bean="wsfactory" />

</jaxws:serviceFactory>

</jaxws:endpoint>


<bean id="wsfactory" class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean"

scope="prototype">

<property name="wrapped" value="true" />

</bean>



PeopleService.java

package demo.rest.spring;


import javax.jws.WebParam;

import javax.jws.WebService;

import javax.ws.rs.GET;


import org.codehaus.jra.HttpResource;


@WebService(targetNamespace = "http://spring.rest.demo")

public interface PeopleService {


@GET

@HttpResource(location = "/{uid}/{lastName}")

Person getPerson(@WebParam(name = "uid") String id, @WebParam(name = "lastName") String name);

}



PeopleServiceImpl.java

package demo.rest.spring;

import javax.jws.WebService;


@WebService(endpointInterface = "demo.rest.spring.PeopleService")

public class PeopleServiceImpl implements PeopleService {



public Person getPerson(String id, String name) {


Person person = new Person();

person.setId(id);

person.setName(name);


return person;


}


}


 
현재 이렇게 돌리면 문제점이 있다.

REST로 url에 parameter를 담아 보내도 결국 나오는 에러는

정보: Invoking GET on /abcd/dfed
2011. 5. 13 오후 5:06:05 org.apache.cxf.phase.PhaseInterceptorChain doDefaultLogging
경고: Interceptor for {http://spring.rest.demo/}PeopleServiceImplService has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Invalid URL/Verb combination. Verb: GET Path: /abcd/dfed 

과 같다.

도데체 뭐가 문제인가 -_-;;;; 
신고

'07.Web' 카테고리의 다른 글

Apache ? Tomcat?  (0) 2011.06.03
java -jar hudson.jar  (0) 2011.05.28
REST CXF  (0) 2011.05.13
팝업창 Cookie를 이용한 일정 기간 내에 열지 않기  (0) 2009.12.07
WAS(Web Application Server) 와 Web Server  (0) 2009.11.30
JSTL param 객체 활용하기  (0) 2009.10.19
Posted by Stewie


티스토리 툴바