11.07.2015 Views

Anyframe CXF JAX-WS Plugin

Anyframe CXF JAX-WS Plugin

Anyframe CXF JAX-WS Plugin

SHOW MORE
SHOW LESS

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

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

<strong>JAX</strong>-<strong>WS</strong> Frontend• Interface ClassThe following is a part of MovieService.java class which develops Movie Service interface class.Setting @WebService Annotation at the top of interface class is required. Also, let's take a look into@WebMethod, @Oneway, and @WebParam Annotation and see how they work.@WebService@XmlSeeAlso(Movie.class)public interface MovieService {@WebMethod(exclude = true)public void remove(String movieId) throws Exception;// ================= method for Annotation tests@WebMethod(operationName = "testAnnotationMethodInclude")public void testAnnotationMethod();@Onewaypublic String testAnnotationOneWay();public String testAnnotationWebParam(@WebParam(name = "movieAnnotationWebParam") String input);...• Implementation ClassThe following is a part of MovieServiceImpl.java which implements Movie Service interface class.@Service("movieService")public class MovieServiceImpl implements MovieService {// ================= method for Annotation testspublic void testAnnotationMethod() {System.out.println("testAnnotationMethod method is called.");}public String testAnnotationOneWay() {System.out.println("testAnnotationOneWay method is called.");return "testAnnotationOneWay";}public String testAnnotationWebParam(String input) {System.out.println("testAnnotationWebParam method is calledwith the input parameter=" + input);return "testAnnotationWebParam";}...• Test CaseThe following is an example of developing code that accesses Movie Service exposed to Web Servicesusing JaxWsProxyFactoryBean class provided in Apache <strong>CXF</strong>. Let's take a look at how it worksaccording to the value defined in WebServices Annotation.JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();factory.setServiceClass(MovieService.class);factory.setAddress("http://localhost:8080/myproject/ws/movieList");MovieService movieService = (MovieService) factory.create();/*** Do not let specific method be exposed to Web Service method using @WebMethodannotation.* Set exclude value as true among @WebMethod property values.28

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

Saved successfully!

Ooh no, something went wrong!