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.

Databinding3.1.1.Server ConfigurationWhen exposing Movie Service to Web Services using <strong>JAX</strong>-<strong>WS</strong> Frontend, declare and test the types ofinterface method parameter and return value in various types.3.1.1.1.SamplesHere is an example of the definition of Movie Service interface class and XmlAdapter class to use maptype.• Interface ClassThe following is a part of MovieService.java which developed Movie Service interface class.Note that @XmlSeeAlso annotation is set because Movie class type saved in Map object during <strong>JAX</strong>BDatabinding should be known. @XmlSeeAlso annotation does not have to be set if another methodof this Web Service uses Movie object as Input or Output parameter class type.@WebService@XmlSeeAlso(Movie.class)public interface MovieFinder {@XmlJavaTypeAdapter(<strong>CXF</strong>MapAdapter.class)Map get(String movieId) throws Exception;...• XmlAdapter Class [Provided by <strong>Anyframe</strong>]If return type is Map among interface methods of Movie Service, XmlAdapter should be additionallydeveloped. If Map type is not used, there is no need to develop this. The following is apart of <strong>CXF</strong>MapAdapter.java that inherits and implements XmlAdapter class. Developers useanyframe.common.cxf.map.<strong>CXF</strong>MapAdapter class provided by <strong>Anyframe</strong>, without needing specialimplementation.public class <strong>CXF</strong>MapAdapter extends XmlAdapter {public <strong>CXF</strong>Map marshal(Map v) throws Exception {<strong>CXF</strong>Map map = new <strong>CXF</strong>Map();for (Map.Entry e : v.entrySet()) {<strong>CXF</strong>Map.<strong>CXF</strong>Entry iue = new <strong>CXF</strong>Map.<strong>CXF</strong>Entry();iue.setValue(e.getValue());iue.setKey(e.getKey());map.getEntries().add(iue);}return map;}}...public Map unmarshal(<strong>CXF</strong>Map v) throws Exception {Map map = new LinkedHashMap();for (<strong>CXF</strong>Map.<strong>CXF</strong>Entry e : v.getEntries()) {map.put(e.getKey(), e.getValue());}return map;}• Additional class used in XmlAdapter Class [Provided by <strong>Anyframe</strong>]13

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

Saved successfully!

Ooh no, something went wrong!