diff --git a/.idea/compiler.xml b/.idea/compiler.xml
index 13249f0..6fdb87c 100644
--- a/.idea/compiler.xml
+++ b/.idea/compiler.xml
@@ -12,6 +12,7 @@
+
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
index 236f921..797721e 100644
--- a/.idea/encodings.xml
+++ b/.idea/encodings.xml
@@ -4,6 +4,7 @@
+
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 6e79789..39545a1 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,6 +1,9 @@
+
+
+
diff --git a/jaxwsdemo-service/jaxwsdemoservice.iml b/jaxwsdemo-service/jaxwsdemoservice.iml
new file mode 100644
index 0000000..78b2cc5
--- /dev/null
+++ b/jaxwsdemo-service/jaxwsdemoservice.iml
@@ -0,0 +1,2 @@
+
+
\ No newline at end of file
diff --git a/jaxwsdemo-service/pom.xml b/jaxwsdemo-service/pom.xml
new file mode 100644
index 0000000..36901ff
--- /dev/null
+++ b/jaxwsdemo-service/pom.xml
@@ -0,0 +1,72 @@
+
+
+ 4.0.0
+ jaxwsdemo-service
+ jaxwsdemo-service
+ war
+
+
+ jeedemo
+ it.plague.jeedemo
+ 1.0-SNAPSHOT
+
+
+
+ UTF-8
+ 1.7
+ 1.7
+
+
+
+
+ org.glassfish.main.extras
+ glassfish-embedded-all
+
+
+ org.projectlombok
+ lombok
+
+
+ junit
+ junit
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.8.0
+
+ 1.7
+ 1.7
+
+
+
+ org.apache.maven.plugins
+ maven-war-plugin
+ 3.2.2
+
+ false
+
+
+
+ org.apache.maven.plugins
+ maven-failsafe-plugin
+ 2.12.4
+
+
+ integration-test
+
+ integration-test
+ verify
+
+
+
+
+
+
+
diff --git a/jaxwsdemo-service/src/main/java/it/plague/jeedemo/CardValidator.java b/jaxwsdemo-service/src/main/java/it/plague/jeedemo/CardValidator.java
new file mode 100644
index 0000000..86ad14e
--- /dev/null
+++ b/jaxwsdemo-service/src/main/java/it/plague/jeedemo/CardValidator.java
@@ -0,0 +1,13 @@
+package it.plague.jeedemo;
+
+import javax.jws.WebService;
+
+@WebService(endpointInterface = "it.plague.jeedemo.Validator")
+public class CardValidator implements Validator {
+
+ @Override
+ public boolean validate(CreditCard creditCard) {
+ Character lastDigit = creditCard.getNumber().charAt(creditCard.getNumber().length() - 1);
+ return Integer.parseInt(lastDigit.toString()) % 2 == 0;
+ }
+}
diff --git a/jaxwsdemo-service/src/main/java/it/plague/jeedemo/CreditCard.java b/jaxwsdemo-service/src/main/java/it/plague/jeedemo/CreditCard.java
new file mode 100644
index 0000000..9d9816e
--- /dev/null
+++ b/jaxwsdemo-service/src/main/java/it/plague/jeedemo/CreditCard.java
@@ -0,0 +1,30 @@
+package it.plague.jeedemo;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlRootElement;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.FIELD)
+public class CreditCard {
+
+ @XmlAttribute(required = true)
+ private String number;
+
+ @XmlAttribute(name = "expiry_date", required = true)
+ private String expiryDate;
+
+ @XmlAttribute(name = "control_number", required = true)
+ private Integer controlNumber;
+
+ @XmlAttribute(required = true)
+ private String type;
+
+}
diff --git a/jaxwsdemo-service/src/main/java/it/plague/jeedemo/Validator.java b/jaxwsdemo-service/src/main/java/it/plague/jeedemo/Validator.java
new file mode 100644
index 0000000..4da1dbb
--- /dev/null
+++ b/jaxwsdemo-service/src/main/java/it/plague/jeedemo/Validator.java
@@ -0,0 +1,9 @@
+package it.plague.jeedemo;
+
+import javax.jws.WebService;
+
+@WebService
+public interface Validator {
+
+ boolean validate(CreditCard creditCard);
+}
diff --git a/jaxwsdemo-service/src/test/java/it/plague/jeedemo/CardValidatorIT.java b/jaxwsdemo-service/src/test/java/it/plague/jeedemo/CardValidatorIT.java
new file mode 100644
index 0000000..34caabf
--- /dev/null
+++ b/jaxwsdemo-service/src/test/java/it/plague/jeedemo/CardValidatorIT.java
@@ -0,0 +1,62 @@
+package it.plague.jeedemo;
+
+import static org.junit.Assert.*;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import javax.xml.namespace.QName;
+import javax.xml.ws.Endpoint;
+import javax.xml.ws.Service;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class CardValidatorIT {
+
+ private static Endpoint endpoint;
+
+ private static Validator cardValidator;
+
+ @BeforeClass
+ public static void setUp() throws MalformedURLException {
+ final String url = "http://localhost:8081/cardValidator";
+
+ // Publishes the SOAP Web Service
+ endpoint = Endpoint.publish(url, new CardValidator());
+
+ // Needed properties to access the web service
+ URL wsdlDocumentLocation = new URL(url + "?wsdl");
+ String namespaceURI = "http://jeedemo.plague.it/";
+ String servicePart = "CardValidatorService";
+ String portName = "CardValidatorPort";
+ QName serviceQn = new QName(namespaceURI, servicePart);
+ QName portQn = new QName(namespaceURI, portName);
+
+ // Creates a service instance
+ Service service = Service.create(wsdlDocumentLocation, serviceQn);
+ cardValidator = service.getPort(portQn, Validator.class);
+ }
+
+ @AfterClass
+ public static void tearDown() {
+ if (endpoint != null) {
+ endpoint.stop();
+ }
+ }
+
+ @Test
+ public void shouldBePublished() {
+ assertTrue(endpoint.isPublished());
+ assertEquals("http://schemas.xmlsoap.org/wsdl/soap/http", endpoint.getBinding().getBindingID());
+ }
+
+ @Test
+ public void shouldCheckCreditCardValidity() {
+ CreditCard creditCard = new CreditCard("12341234", "10/10", 1234, "VISA");
+ assertTrue("Credit card should be valid", cardValidator.validate(creditCard));
+
+ creditCard.setNumber("12341233");
+ assertFalse("Credit card should not be valid", cardValidator.validate(creditCard));
+ }
+
+}
diff --git a/jaxwsdemo-service/src/test/java/it/plague/jeedemo/CardValidatorTest.java b/jaxwsdemo-service/src/test/java/it/plague/jeedemo/CardValidatorTest.java
new file mode 100644
index 0000000..84b0826
--- /dev/null
+++ b/jaxwsdemo-service/src/test/java/it/plague/jeedemo/CardValidatorTest.java
@@ -0,0 +1,21 @@
+package it.plague.jeedemo;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+public class CardValidatorTest {
+
+ @Test
+ public void shouldCheckCreditCardValidity() {
+ CardValidator cardValidator = new CardValidator();
+
+ CreditCard creditCard = new CreditCard("12341234", "10/10", 1234, "VISA");
+ assertTrue("Credit card should be valid", cardValidator.validate(creditCard));
+
+ creditCard.setNumber("12341233");
+ assertFalse("Credit card should not be valid", cardValidator.validate(creditCard));
+ }
+
+}
diff --git a/pom.xml b/pom.xml
index f8f7084..08e6d8f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -15,6 +15,7 @@
ejbdemo
xmlandjsondemo
jmsdemo
+ jaxwsdemo-service