From 6aeb90de5b5b5cfc7b25b119085c7606475e6d41 Mon Sep 17 00:00:00 2001 From: Sunil Mogadati Date: Tue, 25 Apr 2017 00:56:08 -0600 Subject: [PATCH] BAEL-611 Add JAX-WS client and JUnit Test (#1725) * Add NDC and JBoss Logging to the demo application * NDC for Log4j, Log4j2 and JBoss Logging * Simplify NDC example by making it a single operation instead of two * Make NDC example as RestController, Use JBoss Logging only as a logging bridge * Fix merge conflicts in pull request - log-mdc pom.xml updated * BAEL-445 Update to Spring security SpEL example * BAEL-445: Change tabs to spaces in the updated code * BAEL-245: Add Enum Serialization exmaple * BAEL-245: Remove the folder jackson/src/test/java/com/baeldung/jackson/dtos/withEnum as the example is not used anymore * Add more enum serialization examples to align with previous example and prevent build fail * BAEL-611: Minor formatting changes * BAEL-611: Update Test case method names * BAEL-611 Add JAX-WS client and JUnit Test --- jee7/pom.xml | 1 + .../baeldung/jaxws/client/AddEmployee.java | 79 +++++ .../jaxws/client/AddEmployeeResponse.java | 62 ++++ .../baeldung/jaxws/client/CountEmployees.java | 32 ++ .../jaxws/client/CountEmployeesResponse.java | 54 ++++ .../baeldung/jaxws/client/DeleteEmployee.java | 52 +++ .../jaxws/client/DeleteEmployeeResponse.java | 54 ++++ .../com/baeldung/jaxws/client/Employee.java | 79 +++++ .../jaxws/client/EmployeeAlreadyExists.java | 60 ++++ .../EmployeeAlreadyExists_Exception.java | 54 ++++ .../jaxws/client/EmployeeNotFound.java | 60 ++++ .../client/EmployeeNotFound_Exception.java | 54 ++++ .../jaxws/client/EmployeeService.java | 139 +++++++++ .../jaxws/client/EmployeeServiceClient.java | 17 +- .../jaxws/client/EmployeeService_Service.java | 94 ++++++ .../jaxws/client/GetAllEmployees.java | 32 ++ .../jaxws/client/GetAllEmployeesResponse.java | 69 ++++ .../baeldung/jaxws/client/GetEmployee.java | 52 +++ .../jaxws/client/GetEmployeeResponse.java | 62 ++++ .../baeldung/jaxws/client/ObjectFactory.java | 295 ++++++++++++++++++ .../baeldung/jaxws/client/UpdateEmployee.java | 79 +++++ .../jaxws/client/UpdateEmployeeResponse.java | 62 ++++ .../baeldung/jaxws/client/package-info.java | 2 + .../jaxws/EmployeeServiceLiveTest.java | 51 +-- 24 files changed, 1559 insertions(+), 36 deletions(-) create mode 100644 jee7/src/main/java/com/baeldung/jaxws/client/AddEmployee.java create mode 100644 jee7/src/main/java/com/baeldung/jaxws/client/AddEmployeeResponse.java create mode 100644 jee7/src/main/java/com/baeldung/jaxws/client/CountEmployees.java create mode 100644 jee7/src/main/java/com/baeldung/jaxws/client/CountEmployeesResponse.java create mode 100644 jee7/src/main/java/com/baeldung/jaxws/client/DeleteEmployee.java create mode 100644 jee7/src/main/java/com/baeldung/jaxws/client/DeleteEmployeeResponse.java create mode 100644 jee7/src/main/java/com/baeldung/jaxws/client/Employee.java create mode 100644 jee7/src/main/java/com/baeldung/jaxws/client/EmployeeAlreadyExists.java create mode 100644 jee7/src/main/java/com/baeldung/jaxws/client/EmployeeAlreadyExists_Exception.java create mode 100644 jee7/src/main/java/com/baeldung/jaxws/client/EmployeeNotFound.java create mode 100644 jee7/src/main/java/com/baeldung/jaxws/client/EmployeeNotFound_Exception.java create mode 100644 jee7/src/main/java/com/baeldung/jaxws/client/EmployeeService.java create mode 100644 jee7/src/main/java/com/baeldung/jaxws/client/EmployeeService_Service.java create mode 100644 jee7/src/main/java/com/baeldung/jaxws/client/GetAllEmployees.java create mode 100644 jee7/src/main/java/com/baeldung/jaxws/client/GetAllEmployeesResponse.java create mode 100644 jee7/src/main/java/com/baeldung/jaxws/client/GetEmployee.java create mode 100644 jee7/src/main/java/com/baeldung/jaxws/client/GetEmployeeResponse.java create mode 100644 jee7/src/main/java/com/baeldung/jaxws/client/ObjectFactory.java create mode 100644 jee7/src/main/java/com/baeldung/jaxws/client/UpdateEmployee.java create mode 100644 jee7/src/main/java/com/baeldung/jaxws/client/UpdateEmployeeResponse.java create mode 100644 jee7/src/main/java/com/baeldung/jaxws/client/package-info.java diff --git a/jee7/pom.xml b/jee7/pom.xml index e398651055..8ed6eee6be 100644 --- a/jee7/pom.xml +++ b/jee7/pom.xml @@ -171,6 +171,7 @@ **/*IntegrationTest.java **/*LongRunningUnitTest.java **/*ManualTest.java + **/*LiveTest.java diff --git a/jee7/src/main/java/com/baeldung/jaxws/client/AddEmployee.java b/jee7/src/main/java/com/baeldung/jaxws/client/AddEmployee.java new file mode 100644 index 0000000000..85f217398d --- /dev/null +++ b/jee7/src/main/java/com/baeldung/jaxws/client/AddEmployee.java @@ -0,0 +1,79 @@ + +package com.baeldung.jaxws.client; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for addEmployee complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="addEmployee">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="arg0" type="{http://www.w3.org/2001/XMLSchema}int"/>
+ *         <element name="arg1" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "addEmployee", propOrder = { + "arg0", + "arg1" +}) +public class AddEmployee { + + protected int arg0; + protected String arg1; + + /** + * Gets the value of the arg0 property. + * + */ + public int getArg0() { + return arg0; + } + + /** + * Sets the value of the arg0 property. + * + */ + public void setArg0(int value) { + this.arg0 = value; + } + + /** + * Gets the value of the arg1 property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getArg1() { + return arg1; + } + + /** + * Sets the value of the arg1 property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setArg1(String value) { + this.arg1 = value; + } + +} diff --git a/jee7/src/main/java/com/baeldung/jaxws/client/AddEmployeeResponse.java b/jee7/src/main/java/com/baeldung/jaxws/client/AddEmployeeResponse.java new file mode 100644 index 0000000000..8d274942b5 --- /dev/null +++ b/jee7/src/main/java/com/baeldung/jaxws/client/AddEmployeeResponse.java @@ -0,0 +1,62 @@ + +package com.baeldung.jaxws.client; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for addEmployeeResponse complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="addEmployeeResponse">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="return" type="{http://bottomup.server.jaxws.baeldung.com/}employee" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "addEmployeeResponse", propOrder = { + "_return" +}) +public class AddEmployeeResponse { + + @XmlElement(name = "return") + protected Employee _return; + + /** + * Gets the value of the return property. + * + * @return + * possible object is + * {@link Employee } + * + */ + public Employee getReturn() { + return _return; + } + + /** + * Sets the value of the return property. + * + * @param value + * allowed object is + * {@link Employee } + * + */ + public void setReturn(Employee value) { + this._return = value; + } + +} diff --git a/jee7/src/main/java/com/baeldung/jaxws/client/CountEmployees.java b/jee7/src/main/java/com/baeldung/jaxws/client/CountEmployees.java new file mode 100644 index 0000000000..d87ed31634 --- /dev/null +++ b/jee7/src/main/java/com/baeldung/jaxws/client/CountEmployees.java @@ -0,0 +1,32 @@ + +package com.baeldung.jaxws.client; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for countEmployees complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="countEmployees">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "countEmployees") +public class CountEmployees { + + +} diff --git a/jee7/src/main/java/com/baeldung/jaxws/client/CountEmployeesResponse.java b/jee7/src/main/java/com/baeldung/jaxws/client/CountEmployeesResponse.java new file mode 100644 index 0000000000..2d71ddd0b5 --- /dev/null +++ b/jee7/src/main/java/com/baeldung/jaxws/client/CountEmployeesResponse.java @@ -0,0 +1,54 @@ + +package com.baeldung.jaxws.client; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for countEmployeesResponse complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="countEmployeesResponse">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="return" type="{http://www.w3.org/2001/XMLSchema}int"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "countEmployeesResponse", propOrder = { + "_return" +}) +public class CountEmployeesResponse { + + @XmlElement(name = "return") + protected int _return; + + /** + * Gets the value of the return property. + * + */ + public int getReturn() { + return _return; + } + + /** + * Sets the value of the return property. + * + */ + public void setReturn(int value) { + this._return = value; + } + +} diff --git a/jee7/src/main/java/com/baeldung/jaxws/client/DeleteEmployee.java b/jee7/src/main/java/com/baeldung/jaxws/client/DeleteEmployee.java new file mode 100644 index 0000000000..0bd3a783a7 --- /dev/null +++ b/jee7/src/main/java/com/baeldung/jaxws/client/DeleteEmployee.java @@ -0,0 +1,52 @@ + +package com.baeldung.jaxws.client; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for deleteEmployee complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="deleteEmployee">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="arg0" type="{http://www.w3.org/2001/XMLSchema}int"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "deleteEmployee", propOrder = { + "arg0" +}) +public class DeleteEmployee { + + protected int arg0; + + /** + * Gets the value of the arg0 property. + * + */ + public int getArg0() { + return arg0; + } + + /** + * Sets the value of the arg0 property. + * + */ + public void setArg0(int value) { + this.arg0 = value; + } + +} diff --git a/jee7/src/main/java/com/baeldung/jaxws/client/DeleteEmployeeResponse.java b/jee7/src/main/java/com/baeldung/jaxws/client/DeleteEmployeeResponse.java new file mode 100644 index 0000000000..216f766640 --- /dev/null +++ b/jee7/src/main/java/com/baeldung/jaxws/client/DeleteEmployeeResponse.java @@ -0,0 +1,54 @@ + +package com.baeldung.jaxws.client; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for deleteEmployeeResponse complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="deleteEmployeeResponse">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="return" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "deleteEmployeeResponse", propOrder = { + "_return" +}) +public class DeleteEmployeeResponse { + + @XmlElement(name = "return") + protected boolean _return; + + /** + * Gets the value of the return property. + * + */ + public boolean isReturn() { + return _return; + } + + /** + * Sets the value of the return property. + * + */ + public void setReturn(boolean value) { + this._return = value; + } + +} diff --git a/jee7/src/main/java/com/baeldung/jaxws/client/Employee.java b/jee7/src/main/java/com/baeldung/jaxws/client/Employee.java new file mode 100644 index 0000000000..8a89a5b97c --- /dev/null +++ b/jee7/src/main/java/com/baeldung/jaxws/client/Employee.java @@ -0,0 +1,79 @@ + +package com.baeldung.jaxws.client; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for employee complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="employee">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="firstName" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *         <element name="id" type="{http://www.w3.org/2001/XMLSchema}int"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "employee", propOrder = { + "firstName", + "id" +}) +public class Employee { + + protected String firstName; + protected int id; + + /** + * Gets the value of the firstName property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getFirstName() { + return firstName; + } + + /** + * Sets the value of the firstName property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setFirstName(String value) { + this.firstName = value; + } + + /** + * Gets the value of the id property. + * + */ + public int getId() { + return id; + } + + /** + * Sets the value of the id property. + * + */ + public void setId(int value) { + this.id = value; + } + +} diff --git a/jee7/src/main/java/com/baeldung/jaxws/client/EmployeeAlreadyExists.java b/jee7/src/main/java/com/baeldung/jaxws/client/EmployeeAlreadyExists.java new file mode 100644 index 0000000000..3c9c726552 --- /dev/null +++ b/jee7/src/main/java/com/baeldung/jaxws/client/EmployeeAlreadyExists.java @@ -0,0 +1,60 @@ + +package com.baeldung.jaxws.client; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for EmployeeAlreadyExists complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="EmployeeAlreadyExists">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="message" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "EmployeeAlreadyExists", propOrder = { + "message" +}) +public class EmployeeAlreadyExists { + + protected String message; + + /** + * Gets the value of the message property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getMessage() { + return message; + } + + /** + * Sets the value of the message property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setMessage(String value) { + this.message = value; + } + +} diff --git a/jee7/src/main/java/com/baeldung/jaxws/client/EmployeeAlreadyExists_Exception.java b/jee7/src/main/java/com/baeldung/jaxws/client/EmployeeAlreadyExists_Exception.java new file mode 100644 index 0000000000..4d6a867b0d --- /dev/null +++ b/jee7/src/main/java/com/baeldung/jaxws/client/EmployeeAlreadyExists_Exception.java @@ -0,0 +1,54 @@ + +package com.baeldung.jaxws.client; + +import javax.xml.ws.WebFault; + + +/** + * This class was generated by the JAX-WS RI. + * JAX-WS RI 2.2.9-b130926.1035 + * Generated source version: 2.2 + * + */ +@WebFault(name = "EmployeeAlreadyExists", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/") +public class EmployeeAlreadyExists_Exception + extends Exception +{ + + /** + * Java type that goes as soapenv:Fault detail element. + * + */ + private EmployeeAlreadyExists faultInfo; + + /** + * + * @param faultInfo + * @param message + */ + public EmployeeAlreadyExists_Exception(String message, EmployeeAlreadyExists faultInfo) { + super(message); + this.faultInfo = faultInfo; + } + + /** + * + * @param faultInfo + * @param cause + * @param message + */ + public EmployeeAlreadyExists_Exception(String message, EmployeeAlreadyExists faultInfo, Throwable cause) { + super(message, cause); + this.faultInfo = faultInfo; + } + + /** + * + * @return + * returns fault bean: com.baeldung.jaxws.client.EmployeeAlreadyExists + */ + public EmployeeAlreadyExists getFaultInfo() { + return faultInfo; + } + +} diff --git a/jee7/src/main/java/com/baeldung/jaxws/client/EmployeeNotFound.java b/jee7/src/main/java/com/baeldung/jaxws/client/EmployeeNotFound.java new file mode 100644 index 0000000000..ba3be93571 --- /dev/null +++ b/jee7/src/main/java/com/baeldung/jaxws/client/EmployeeNotFound.java @@ -0,0 +1,60 @@ + +package com.baeldung.jaxws.client; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for EmployeeNotFound complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="EmployeeNotFound">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="message" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "EmployeeNotFound", propOrder = { + "message" +}) +public class EmployeeNotFound { + + protected String message; + + /** + * Gets the value of the message property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getMessage() { + return message; + } + + /** + * Sets the value of the message property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setMessage(String value) { + this.message = value; + } + +} diff --git a/jee7/src/main/java/com/baeldung/jaxws/client/EmployeeNotFound_Exception.java b/jee7/src/main/java/com/baeldung/jaxws/client/EmployeeNotFound_Exception.java new file mode 100644 index 0000000000..957e59fdc9 --- /dev/null +++ b/jee7/src/main/java/com/baeldung/jaxws/client/EmployeeNotFound_Exception.java @@ -0,0 +1,54 @@ + +package com.baeldung.jaxws.client; + +import javax.xml.ws.WebFault; + + +/** + * This class was generated by the JAX-WS RI. + * JAX-WS RI 2.2.9-b130926.1035 + * Generated source version: 2.2 + * + */ +@WebFault(name = "EmployeeNotFound", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/") +public class EmployeeNotFound_Exception + extends Exception +{ + + /** + * Java type that goes as soapenv:Fault detail element. + * + */ + private EmployeeNotFound faultInfo; + + /** + * + * @param faultInfo + * @param message + */ + public EmployeeNotFound_Exception(String message, EmployeeNotFound faultInfo) { + super(message); + this.faultInfo = faultInfo; + } + + /** + * + * @param faultInfo + * @param cause + * @param message + */ + public EmployeeNotFound_Exception(String message, EmployeeNotFound faultInfo, Throwable cause) { + super(message, cause); + this.faultInfo = faultInfo; + } + + /** + * + * @return + * returns fault bean: com.baeldung.jaxws.client.EmployeeNotFound + */ + public EmployeeNotFound getFaultInfo() { + return faultInfo; + } + +} diff --git a/jee7/src/main/java/com/baeldung/jaxws/client/EmployeeService.java b/jee7/src/main/java/com/baeldung/jaxws/client/EmployeeService.java new file mode 100644 index 0000000000..a2c007c5a0 --- /dev/null +++ b/jee7/src/main/java/com/baeldung/jaxws/client/EmployeeService.java @@ -0,0 +1,139 @@ + +package com.baeldung.jaxws.client; + +import java.util.List; +import javax.jws.WebMethod; +import javax.jws.WebParam; +import javax.jws.WebResult; +import javax.jws.WebService; +import javax.xml.bind.annotation.XmlSeeAlso; +import javax.xml.ws.Action; +import javax.xml.ws.FaultAction; +import javax.xml.ws.RequestWrapper; +import javax.xml.ws.ResponseWrapper; + + +/** + * This class was generated by the JAX-WS RI. + * JAX-WS RI 2.2.9-b130926.1035 + * Generated source version: 2.2 + * + */ +@WebService(name = "EmployeeService", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/") +@XmlSeeAlso({ + ObjectFactory.class +}) +public interface EmployeeService { + + + /** + * + * @param arg0 + * @return + * returns com.baeldung.jaxws.client.Employee + * @throws EmployeeNotFound_Exception + */ + @WebMethod + @WebResult(targetNamespace = "") + @RequestWrapper(localName = "getEmployee", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/", className = "com.baeldung.jaxws.client.GetEmployee") + @ResponseWrapper(localName = "getEmployeeResponse", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/", className = "com.baeldung.jaxws.client.GetEmployeeResponse") + @Action(input = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/getEmployeeRequest", output = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/getEmployeeResponse", fault = { + @FaultAction(className = EmployeeNotFound_Exception.class, value = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/getEmployee/Fault/EmployeeNotFound") + }) + public Employee getEmployee( + @WebParam(name = "arg0", targetNamespace = "") + int arg0) + throws EmployeeNotFound_Exception + ; + + /** + * + * @param arg1 + * @param arg0 + * @return + * returns com.baeldung.jaxws.client.Employee + * @throws EmployeeNotFound_Exception + */ + @WebMethod + @WebResult(targetNamespace = "") + @RequestWrapper(localName = "updateEmployee", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/", className = "com.baeldung.jaxws.client.UpdateEmployee") + @ResponseWrapper(localName = "updateEmployeeResponse", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/", className = "com.baeldung.jaxws.client.UpdateEmployeeResponse") + @Action(input = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/updateEmployeeRequest", output = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/updateEmployeeResponse", fault = { + @FaultAction(className = EmployeeNotFound_Exception.class, value = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/updateEmployee/Fault/EmployeeNotFound") + }) + public Employee updateEmployee( + @WebParam(name = "arg0", targetNamespace = "") + int arg0, + @WebParam(name = "arg1", targetNamespace = "") + String arg1) + throws EmployeeNotFound_Exception + ; + + /** + * + * @return + * returns java.util.List + */ + @WebMethod + @WebResult(targetNamespace = "") + @RequestWrapper(localName = "getAllEmployees", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/", className = "com.baeldung.jaxws.client.GetAllEmployees") + @ResponseWrapper(localName = "getAllEmployeesResponse", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/", className = "com.baeldung.jaxws.client.GetAllEmployeesResponse") + @Action(input = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/getAllEmployeesRequest", output = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/getAllEmployeesResponse") + public List getAllEmployees(); + + /** + * + * @param arg0 + * @return + * returns boolean + * @throws EmployeeNotFound_Exception + */ + @WebMethod + @WebResult(targetNamespace = "") + @RequestWrapper(localName = "deleteEmployee", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/", className = "com.baeldung.jaxws.client.DeleteEmployee") + @ResponseWrapper(localName = "deleteEmployeeResponse", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/", className = "com.baeldung.jaxws.client.DeleteEmployeeResponse") + @Action(input = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/deleteEmployeeRequest", output = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/deleteEmployeeResponse", fault = { + @FaultAction(className = EmployeeNotFound_Exception.class, value = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/deleteEmployee/Fault/EmployeeNotFound") + }) + public boolean deleteEmployee( + @WebParam(name = "arg0", targetNamespace = "") + int arg0) + throws EmployeeNotFound_Exception + ; + + /** + * + * @param arg1 + * @param arg0 + * @return + * returns com.baeldung.jaxws.client.Employee + * @throws EmployeeAlreadyExists_Exception + */ + @WebMethod + @WebResult(targetNamespace = "") + @RequestWrapper(localName = "addEmployee", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/", className = "com.baeldung.jaxws.client.AddEmployee") + @ResponseWrapper(localName = "addEmployeeResponse", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/", className = "com.baeldung.jaxws.client.AddEmployeeResponse") + @Action(input = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/addEmployeeRequest", output = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/addEmployeeResponse", fault = { + @FaultAction(className = EmployeeAlreadyExists_Exception.class, value = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/addEmployee/Fault/EmployeeAlreadyExists") + }) + public Employee addEmployee( + @WebParam(name = "arg0", targetNamespace = "") + int arg0, + @WebParam(name = "arg1", targetNamespace = "") + String arg1) + throws EmployeeAlreadyExists_Exception + ; + + /** + * + * @return + * returns int + */ + @WebMethod + @WebResult(targetNamespace = "") + @RequestWrapper(localName = "countEmployees", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/", className = "com.baeldung.jaxws.client.CountEmployees") + @ResponseWrapper(localName = "countEmployeesResponse", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/", className = "com.baeldung.jaxws.client.CountEmployeesResponse") + @Action(input = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/countEmployeesRequest", output = "http://bottomup.server.jaxws.baeldung.com/EmployeeService/countEmployeesResponse") + public int countEmployees(); + +} diff --git a/jee7/src/main/java/com/baeldung/jaxws/client/EmployeeServiceClient.java b/jee7/src/main/java/com/baeldung/jaxws/client/EmployeeServiceClient.java index 3d5450690a..d2d5111109 100644 --- a/jee7/src/main/java/com/baeldung/jaxws/client/EmployeeServiceClient.java +++ b/jee7/src/main/java/com/baeldung/jaxws/client/EmployeeServiceClient.java @@ -1,25 +1,18 @@ package com.baeldung.jaxws.client; - -import com.baeldung.jaxws.server.bottomup.EmployeeService; - -import javax.xml.namespace.QName; -import javax.xml.ws.Service; import java.net.URL; +import java.util.List; public class EmployeeServiceClient { public static void main(String[] args) throws Exception { - URL url = new URL("http://localhost:8081/employeeservice?wsdl"); - QName qname = new QName("http://bottomup.server.jaxws.baeldung.com/", "EmployeeServiceImplService"); + URL url = new URL("http://localhost:8080/employeeservice?wsdl"); - Service service = Service.create(url, qname); + EmployeeService_Service employeeService_Service = new EmployeeService_Service(url); + EmployeeService employeeServiceProxy = employeeService_Service.getEmployeeServiceImplPort(); - EmployeeService employeeService = service.getPort(EmployeeService.class); - employeeService.countEmployees(); - - System.out.println(employeeService.countEmployees()); + List allEmployees = employeeServiceProxy.getAllEmployees(); } } \ No newline at end of file diff --git a/jee7/src/main/java/com/baeldung/jaxws/client/EmployeeService_Service.java b/jee7/src/main/java/com/baeldung/jaxws/client/EmployeeService_Service.java new file mode 100644 index 0000000000..b214f9cd90 --- /dev/null +++ b/jee7/src/main/java/com/baeldung/jaxws/client/EmployeeService_Service.java @@ -0,0 +1,94 @@ + +package com.baeldung.jaxws.client; + +import java.net.MalformedURLException; +import java.net.URL; +import javax.xml.namespace.QName; +import javax.xml.ws.Service; +import javax.xml.ws.WebEndpoint; +import javax.xml.ws.WebServiceClient; +import javax.xml.ws.WebServiceException; +import javax.xml.ws.WebServiceFeature; + + +/** + * This class was generated by the JAX-WS RI. + * JAX-WS RI 2.2.9-b130926.1035 + * Generated source version: 2.2 + * + */ +@WebServiceClient(name = "EmployeeService", targetNamespace = "http://bottomup.server.jaxws.baeldung.com/", wsdlLocation = "http://localhost:8080/employeeservice?wsdl") +public class EmployeeService_Service + extends Service +{ + + private final static URL EMPLOYEESERVICE_WSDL_LOCATION; + private final static WebServiceException EMPLOYEESERVICE_EXCEPTION; + private final static QName EMPLOYEESERVICE_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "EmployeeService"); + + static { + URL url = null; + WebServiceException e = null; + try { + url = new URL("http://localhost:8080/employeeservice?wsdl"); + } catch (MalformedURLException ex) { + e = new WebServiceException(ex); + } + EMPLOYEESERVICE_WSDL_LOCATION = url; + EMPLOYEESERVICE_EXCEPTION = e; + } + + public EmployeeService_Service() { + super(__getWsdlLocation(), EMPLOYEESERVICE_QNAME); + } + + public EmployeeService_Service(WebServiceFeature... features) { + super(__getWsdlLocation(), EMPLOYEESERVICE_QNAME, features); + } + + public EmployeeService_Service(URL wsdlLocation) { + super(wsdlLocation, EMPLOYEESERVICE_QNAME); + } + + public EmployeeService_Service(URL wsdlLocation, WebServiceFeature... features) { + super(wsdlLocation, EMPLOYEESERVICE_QNAME, features); + } + + public EmployeeService_Service(URL wsdlLocation, QName serviceName) { + super(wsdlLocation, serviceName); + } + + public EmployeeService_Service(URL wsdlLocation, QName serviceName, WebServiceFeature... features) { + super(wsdlLocation, serviceName, features); + } + + /** + * + * @return + * returns EmployeeService + */ + @WebEndpoint(name = "EmployeeServiceImplPort") + public EmployeeService getEmployeeServiceImplPort() { + return super.getPort(new QName("http://bottomup.server.jaxws.baeldung.com/", "EmployeeServiceImplPort"), EmployeeService.class); + } + + /** + * + * @param features + * A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the features parameter will have their default values. + * @return + * returns EmployeeService + */ + @WebEndpoint(name = "EmployeeServiceImplPort") + public EmployeeService getEmployeeServiceImplPort(WebServiceFeature... features) { + return super.getPort(new QName("http://bottomup.server.jaxws.baeldung.com/", "EmployeeServiceImplPort"), EmployeeService.class, features); + } + + private static URL __getWsdlLocation() { + if (EMPLOYEESERVICE_EXCEPTION!= null) { + throw EMPLOYEESERVICE_EXCEPTION; + } + return EMPLOYEESERVICE_WSDL_LOCATION; + } + +} diff --git a/jee7/src/main/java/com/baeldung/jaxws/client/GetAllEmployees.java b/jee7/src/main/java/com/baeldung/jaxws/client/GetAllEmployees.java new file mode 100644 index 0000000000..137cf06704 --- /dev/null +++ b/jee7/src/main/java/com/baeldung/jaxws/client/GetAllEmployees.java @@ -0,0 +1,32 @@ + +package com.baeldung.jaxws.client; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for getAllEmployees complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="getAllEmployees">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "getAllEmployees") +public class GetAllEmployees { + + +} diff --git a/jee7/src/main/java/com/baeldung/jaxws/client/GetAllEmployeesResponse.java b/jee7/src/main/java/com/baeldung/jaxws/client/GetAllEmployeesResponse.java new file mode 100644 index 0000000000..be3d502222 --- /dev/null +++ b/jee7/src/main/java/com/baeldung/jaxws/client/GetAllEmployeesResponse.java @@ -0,0 +1,69 @@ + +package com.baeldung.jaxws.client; + +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for getAllEmployeesResponse complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="getAllEmployeesResponse">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="return" type="{http://bottomup.server.jaxws.baeldung.com/}employee" maxOccurs="unbounded" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "getAllEmployeesResponse", propOrder = { + "_return" +}) +public class GetAllEmployeesResponse { + + @XmlElement(name = "return") + protected List _return; + + /** + * Gets the value of the return property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the return property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getReturn().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link Employee } + * + * + */ + public List getReturn() { + if (_return == null) { + _return = new ArrayList(); + } + return this._return; + } + +} diff --git a/jee7/src/main/java/com/baeldung/jaxws/client/GetEmployee.java b/jee7/src/main/java/com/baeldung/jaxws/client/GetEmployee.java new file mode 100644 index 0000000000..333073be69 --- /dev/null +++ b/jee7/src/main/java/com/baeldung/jaxws/client/GetEmployee.java @@ -0,0 +1,52 @@ + +package com.baeldung.jaxws.client; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for getEmployee complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="getEmployee">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="arg0" type="{http://www.w3.org/2001/XMLSchema}int"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "getEmployee", propOrder = { + "arg0" +}) +public class GetEmployee { + + protected int arg0; + + /** + * Gets the value of the arg0 property. + * + */ + public int getArg0() { + return arg0; + } + + /** + * Sets the value of the arg0 property. + * + */ + public void setArg0(int value) { + this.arg0 = value; + } + +} diff --git a/jee7/src/main/java/com/baeldung/jaxws/client/GetEmployeeResponse.java b/jee7/src/main/java/com/baeldung/jaxws/client/GetEmployeeResponse.java new file mode 100644 index 0000000000..6926c8a6f6 --- /dev/null +++ b/jee7/src/main/java/com/baeldung/jaxws/client/GetEmployeeResponse.java @@ -0,0 +1,62 @@ + +package com.baeldung.jaxws.client; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for getEmployeeResponse complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="getEmployeeResponse">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="return" type="{http://bottomup.server.jaxws.baeldung.com/}employee" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "getEmployeeResponse", propOrder = { + "_return" +}) +public class GetEmployeeResponse { + + @XmlElement(name = "return") + protected Employee _return; + + /** + * Gets the value of the return property. + * + * @return + * possible object is + * {@link Employee } + * + */ + public Employee getReturn() { + return _return; + } + + /** + * Sets the value of the return property. + * + * @param value + * allowed object is + * {@link Employee } + * + */ + public void setReturn(Employee value) { + this._return = value; + } + +} diff --git a/jee7/src/main/java/com/baeldung/jaxws/client/ObjectFactory.java b/jee7/src/main/java/com/baeldung/jaxws/client/ObjectFactory.java new file mode 100644 index 0000000000..a16ae2567b --- /dev/null +++ b/jee7/src/main/java/com/baeldung/jaxws/client/ObjectFactory.java @@ -0,0 +1,295 @@ + +package com.baeldung.jaxws.client; + +import javax.xml.bind.JAXBElement; +import javax.xml.bind.annotation.XmlElementDecl; +import javax.xml.bind.annotation.XmlRegistry; +import javax.xml.namespace.QName; + + +/** + * This object contains factory methods for each + * Java content interface and Java element interface + * generated in the com.baeldung.jaxws.client package. + *

An ObjectFactory allows you to programatically + * construct new instances of the Java representation + * for XML content. The Java representation of XML + * content can consist of schema derived interfaces + * and classes representing the binding of schema + * type definitions, element declarations and model + * groups. Factory methods for each of these are + * provided in this class. + * + */ +@XmlRegistry +public class ObjectFactory { + + private final static QName _AddEmployeeResponse_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "addEmployeeResponse"); + private final static QName _EmployeeAlreadyExists_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "EmployeeAlreadyExists"); + private final static QName _GetEmployeeResponse_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "getEmployeeResponse"); + private final static QName _EmployeeNotFound_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "EmployeeNotFound"); + private final static QName _CountEmployees_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "countEmployees"); + private final static QName _UpdateEmployee_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "updateEmployee"); + private final static QName _DeleteEmployeeResponse_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "deleteEmployeeResponse"); + private final static QName _GetAllEmployeesResponse_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "getAllEmployeesResponse"); + private final static QName _DeleteEmployee_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "deleteEmployee"); + private final static QName _UpdateEmployeeResponse_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "updateEmployeeResponse"); + private final static QName _AddEmployee_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "addEmployee"); + private final static QName _GetAllEmployees_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "getAllEmployees"); + private final static QName _CountEmployeesResponse_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "countEmployeesResponse"); + private final static QName _GetEmployee_QNAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "getEmployee"); + + /** + * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.baeldung.jaxws.client + * + */ + public ObjectFactory() { + } + + /** + * Create an instance of {@link EmployeeNotFound } + * + */ + public EmployeeNotFound createEmployeeNotFound() { + return new EmployeeNotFound(); + } + + /** + * Create an instance of {@link CountEmployees } + * + */ + public CountEmployees createCountEmployees() { + return new CountEmployees(); + } + + /** + * Create an instance of {@link AddEmployeeResponse } + * + */ + public AddEmployeeResponse createAddEmployeeResponse() { + return new AddEmployeeResponse(); + } + + /** + * Create an instance of {@link EmployeeAlreadyExists } + * + */ + public EmployeeAlreadyExists createEmployeeAlreadyExists() { + return new EmployeeAlreadyExists(); + } + + /** + * Create an instance of {@link GetEmployeeResponse } + * + */ + public GetEmployeeResponse createGetEmployeeResponse() { + return new GetEmployeeResponse(); + } + + /** + * Create an instance of {@link DeleteEmployeeResponse } + * + */ + public DeleteEmployeeResponse createDeleteEmployeeResponse() { + return new DeleteEmployeeResponse(); + } + + /** + * Create an instance of {@link GetAllEmployeesResponse } + * + */ + public GetAllEmployeesResponse createGetAllEmployeesResponse() { + return new GetAllEmployeesResponse(); + } + + /** + * Create an instance of {@link UpdateEmployee } + * + */ + public UpdateEmployee createUpdateEmployee() { + return new UpdateEmployee(); + } + + /** + * Create an instance of {@link CountEmployeesResponse } + * + */ + public CountEmployeesResponse createCountEmployeesResponse() { + return new CountEmployeesResponse(); + } + + /** + * Create an instance of {@link GetEmployee } + * + */ + public GetEmployee createGetEmployee() { + return new GetEmployee(); + } + + /** + * Create an instance of {@link DeleteEmployee } + * + */ + public DeleteEmployee createDeleteEmployee() { + return new DeleteEmployee(); + } + + /** + * Create an instance of {@link UpdateEmployeeResponse } + * + */ + public UpdateEmployeeResponse createUpdateEmployeeResponse() { + return new UpdateEmployeeResponse(); + } + + /** + * Create an instance of {@link AddEmployee } + * + */ + public AddEmployee createAddEmployee() { + return new AddEmployee(); + } + + /** + * Create an instance of {@link GetAllEmployees } + * + */ + public GetAllEmployees createGetAllEmployees() { + return new GetAllEmployees(); + } + + /** + * Create an instance of {@link Employee } + * + */ + public Employee createEmployee() { + return new Employee(); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link AddEmployeeResponse }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://bottomup.server.jaxws.baeldung.com/", name = "addEmployeeResponse") + public JAXBElement createAddEmployeeResponse(AddEmployeeResponse value) { + return new JAXBElement(_AddEmployeeResponse_QNAME, AddEmployeeResponse.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link EmployeeAlreadyExists }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://bottomup.server.jaxws.baeldung.com/", name = "EmployeeAlreadyExists") + public JAXBElement createEmployeeAlreadyExists(EmployeeAlreadyExists value) { + return new JAXBElement(_EmployeeAlreadyExists_QNAME, EmployeeAlreadyExists.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link GetEmployeeResponse }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://bottomup.server.jaxws.baeldung.com/", name = "getEmployeeResponse") + public JAXBElement createGetEmployeeResponse(GetEmployeeResponse value) { + return new JAXBElement(_GetEmployeeResponse_QNAME, GetEmployeeResponse.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link EmployeeNotFound }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://bottomup.server.jaxws.baeldung.com/", name = "EmployeeNotFound") + public JAXBElement createEmployeeNotFound(EmployeeNotFound value) { + return new JAXBElement(_EmployeeNotFound_QNAME, EmployeeNotFound.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link CountEmployees }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://bottomup.server.jaxws.baeldung.com/", name = "countEmployees") + public JAXBElement createCountEmployees(CountEmployees value) { + return new JAXBElement(_CountEmployees_QNAME, CountEmployees.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link UpdateEmployee }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://bottomup.server.jaxws.baeldung.com/", name = "updateEmployee") + public JAXBElement createUpdateEmployee(UpdateEmployee value) { + return new JAXBElement(_UpdateEmployee_QNAME, UpdateEmployee.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link DeleteEmployeeResponse }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://bottomup.server.jaxws.baeldung.com/", name = "deleteEmployeeResponse") + public JAXBElement createDeleteEmployeeResponse(DeleteEmployeeResponse value) { + return new JAXBElement(_DeleteEmployeeResponse_QNAME, DeleteEmployeeResponse.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link GetAllEmployeesResponse }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://bottomup.server.jaxws.baeldung.com/", name = "getAllEmployeesResponse") + public JAXBElement createGetAllEmployeesResponse(GetAllEmployeesResponse value) { + return new JAXBElement(_GetAllEmployeesResponse_QNAME, GetAllEmployeesResponse.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link DeleteEmployee }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://bottomup.server.jaxws.baeldung.com/", name = "deleteEmployee") + public JAXBElement createDeleteEmployee(DeleteEmployee value) { + return new JAXBElement(_DeleteEmployee_QNAME, DeleteEmployee.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link UpdateEmployeeResponse }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://bottomup.server.jaxws.baeldung.com/", name = "updateEmployeeResponse") + public JAXBElement createUpdateEmployeeResponse(UpdateEmployeeResponse value) { + return new JAXBElement(_UpdateEmployeeResponse_QNAME, UpdateEmployeeResponse.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link AddEmployee }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://bottomup.server.jaxws.baeldung.com/", name = "addEmployee") + public JAXBElement createAddEmployee(AddEmployee value) { + return new JAXBElement(_AddEmployee_QNAME, AddEmployee.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link GetAllEmployees }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://bottomup.server.jaxws.baeldung.com/", name = "getAllEmployees") + public JAXBElement createGetAllEmployees(GetAllEmployees value) { + return new JAXBElement(_GetAllEmployees_QNAME, GetAllEmployees.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link CountEmployeesResponse }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://bottomup.server.jaxws.baeldung.com/", name = "countEmployeesResponse") + public JAXBElement createCountEmployeesResponse(CountEmployeesResponse value) { + return new JAXBElement(_CountEmployeesResponse_QNAME, CountEmployeesResponse.class, null, value); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link GetEmployee }{@code >}} + * + */ + @XmlElementDecl(namespace = "http://bottomup.server.jaxws.baeldung.com/", name = "getEmployee") + public JAXBElement createGetEmployee(GetEmployee value) { + return new JAXBElement(_GetEmployee_QNAME, GetEmployee.class, null, value); + } + +} diff --git a/jee7/src/main/java/com/baeldung/jaxws/client/UpdateEmployee.java b/jee7/src/main/java/com/baeldung/jaxws/client/UpdateEmployee.java new file mode 100644 index 0000000000..d1850428e8 --- /dev/null +++ b/jee7/src/main/java/com/baeldung/jaxws/client/UpdateEmployee.java @@ -0,0 +1,79 @@ + +package com.baeldung.jaxws.client; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for updateEmployee complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="updateEmployee">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="arg0" type="{http://www.w3.org/2001/XMLSchema}int"/>
+ *         <element name="arg1" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "updateEmployee", propOrder = { + "arg0", + "arg1" +}) +public class UpdateEmployee { + + protected int arg0; + protected String arg1; + + /** + * Gets the value of the arg0 property. + * + */ + public int getArg0() { + return arg0; + } + + /** + * Sets the value of the arg0 property. + * + */ + public void setArg0(int value) { + this.arg0 = value; + } + + /** + * Gets the value of the arg1 property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getArg1() { + return arg1; + } + + /** + * Sets the value of the arg1 property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setArg1(String value) { + this.arg1 = value; + } + +} diff --git a/jee7/src/main/java/com/baeldung/jaxws/client/UpdateEmployeeResponse.java b/jee7/src/main/java/com/baeldung/jaxws/client/UpdateEmployeeResponse.java new file mode 100644 index 0000000000..56119c6546 --- /dev/null +++ b/jee7/src/main/java/com/baeldung/jaxws/client/UpdateEmployeeResponse.java @@ -0,0 +1,62 @@ + +package com.baeldung.jaxws.client; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for updateEmployeeResponse complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="updateEmployeeResponse">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="return" type="{http://bottomup.server.jaxws.baeldung.com/}employee" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "updateEmployeeResponse", propOrder = { + "_return" +}) +public class UpdateEmployeeResponse { + + @XmlElement(name = "return") + protected Employee _return; + + /** + * Gets the value of the return property. + * + * @return + * possible object is + * {@link Employee } + * + */ + public Employee getReturn() { + return _return; + } + + /** + * Sets the value of the return property. + * + * @param value + * allowed object is + * {@link Employee } + * + */ + public void setReturn(Employee value) { + this._return = value; + } + +} diff --git a/jee7/src/main/java/com/baeldung/jaxws/client/package-info.java b/jee7/src/main/java/com/baeldung/jaxws/client/package-info.java new file mode 100644 index 0000000000..c264b876f9 --- /dev/null +++ b/jee7/src/main/java/com/baeldung/jaxws/client/package-info.java @@ -0,0 +1,2 @@ +@javax.xml.bind.annotation.XmlSchema(namespace = "http://bottomup.server.jaxws.baeldung.com/") +package com.baeldung.jaxws.client; diff --git a/jee7/src/test/java/com/baeldung/jaxws/EmployeeServiceLiveTest.java b/jee7/src/test/java/com/baeldung/jaxws/EmployeeServiceLiveTest.java index 4429703468..5663db712e 100644 --- a/jee7/src/test/java/com/baeldung/jaxws/EmployeeServiceLiveTest.java +++ b/jee7/src/test/java/com/baeldung/jaxws/EmployeeServiceLiveTest.java @@ -1,4 +1,4 @@ -/*package com.baeldung.jaxws; +package com.baeldung.jaxws; import static org.junit.Assert.assertEquals; @@ -7,7 +7,6 @@ import java.net.URL; import java.util.List; import javax.xml.namespace.QName; -import javax.xml.ws.Service; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; @@ -19,17 +18,18 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import com.baeldung.jaxws.exception.EmployeeAlreadyExists; -import com.baeldung.jaxws.exception.EmployeeNotFound; -import com.baeldung.jaxws.model.Employee; -import com.baeldung.jaxws.repository.EmployeeRepository; +import com.baeldung.jaxws.client.Employee; +import com.baeldung.jaxws.client.EmployeeAlreadyExists_Exception; +import com.baeldung.jaxws.client.EmployeeNotFound_Exception; +import com.baeldung.jaxws.client.EmployeeService; +import com.baeldung.jaxws.client.EmployeeService_Service; @RunWith(Arquillian.class) public class EmployeeServiceLiveTest { private static final String APP_NAME = "jee7"; private static final String WSDL_PATH = "EmployeeService?wsdl"; - private static QName SERVICE_NAME = new QName("http://jaxws.baeldung.com/", "EmployeeService"); + private static QName SERVICE_NAME = new QName("http://bottomup.server.jaxws.baeldung.com/", "EmployeeService"); private static URL wsdlUrl; @ArquillianResource @@ -39,8 +39,12 @@ public class EmployeeServiceLiveTest { @Deployment(testable = false) public static WebArchive createDeployment() { - return ShrinkWrap.create(WebArchive.class, APP_NAME + ".war").addPackage(EmployeeService.class.getPackage()).addPackage(Employee.class.getPackage()).addPackage(EmployeeNotFound.class.getPackage()).addPackage(EmployeeRepository.class.getPackage()) - .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml"); + return ShrinkWrap.create(WebArchive.class, APP_NAME + ".war") + .addPackage(com.baeldung.jaxws.server.bottomup.EmployeeService.class.getPackage()) + .addPackage(com.baeldung.jaxws.server.bottomup.model.Employee.class.getPackage()) + .addPackage(com.baeldung.jaxws.server.bottomup.exception.EmployeeNotFound.class.getPackage()) + .addPackage(com.baeldung.jaxws.server.repository.EmployeeRepository.class.getPackage()) + .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml"); } @Before @@ -51,8 +55,8 @@ public class EmployeeServiceLiveTest { e.printStackTrace(); } - Service service = Service.create(wsdlUrl, SERVICE_NAME); - employeeServiceProxy = service.getPort(EmployeeService.class); + EmployeeService_Service employeeService_Service = new EmployeeService_Service(wsdlUrl); + employeeServiceProxy = employeeService_Service.getEmployeeServiceImplPort(); } @Test @@ -63,49 +67,48 @@ public class EmployeeServiceLiveTest { } @Test - public void givenEmployees_whenGetAvailableEmployee_thenCorrectEmployeeReturned() throws EmployeeNotFound { + public void givenEmployees_whenGetAvailableEmployee_thenCorrectEmployeeReturned() throws EmployeeNotFound_Exception { Employee employee = employeeServiceProxy.getEmployee(2); assertEquals(employee.getFirstName(), "Jack"); } - @Test(expected = EmployeeNotFound.class) - public void givenEmployees_whenGetNonAvailableEmployee_thenEmployeeNotFoundException() throws EmployeeNotFound { + @Test(expected = EmployeeNotFound_Exception.class) + public void givenEmployees_whenGetNonAvailableEmployee_thenEmployeeNotFoundException() throws EmployeeNotFound_Exception { employeeServiceProxy.getEmployee(20); } @Test - public void givenEmployees_whenAddNewEmployee_thenEmployeeCountIncreased() throws EmployeeAlreadyExists { + public void givenEmployees_whenAddNewEmployee_thenEmployeeCountIncreased() throws EmployeeAlreadyExists_Exception { int employeeCount = employeeServiceProxy.countEmployees(); employeeServiceProxy.addEmployee(4, "Anna"); assertEquals(employeeServiceProxy.countEmployees(), employeeCount + 1); } - @Test(expected = EmployeeAlreadyExists.class) - public void givenEmployees_whenAddAlreadyExistingEmployee_thenEmployeeAlreadyExistsException() throws EmployeeAlreadyExists { + @Test(expected = EmployeeAlreadyExists_Exception.class) + public void givenEmployees_whenAddAlreadyExistingEmployee_thenEmployeeAlreadyExistsException() throws EmployeeAlreadyExists_Exception { employeeServiceProxy.addEmployee(1, "Anna"); } @Test - public void givenEmployees_whenUpdateExistingEmployee_thenUpdatedEmployeeReturned() throws EmployeeNotFound { + public void givenEmployees_whenUpdateExistingEmployee_thenUpdatedEmployeeReturned() throws EmployeeNotFound_Exception { Employee updated = employeeServiceProxy.updateEmployee(1, "Joan"); assertEquals(updated.getFirstName(), "Joan"); } - @Test(expected = EmployeeNotFound.class) - public void givenEmployees_whenUpdateNonExistingEmployee_thenEmployeeNotFoundException() throws EmployeeNotFound { + @Test(expected = EmployeeNotFound_Exception.class) + public void givenEmployees_whenUpdateNonExistingEmployee_thenEmployeeNotFoundException() throws EmployeeNotFound_Exception { employeeServiceProxy.updateEmployee(20, "Joan"); } @Test - public void givenEmployees_whenDeleteExistingEmployee_thenSuccessReturned() throws EmployeeNotFound { + public void givenEmployees_whenDeleteExistingEmployee_thenSuccessReturned() throws EmployeeNotFound_Exception { boolean deleteEmployee = employeeServiceProxy.deleteEmployee(3); assertEquals(deleteEmployee, true); } - @Test(expected = EmployeeNotFound.class) - public void givenEmployee_whenDeleteNonExistingEmployee_thenEmployeeNotFoundException() throws EmployeeNotFound { + @Test(expected = EmployeeNotFound_Exception.class) + public void givenEmployee_whenDeleteNonExistingEmployee_thenEmployeeNotFoundException() throws EmployeeNotFound_Exception { employeeServiceProxy.deleteEmployee(20); } } -*/ \ No newline at end of file