12.07.2015 Views

Beginning Java EE 6 with GlassFish 3, Second Edition

Beginning Java EE 6 with GlassFish 3, Second Edition

Beginning Java EE 6 with GlassFish 3, Second Edition

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 14 ■ SOAP WEB SERVICESListing 14-24. The CardValidator Web Service@WebServicepublic class CardValidator {public boolean validate(CreditCard creditCard) {Character lastDigit = creditCard.getNumber().charAt(creditCard.getNumber().length() - 1);}}if (Integer.parseInt(lastDigit.toString()) % 2 != 0) {return true;} else {return false;}For simplicity, no extra <strong>Java</strong>-to-WSDL mapping is used, so there are no @WebMethod, @WebResult, or@WebParam annotations, allowing you to see how easy it is to write a web service using all the defaultmapping rules.Compiling and Packaging <strong>with</strong> MavenThe CardValidator web service (shown previously in Listing 14-24) needs to be compiled and packagedin a war file ( war ). The pom.xml file (see Listing 14-25) declares the jaxws-rtdependency to use the 2.2 version of JAX-WS. <strong>Java</strong> SE 6 comes <strong>with</strong> a JAXB and JAX-WS implementation.Specifying the 1.6 version in the maven-compiler-plugin should be enough as you explicitly specify youwant to use <strong>Java</strong> SE 6 ( 1.6 ). But if you want to control your dependency versions andabsolutely want JAX-WS 2.2, it’s better to explicitly add the jaxws-rt dependency to the project.Listing 14-25. The pom.xml File to Compile and Package the Web Service4.0.0com.apress.javaee6chapter14-service2.0warcom.sun.xml.wsjaxws-rt443

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

Saved successfully!

Ooh no, something went wrong!