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 Services} else if (httpMethod.equalsIgnoreCase("GET")) {if (path.equals("/movieservice/movies") && query == null) {return findMovieListAll();} else if (path.equals("/movieservice/movies") && query != null) {return findMovie(query);}}중략...• Test case다음은 서버 사이드의 서비스를 Web Services로 노출시키는 서버를 구동하는 코드 작성 예이다.MovieServicePayloadProvider 클래스 생성 후 javax.xml.ws.Endpoint 클래스를 생성해 준 다음, 접근주소를 설정하여 publish 시킨다. 이때 Endpoint Binding Id를 HTTP Binding ID로 설정하고 있음에 유의하도록 한다.System.out.println("Starting Server");Endpoint e = Endpoint.create(HTTPBinding.HTTP_BINDING,new MovieServicePayloadProvider());String address = "http://localhost:9002/movieservice/movies";e.publish(address);중략...7.4.2.Client ConfigurationWeb Services에 접근하기 위한 클라이언트를 작성한다. HttpClient 혹은 URL 클래스를 이용하여 RESTfulWebService에 접근할 수도 있고, Dispatch API를 이용하여 접근해볼 수도 있다.7.4.2.1.Samples다음은 org.apache.commons.httpclient.HttpClient를 이용하여 RESTful Web Services로 노출된 MovieService에 접근하는 예제이다. 이때, RESTful WebService의 결과 값이 XML 형태로 리턴되기 때문에 실제클라이언트 코드에서 JavaBeans 객체로 변경하여 사용해야 하는 작업이 추가된다. XML을 JavaBeans객체로 변경하는 일을 JAXB를 통해서 수행하고 있다.• JAXB 활용JAXB를 활용하여 서비스 결과 XML을 JavaBeans로 변경시키기 위해서는 다음과 같이 각 JavaBeans객체에 Annotation을 설정하고 jaxb.index 파일을 추가 생성시켜줘야 한다. 다음은 Movie Service에서입력 및 출력 시 Movie 상세조회 XML 데이터와 변환되는 Movie.java의 일부이다. Movie 클래스 정의시 작성한 @XmlRootElement(name = "Movie") Annotation 설정에 유의하도록 한다. JAXB를 이용하여 서비스 결과 XML을 JavaBeans 객체로 변환 시 이 Annotation 정보를 이용한다.import javax.xml.bind.annotation.XmlRootElement;@XmlRootElement(name = "Movie")public class Movie implements Serializable {public String getTitle() {return title;}public void setTitle(String title) {this.title = title;}중략...다음은 Movie Service에서 입력 및 출력 시 Movie 목록조회 XML 데이터와 변환되는 Movies.java 의일부이다. Movies 클래스 정의 시 작성한 @XmlRootElement(name = "Movies") Annotation 설정에 유68

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

Saved successfully!

Ooh no, something went wrong!