12.07.2015 Views

Anyframe CXF Plugin

Anyframe CXF Plugin

Anyframe CXF Plugin

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

RESTful Services7.4.JAX-WS Provider/Dispatch API 활용한RESTful 서비스 구현표준 API를 사용하여 간단한 RESTful 서비스를 작성할 수 있게 하지만, HTTP Binding 방식에 비해 유연한 구조가 아니다.JAX-WS Provider/Dispatch API의 특징을 살펴보면 다음과 같다.• JAX-WS Provider(javax.xml.ws.Provider)와 Dispatch(javax.xml.ws.Dispatch) API를 사용하여 간단한RESTful 서비스를 구현할 수 있다.• Web Service로 노출시킬 서비스를 Provider 인터페이스 클래스를 구현하여 작성하고 invoke method를 구현한다.다음은 JAX-WS Provider와 Dispatch API를 사용하여 RESTful 서비스 구현 시 Server와 Client 단에서 어떻게 사용해야 하는지에 대한 사용법이다.• Server Configuration• Client Configuration7.4.1.Server ConfigurationMovie Service를 Provider 인터페이스 클래스를 구현한 MovieServicePayloadProvider 클래스로 작성하고 invoke method를 구현함으로써 RESTful Web Services로 노출시켜 보도록 한다.7.4.1.1.Samples다음은 Provider 인터페이스 클래스를 구현한 MovieServicePayloadProvider 클래스 정의에 대한 예제이다. 서버 구동을 위해서 javax.xml.ws.Endpoint 클래스를 이용하고 있다.• Provider 인터페이스 클래스 구현(MovieServicePayloadProvider)다음은 Provider 인터페이스 클래스를 구현한 MovieServicePayloadProvider 클래스를 작성한MovieServicePayloadProvider.java 의 일부이다. Annotation 설정에 유의하도록 한다.import javax.xml.ws.ServiceMode;import javax.xml.ws.WebServiceProvider;@WebServiceProvider()@ServiceMode(value = Service.Mode.PAYLOAD)public class MovieServicePayloadProvider implements Provider {@Resourceprotected WebServiceContext wsContext;public MovieServicePayloadProvider() {}public DOMSource invoke(DOMSource request) {MessageContext mc = wsContext.getMessageContext();String path = (String) mc.get(Message.PATH_INFO);String query = (String) mc.get(Message.QUERY_STRING);String httpMethod = (String) mc.get(Message.HTTP_REQUEST_METHOD);if (httpMethod.equalsIgnoreCase("POST")) {return updateMovie(request);67

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!