From: Gustavo Martin Morcuende Date: Fri, 8 Jan 2016 21:41:51 +0000 (+0100) Subject: Making space for REST services from JavaForFun repository X-Git-Url: https://git.gumartinm.name/?a=commitdiff_plain;h=0cca10b48185d02a8ef79a6a7c0fca5aa6e3a329;p=SpringWebServicesForFun%2F.git Making space for REST services from JavaForFun repository --- diff --git a/HOWSPRINGWORKS.txt b/HOWSPRINGWORKS.txt deleted file mode 100644 index 42f5276..0000000 --- a/HOWSPRINGWORKS.txt +++ /dev/null @@ -1,138 +0,0 @@ - - -*************************** Porque estoy usando sws:annotation-driven *************************** - -Porque estoy usando sws:annotation-driven y no declarando explícitamente los beans en XML existe un -orden de búsqueda de por defecto de macheadores de endpoints y excepciones. Ver: org.springframework.ws.config.AnnotationDrivenBeanDefinitionParser -Cuanto más bajo es el valor de order mayor es la prioridad. - - - 1. Manejadores de excepción, orden por defecto inicializado en AnnotationDrivenBeanDefinitionParser: - a) SoapFaultAnnotationExceptionResolver será el primer manejador de excepciones que se intente usar por defecto. order = 0 - b) SimpleSoapExceptionResolver será el último manejador de excepciones que se intente usar por defecto. order = Ordered.LOWEST_PRECEDENCE - Se usará si la excepción generada no pudo ser manejada por SoapFaultAnnotationExceptionResolver (porque la excepción no fue anotada con - @SoapFault. Este manejador se traga cualquier excepción. - - 2. Endpoints a buscar, orden por defecto inicializado en AnnotationDrivenBeanDefinitionParser: - a) PayloadRootAnnotationMethodEndpointMapping será el primer tipo de endpoints que se buscará y que se intentará usar. order = 0 - Si el XML SOAP que llega no machea ningún metodo anotado con este EndPoint pasamos a b). - b) SoapActionAnnotationMethodEndpointMapping será el segundo tipo de endpoints que se intentará usar. order = 1 - Si el XML SOAP que llega no machea ningún metodo anotado con este EndPoint pasamos a c). - c) AnnotationActionEndpointMapping será el último tipo de endpoints que se buscará. order = 2 - Si el XML SOAP que llega no machea tampoco métodos anotado con este EndPoint se - lanza NoEndpointFoundException desde org.springframework.ws.server.MessageDispatcher.dispatch() - - - EN LUGAR DE USAR LA ANOTACIÓN PODRÍAMOS HABER DECLARADO EXPLÍCITAMENTE CADA BEAN TAL QUE ASÍ: - - - - - - - - - - CON LA ANOTACIÓN ME AHORRO DECLARAR bean POR bean PERO LO MALO ES QUE INSTANCIO MANEJADORES QUE LUEGO NO USO :( - - - - -*************************** org.springframework.ws.server.MessageDispatcher *************************** - - -org.springframework.ws.server.MessageDispatcher ES LA CLASE QUE BUSCA EndPoints Y MANEJADORES DE EXCEPCIÓN - -ORDEN DE BUSQUEDA DE IMPLEMENTACIONES DE MANEJADORES DE EXCEPCION -Busca en el ApplicationContext manejadores de excepción siguiendo este orden. Cuanto más bajo es el valor de order -mayor es la prioridad. - -Por haber usado sws:annotation-driven el orden es el siguiente: - - -1. Primero se busca por excepciones anotadas con @SoapFault. Si la excepcion generada -está anotada son @SoapFault entonces se usa este manejador de excepcion. - -Implementation of the org.springframework.ws.server.EndpointExceptionResolver interface -that uses the SoapFault annotation to map exceptions to SOAP Faults. -org.springframework.ws.soap.server.endpoint.SoapFaultAnnotationExceptionResolver - - - -2. Segundo usa este manejador de excepción. Este manejador machea cualquier excepción así que si -este manejador llega primero siempre resolverá la excepción. -Simple, SOAP-specific EndpointExceptionResolver implementation that stores -the exception's message as the fault string. -org.springframework.ws.soap.server.endpoint.SimpleSoapExceptionResolver - - -3. Un manejador de excepciones inyectado por mi en un archivo XML de Spring. Si no se pone prioridad por defecto -Spring le pone la prioridad más baja que es lo que me pasó a mí al principio y SimpleSoapExceptionResolver -se meterá siempre por el medio :( -org.springframework.ws.soap.server.endpoint.SoapFaultMappingExceptionResolver - - -Si ninguno machea MessageDispatcher lanza la Excepción desde org.springframework.ws.server.MessageDispatcher.processEndpointException() - - - -ORDEN DE BUSQUEDA DE ENDPOINTS EN EL APPLICATION CONTEXT: -Busca en el ApplicationContext metodos anotados siguiendo este orden. Si el XML SOAP que me llega -machea con alguna de estas anotaciones, entonces ese método anotado será usado. Y NO SE CONTINUARÁ -BUSCANDO MÁS MANEJADORES. EN CUANTO UNO MACHEA YA NO SE BUSCA POR MÁS. - - -Por haber usado sws:annotation-driven el orden es el siguiente: - - -1. Primero se busca por métodos de este modo. Si el XML SOAP machea con algún metodo anotado -de este modo, entonces ese método será usado y no se continúa buscando matches. - -Implementation of the org.springframework.ws.server.EndpointMapping interface that uses the -PayloadRoot annotation to map methods to request payload root elements. -org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping -@Endpoint -public class MyEndpoint { - - @PayloadRoot(localPart = "Request", namespace = "http://springframework.org/spring-ws") - public Source doSomethingWithRequest() { - ... - } -} - -2. Segundo se busca por métodos de este modo. Si el XML SOAP machea con algún metodo anotado -de este modo, entonces ese método será usado y no se continúa buscando matches. - -Implementation of the org.springframework.ws.server.EndpointMapping interface that uses the -SoapAction annotation to map methods to the request SOAPAction header. -org.springframework.ws.soap.server.endpoint.mapping.SoapActionAnnotationMethodEndpointMapping -@Endpoint -public class MyEndpoint{ - - @SoapAction("http://springframework.org/spring-ws/SoapAction") - public Source doSomethingWithRequest() { - ... - } -} - - -3. Tercero se busca por métodos de este modo. Si el XML SOAP machea con algún metodo anotado -de este modo, entonces ese método será usado. - -Implementation of the org.springframework.ws.server.EndpointMapping interface that uses the -@Action annotation to map methods to a WS-Addressing Action header. -org.springframework.ws.soap.addressing.server.AnnotationActionEndpointMapping -@Endpoint -@Address("mailto:joe@fabrikam123.example") -public class MyEndpoint{ - - @Action("http://fabrikam123.example/mail/Delete") - public Source doSomethingWithRequest() { - ... - } -} - - -Si ninguno machea MessageDispatcher lanza NoEndpointFoundException desde org.springframework.ws.server.MessageDispatcher.dispatch() diff --git a/README.md b/README.md index d29c636..921ec04 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ SpringWebServicesForFun ======================= +SOAP + Messing around with Spring Web Services mvn clean install @@ -10,6 +12,5 @@ mvn jetty:run mvn clean install -Dmaven.test.skip=true -TODO: using Jetty instead of Tomcat For debugging: export MAVEN_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y" diff --git a/SOAP/HOWSPRINGWORKS.txt b/SOAP/HOWSPRINGWORKS.txt new file mode 100644 index 0000000..42f5276 --- /dev/null +++ b/SOAP/HOWSPRINGWORKS.txt @@ -0,0 +1,138 @@ + + +*************************** Porque estoy usando sws:annotation-driven *************************** + +Porque estoy usando sws:annotation-driven y no declarando explícitamente los beans en XML existe un +orden de búsqueda de por defecto de macheadores de endpoints y excepciones. Ver: org.springframework.ws.config.AnnotationDrivenBeanDefinitionParser +Cuanto más bajo es el valor de order mayor es la prioridad. + + + 1. Manejadores de excepción, orden por defecto inicializado en AnnotationDrivenBeanDefinitionParser: + a) SoapFaultAnnotationExceptionResolver será el primer manejador de excepciones que se intente usar por defecto. order = 0 + b) SimpleSoapExceptionResolver será el último manejador de excepciones que se intente usar por defecto. order = Ordered.LOWEST_PRECEDENCE + Se usará si la excepción generada no pudo ser manejada por SoapFaultAnnotationExceptionResolver (porque la excepción no fue anotada con + @SoapFault. Este manejador se traga cualquier excepción. + + 2. Endpoints a buscar, orden por defecto inicializado en AnnotationDrivenBeanDefinitionParser: + a) PayloadRootAnnotationMethodEndpointMapping será el primer tipo de endpoints que se buscará y que se intentará usar. order = 0 + Si el XML SOAP que llega no machea ningún metodo anotado con este EndPoint pasamos a b). + b) SoapActionAnnotationMethodEndpointMapping será el segundo tipo de endpoints que se intentará usar. order = 1 + Si el XML SOAP que llega no machea ningún metodo anotado con este EndPoint pasamos a c). + c) AnnotationActionEndpointMapping será el último tipo de endpoints que se buscará. order = 2 + Si el XML SOAP que llega no machea tampoco métodos anotado con este EndPoint se + lanza NoEndpointFoundException desde org.springframework.ws.server.MessageDispatcher.dispatch() + + + EN LUGAR DE USAR LA ANOTACIÓN PODRÍAMOS HABER DECLARADO EXPLÍCITAMENTE CADA BEAN TAL QUE ASÍ: + + + + + + + + + + CON LA ANOTACIÓN ME AHORRO DECLARAR bean POR bean PERO LO MALO ES QUE INSTANCIO MANEJADORES QUE LUEGO NO USO :( + + + + +*************************** org.springframework.ws.server.MessageDispatcher *************************** + + +org.springframework.ws.server.MessageDispatcher ES LA CLASE QUE BUSCA EndPoints Y MANEJADORES DE EXCEPCIÓN + +ORDEN DE BUSQUEDA DE IMPLEMENTACIONES DE MANEJADORES DE EXCEPCION +Busca en el ApplicationContext manejadores de excepción siguiendo este orden. Cuanto más bajo es el valor de order +mayor es la prioridad. + +Por haber usado sws:annotation-driven el orden es el siguiente: + + +1. Primero se busca por excepciones anotadas con @SoapFault. Si la excepcion generada +está anotada son @SoapFault entonces se usa este manejador de excepcion. + +Implementation of the org.springframework.ws.server.EndpointExceptionResolver interface +that uses the SoapFault annotation to map exceptions to SOAP Faults. +org.springframework.ws.soap.server.endpoint.SoapFaultAnnotationExceptionResolver + + + +2. Segundo usa este manejador de excepción. Este manejador machea cualquier excepción así que si +este manejador llega primero siempre resolverá la excepción. +Simple, SOAP-specific EndpointExceptionResolver implementation that stores +the exception's message as the fault string. +org.springframework.ws.soap.server.endpoint.SimpleSoapExceptionResolver + + +3. Un manejador de excepciones inyectado por mi en un archivo XML de Spring. Si no se pone prioridad por defecto +Spring le pone la prioridad más baja que es lo que me pasó a mí al principio y SimpleSoapExceptionResolver +se meterá siempre por el medio :( +org.springframework.ws.soap.server.endpoint.SoapFaultMappingExceptionResolver + + +Si ninguno machea MessageDispatcher lanza la Excepción desde org.springframework.ws.server.MessageDispatcher.processEndpointException() + + + +ORDEN DE BUSQUEDA DE ENDPOINTS EN EL APPLICATION CONTEXT: +Busca en el ApplicationContext metodos anotados siguiendo este orden. Si el XML SOAP que me llega +machea con alguna de estas anotaciones, entonces ese método anotado será usado. Y NO SE CONTINUARÁ +BUSCANDO MÁS MANEJADORES. EN CUANTO UNO MACHEA YA NO SE BUSCA POR MÁS. + + +Por haber usado sws:annotation-driven el orden es el siguiente: + + +1. Primero se busca por métodos de este modo. Si el XML SOAP machea con algún metodo anotado +de este modo, entonces ese método será usado y no se continúa buscando matches. + +Implementation of the org.springframework.ws.server.EndpointMapping interface that uses the +PayloadRoot annotation to map methods to request payload root elements. +org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping +@Endpoint +public class MyEndpoint { + + @PayloadRoot(localPart = "Request", namespace = "http://springframework.org/spring-ws") + public Source doSomethingWithRequest() { + ... + } +} + +2. Segundo se busca por métodos de este modo. Si el XML SOAP machea con algún metodo anotado +de este modo, entonces ese método será usado y no se continúa buscando matches. + +Implementation of the org.springframework.ws.server.EndpointMapping interface that uses the +SoapAction annotation to map methods to the request SOAPAction header. +org.springframework.ws.soap.server.endpoint.mapping.SoapActionAnnotationMethodEndpointMapping +@Endpoint +public class MyEndpoint{ + + @SoapAction("http://springframework.org/spring-ws/SoapAction") + public Source doSomethingWithRequest() { + ... + } +} + + +3. Tercero se busca por métodos de este modo. Si el XML SOAP machea con algún metodo anotado +de este modo, entonces ese método será usado. + +Implementation of the org.springframework.ws.server.EndpointMapping interface that uses the +@Action annotation to map methods to a WS-Addressing Action header. +org.springframework.ws.soap.addressing.server.AnnotationActionEndpointMapping +@Endpoint +@Address("mailto:joe@fabrikam123.example") +public class MyEndpoint{ + + @Action("http://fabrikam123.example/mail/Delete") + public Source doSomethingWithRequest() { + ... + } +} + + +Si ninguno machea MessageDispatcher lanza NoEndpointFoundException desde org.springframework.ws.server.MessageDispatcher.dispatch() diff --git a/SOAP/cxf/web-services-spring-cxf-client/pom.xml b/SOAP/cxf/web-services-spring-cxf-client/pom.xml new file mode 100644 index 0000000..c3de39a --- /dev/null +++ b/SOAP/cxf/web-services-spring-cxf-client/pom.xml @@ -0,0 +1,169 @@ + + 4.0.0 + + web-services-spring-cxf + de.spring.webservices + 1.0-SNAPSHOT + + web-services-spring-cxf-client + web-services-spring-cxf-client + http://gumartinm.name + + + src/main/build-resources/wsdl + ${basedir}/target/generated-sources/src/main/java + src/main/build-resources/bindings + + ${basedir}/src/main/build-resources/catalogs + + + + + org.springframework.ws + spring-ws-core + + + org.springframework.ws + spring-xml + + + org.jdom + jdom + + + + + + de.spring.webservices + web-services-spring-cxf-globalxsds + ${project.version} + + + + + + wsdl4j + wsdl4j + + + + + org.jvnet.jaxb2_commons + jaxb2-basics-runtime + 0.9.4 + + + + + junit + junit + test + + + org.springframework + spring-test + test + + + org.springframework.ws + spring-ws-test + test + + + + + ${project.artifactId} + + + ${basedir}/src/main/resources/ + + **/*.* + + + + + + + org.apache.cxf + cxf-codegen-plugin + 3.1.0 + + + generate-sources-from-wsdl + generate-sources + + wsdl2java + + + true + ${project.wsdl.target.path} + + + ${project.wsdl.sources.path}/example.wsdl + + ${project.bindings.path}/custombinding.xjb + + + -xjc-Xinheritance + -xjc-Xannotate + -catalog + ${project.catalogs.path}/catalog.cat + -verbose + + + + + + + + + + org.jvnet.jaxb2_commons + jaxb2-basics + 0.9.4 + + + + + org.jvnet.jaxb2_commons + jaxb2-basics-annotate + 1.0.1 + + + + + org.codehaus.mojo + build-helper-maven-plugin + 1.9.1 + + + add-source + generate-sources + + add-source + + + + ${project.wsdl.target.path} + + + + + + + + + diff --git a/SOAP/cxf/web-services-spring-cxf-client/src/main/build-resources/bindings/custombinding.xjb b/SOAP/cxf/web-services-spring-cxf-client/src/main/build-resources/bindings/custombinding.xjb new file mode 100644 index 0000000..d573e11 --- /dev/null +++ b/SOAP/cxf/web-services-spring-cxf-client/src/main/build-resources/bindings/custombinding.xjb @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + de.spring.webservices.operations.Request + @java.lang.suppresswarnings({"unchecked","rawtypes"}) + + + + de.spring.webservices.operations.Response + @java.lang.suppresswarnings({"unchecked","rawtypes"}) + + + + + + + + + diff --git a/SOAP/cxf/web-services-spring-cxf-client/src/main/build-resources/catalogs/catalog.cat b/SOAP/cxf/web-services-spring-cxf-client/src/main/build-resources/catalogs/catalog.cat new file mode 100644 index 0000000..4bc1c66 --- /dev/null +++ b/SOAP/cxf/web-services-spring-cxf-client/src/main/build-resources/catalogs/catalog.cat @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/SOAP/cxf/web-services-spring-cxf-client/src/main/build-resources/wsdl/example.wsdl b/SOAP/cxf/web-services-spring-cxf-client/src/main/build-resources/wsdl/example.wsdl new file mode 100644 index 0000000..e3f61ed --- /dev/null +++ b/SOAP/cxf/web-services-spring-cxf-client/src/main/build-resources/wsdl/example.wsdl @@ -0,0 +1,194 @@ + + + + + + + + + + + + + + + + + @java.lang.SuppressWarnings({"unchecked","rawtypes"}) + de.spring.webservices.operations.Request + + + + + + + + + + + + de.spring.webservices.operations.Response + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/SOAP/cxf/web-services-spring-cxf-client/src/main/java/de/spring/webservices/client/CustomFaultMessageResolver.java b/SOAP/cxf/web-services-spring-cxf-client/src/main/java/de/spring/webservices/client/CustomFaultMessageResolver.java new file mode 100644 index 0000000..244be4e --- /dev/null +++ b/SOAP/cxf/web-services-spring-cxf-client/src/main/java/de/spring/webservices/client/CustomFaultMessageResolver.java @@ -0,0 +1,83 @@ +package de.spring.webservices.client; + +import java.io.IOException; +import java.util.Iterator; + +import javax.xml.transform.Source; + +// cxf-codegen-plugin DOES generate again the objects in web-services-spring-jaxb2-globalxsds :( +// So I guess it is better to use the objects generated in this package +// than the ones from globalxsds even if they should be the same. +import name.gumartinm.spring_ws.parent.GeneralFault; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.oxm.Unmarshaller; +import org.springframework.oxm.XmlMappingException; +import org.springframework.ws.WebServiceMessage; +import org.springframework.ws.client.core.FaultMessageResolver; +import org.springframework.ws.soap.SoapBody; +import org.springframework.ws.soap.SoapFault; +import org.springframework.ws.soap.SoapFaultDetail; +import org.springframework.ws.soap.SoapFaultDetailElement; +import org.springframework.ws.soap.SoapMessage; +import org.springframework.ws.soap.client.core.SoapFaultMessageResolver; + +/** + * Enables us to log custom Fault remote messages. + * + */ +public class CustomFaultMessageResolver implements FaultMessageResolver { + +private static final Logger LOGGER = LoggerFactory.getLogger(CustomFaultMessageResolver.class); + + private final FaultMessageResolver defaultMessageResolver = new SoapFaultMessageResolver(); + + private Unmarshaller unmarshaller; + + @Override + public void resolveFault(WebServiceMessage message) throws IOException { + + // Same behavior as default message resolver (SoapFaultMessageResolver) but this implementation also + // logs error information. + if (LOGGER.isErrorEnabled()) { + try { + logErrorInformation(message); + } catch (Exception ex) { + LOGGER.error("CustomFaultMessageResolver exception:", ex); + } + } + + defaultMessageResolver.resolveFault(message); + } + + private void logErrorInformation(WebServiceMessage message) throws XmlMappingException, IOException { + SoapMessage soapMessage = (SoapMessage) message; + SoapBody body = soapMessage.getSoapBody(); + SoapFault soapFault = body != null ? body.getFault() : null; + SoapFaultDetail detail = soapFault != null ? soapFault.getFaultDetail() : null; + + if (detail != null) { + Iterator iterator = detail.getDetailEntries(); + while (iterator.hasNext()) { + SoapFaultDetailElement bodyElement = iterator.next(); + Source detailSource = bodyElement.getSource(); + // TODO: How to check if I am receiving GeneralFault before trying to unmarshal? + // Right now there will be exception if unmarshal doesn't return a GeneralFault object. + GeneralFault error = (GeneralFault)this.unmarshaller.unmarshal(detailSource); + LOGGER.error("TECHNICALERROR:"); + LOGGER.error(error.getTechnicalError()); + LOGGER.error("ELEMENTS:"); + error.getElements().forEach(element -> { + LOGGER.error("MESSAGE: " + element.getMessage()); + LOGGER.error("MESSAGEARGS:"); + element.getMessageArgs().forEach(messageArg -> LOGGER.error(messageArg)); + }); + } + } + } + + public void setUnmarshaller(Unmarshaller unmarshaller) { + this.unmarshaller = unmarshaller; + } +} diff --git a/SOAP/cxf/web-services-spring-cxf-client/src/main/java/de/spring/webservices/client/ExampleClientService.java b/SOAP/cxf/web-services-spring-cxf-client/src/main/java/de/spring/webservices/client/ExampleClientService.java new file mode 100644 index 0000000..32e1435 --- /dev/null +++ b/SOAP/cxf/web-services-spring-cxf-client/src/main/java/de/spring/webservices/client/ExampleClientService.java @@ -0,0 +1,76 @@ +package de.spring.webservices.client; + +import name.gumartinm.spring_ws.parent.ParentEnumType; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.ws.client.core.WebServiceTemplate; + +import de.spring.webservices.client.auto.CustomBindingExampleFault_Exception; +import de.spring.webservices.client.auto.CustomBindingExampleRequest; +import de.spring.webservices.client.auto.CustomBindingExampleResponse; +import de.spring.webservices.client.auto.ExampleFault_Exception; +import de.spring.webservices.client.auto.ExampleRequest; +import de.spring.webservices.client.auto.ExampleResponse; +import de.spring.webservices.client.auto.Examples; +import de.spring.webservices.client.auto.ExamplesService; + +/** + * Someone could write code like this one in order to send and receive + * information from our Web Services. + * + */ +@Service("exampleClientService") +public class ExampleClientService { + private final WebServiceTemplate webServiceTemplate; + + @Autowired + public ExampleClientService(WebServiceTemplate webServiceTemplate) { + this.webServiceTemplate = webServiceTemplate; + } + + public ExampleResponse sendAndReceiveJava() throws ExampleFault_Exception { + final ExampleRequest exampleRequest = new ExampleRequest(); + exampleRequest.setData("SCARLETT JAVA. IT IS CANON."); + + final Examples exampleService = new ExamplesService().getExamplesSoap12(); + final ExampleResponse exampleResponse = exampleService.example(exampleRequest); + + return exampleResponse; + } + + public ExampleResponse sendAndReceiveSpring() { + final ExampleRequest exampleRequest = new ExampleRequest(); + exampleRequest.setData("SCARLETT SPRING. IT IS CANON."); + + final ExampleResponse exampleResponse = (ExampleResponse) + this.webServiceTemplate.marshalSendAndReceive(exampleRequest); + + return exampleResponse; + } + + public CustomBindingExampleResponse sendAndReceiveJavaCustom() throws CustomBindingExampleFault_Exception { + final CustomBindingExampleRequest customBindingxampleRequest = + new CustomBindingExampleRequest(); + customBindingxampleRequest.setData("CUSTOM BINDING JAVA. SCARLETT. IT IS CANON."); + customBindingxampleRequest.setParentEnum(ParentEnumType.FIRST); + + final Examples exampleService = new ExamplesService().getExamplesSoap12(); + final CustomBindingExampleResponse customBindingExampleResponse = + exampleService.customBindingExample(customBindingxampleRequest); + + return customBindingExampleResponse; + } + + public CustomBindingExampleResponse sendAndReceiveSpringCustom() { + final CustomBindingExampleRequest customBindingxampleRequest = + new CustomBindingExampleRequest(); + customBindingxampleRequest.setData("CUSTOM BINDING SPRING. SCARLETT. IT IS CANON."); + + final CustomBindingExampleResponse customBindingExampleResponse = + (CustomBindingExampleResponse) this.webServiceTemplate + .marshalSendAndReceive(customBindingxampleRequest); + + return customBindingExampleResponse; + } +} diff --git a/SOAP/cxf/web-services-spring-cxf-client/src/main/java/de/spring/webservices/client/MainTest.java b/SOAP/cxf/web-services-spring-cxf-client/src/main/java/de/spring/webservices/client/MainTest.java new file mode 100644 index 0000000..54cc644 --- /dev/null +++ b/SOAP/cxf/web-services-spring-cxf-client/src/main/java/de/spring/webservices/client/MainTest.java @@ -0,0 +1,68 @@ +package de.spring.webservices.client; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.context.ApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +import de.spring.webservices.client.auto.CustomBindingExampleFault; +import de.spring.webservices.client.auto.CustomBindingExampleResponse; +import de.spring.webservices.client.auto.ExampleFault; +import de.spring.webservices.client.auto.ExampleResponse; + +/** + * This class is used just like a nice example about how to write and run client + * code which will send data to and from the Web Services. + * + */ +public class MainTest { + private static final Logger LOGGER = LoggerFactory.getLogger(MainTest.class); + + public ApplicationContext context; + + /** + * @param args + * @throws ExampleFault_Exception + * @throws CustomBindingExampleFault_Exception + */ + public static void main(final String[] args) { + final MainTest test = new MainTest(); + + test.context = new ClassPathXmlApplicationContext( + "classpath:spring-configuration/ws/client-spring-configuration.xml"); + + final ExampleClientService example = + (ExampleClientService) test.context.getBean("exampleClientService"); + + LOGGER.info("ExampleResponse Java:"); + ExampleResponse response; + try { + response = example.sendAndReceiveJava(); + LOGGER.info(response.getData()); + } catch (Exception e) { + LOGGER.info("ExampleResponse Java error:", e); + } + + + + LOGGER.info("CustomBindingExampleResponse Java:"); + CustomBindingExampleResponse customBindingResponse; + try { + customBindingResponse = example.sendAndReceiveJavaCustom(); + LOGGER.info(customBindingResponse.getData()); + } catch (Exception e) { + LOGGER.info("CustomBindingExampleResponse Java error:", e); + } + + + + LOGGER.info("ExampleResponse Spring:"); + response = example.sendAndReceiveSpring(); + LOGGER.info(response.getData()); + + + LOGGER.info("CustomBindingExampleResponse Spring:"); + customBindingResponse = example.sendAndReceiveSpringCustom(); + LOGGER.info(customBindingResponse.getData()); + } +} diff --git a/SOAP/cxf/web-services-spring-cxf-client/src/main/java/de/spring/webservices/client/transport/http/CustomHttpRequestMessageSender.java b/SOAP/cxf/web-services-spring-cxf-client/src/main/java/de/spring/webservices/client/transport/http/CustomHttpRequestMessageSender.java new file mode 100644 index 0000000..cf44220 --- /dev/null +++ b/SOAP/cxf/web-services-spring-cxf-client/src/main/java/de/spring/webservices/client/transport/http/CustomHttpRequestMessageSender.java @@ -0,0 +1,57 @@ +package de.spring.webservices.client.transport.http; + +import java.io.IOException; +import java.net.URI; + +import org.springframework.http.HttpMethod; +import org.springframework.http.client.ClientHttpRequest; +import org.springframework.http.client.ClientHttpRequestFactory; +import org.springframework.http.client.SimpleClientHttpRequestFactory; +import org.springframework.ws.transport.WebServiceConnection; +import org.springframework.ws.transport.http.AbstractHttpWebServiceMessageSender; +import org.springframework.ws.transport.http.ClientHttpRequestConnection; +import org.springframework.ws.transport.http.HttpTransportConstants; + + +/** + * Based on ClientHttpRequestMessageSender from the Spring WS framework. + * + *

+ * Spring WS framework also provides implementations based on the HTTP clients by Jakarta and Apache HttpClient: + * {@link https://hc.apache.org/httpcomponents-client-ga/} and {@link http://hc.apache.org/httpclient-3.x/} + *

+ * + *

+ * Four implementations for four HTTP clients: + *

+ *

+ */ +public class CustomHttpRequestMessageSender extends AbstractHttpWebServiceMessageSender { + private static final String MY_CUSTOM_HEADER = "MY_CUSTOM_HEADER"; + + private final ClientHttpRequestFactory requestFactory; + + public CustomHttpRequestMessageSender() { + requestFactory = new SimpleClientHttpRequestFactory(); + } + + @Override + public WebServiceConnection createConnection(URI uri) throws IOException { + ClientHttpRequest request = requestFactory.createRequest(uri, HttpMethod.POST); + if (isAcceptGzipEncoding()) { + request.getHeaders().add(HttpTransportConstants.HEADER_ACCEPT_ENCODING, + HttpTransportConstants.CONTENT_ENCODING_GZIP); + } + + request.getHeaders().add(MY_CUSTOM_HEADER, "gumartinm.name"); + + return new ClientHttpRequestConnection(request); + } + +} diff --git a/SOAP/cxf/web-services-spring-cxf-client/src/main/resources/examples.xsd b/SOAP/cxf/web-services-spring-cxf-client/src/main/resources/examples.xsd new file mode 100644 index 0000000..59cd317 --- /dev/null +++ b/SOAP/cxf/web-services-spring-cxf-client/src/main/resources/examples.xsd @@ -0,0 +1,127 @@ + + + + + + + + + + + + + + + + @java.lang.SuppressWarnings({"unchecked","rawtypes"}) + de.spring.webservices.operations.Request + + + + + + + + + + + + de.spring.webservices.operations.Response + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SOAP/cxf/web-services-spring-cxf-client/src/main/resources/log4j2.xml b/SOAP/cxf/web-services-spring-cxf-client/src/main/resources/log4j2.xml new file mode 100644 index 0000000..5d47d57 --- /dev/null +++ b/SOAP/cxf/web-services-spring-cxf-client/src/main/resources/log4j2.xml @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SOAP/cxf/web-services-spring-cxf-client/src/main/resources/spring-configuration/ws/client-spring-configuration.xml b/SOAP/cxf/web-services-spring-cxf-client/src/main/resources/spring-configuration/ws/client-spring-configuration.xml new file mode 100644 index 0000000..7f6f1f3 --- /dev/null +++ b/SOAP/cxf/web-services-spring-cxf-client/src/main/resources/spring-configuration/ws/client-spring-configuration.xml @@ -0,0 +1,198 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + classpath:parent.xsd + + classpath:examples.xsd + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SOAP/cxf/web-services-spring-cxf-client/src/test/java/de/spring/webservices/client/ExampleClientServiceIntegrationTest.java b/SOAP/cxf/web-services-spring-cxf-client/src/test/java/de/spring/webservices/client/ExampleClientServiceIntegrationTest.java new file mode 100644 index 0000000..4877a5d --- /dev/null +++ b/SOAP/cxf/web-services-spring-cxf-client/src/test/java/de/spring/webservices/client/ExampleClientServiceIntegrationTest.java @@ -0,0 +1,78 @@ +package de.spring.webservices.client; + +import static org.junit.Assert.assertEquals; +import static org.springframework.ws.test.client.RequestMatchers.payload; +import static org.springframework.ws.test.client.ResponseCreators.withPayload; + +import javax.xml.transform.Source; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.ws.client.core.WebServiceTemplate; +import org.springframework.ws.test.client.MockWebServiceServer; +import org.springframework.xml.transform.StringSource; + +import de.spring.webservices.client.auto.CustomBindingExampleResponse; +import de.spring.webservices.client.auto.ExampleResponse; + + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration("classpath*:spring-configuration/ws/client-spring-configuration.xml") +public class ExampleClientServiceIntegrationTest { + + @Autowired + ExampleClientService exampleClientService; + + @Autowired + private WebServiceTemplate webServiceTemplate; + + private MockWebServiceServer mockServer; + + @Before + public void createServer() throws Exception { + mockServer = MockWebServiceServer.createServer(webServiceTemplate); + } + + @Test + public void customerClient() throws Exception { + final Source requestPayload = new StringSource( + "" + + "SCARLETT SPRING. IT IS CANON." + + ""); + final Source responsePayload = new StringSource( + "" + + "SNAKE EYES AND SCARLETT SPRING. IT IS CANON." + + ""); + mockServer.expect(payload(requestPayload)).andRespond( + withPayload(responsePayload)); + + final ExampleResponse response = exampleClientService.sendAndReceiveSpring(); + + assertEquals(response.getData(), "SNAKE EYES AND SCARLETT SPRING. IT IS CANON."); + mockServer.verify(); + } + + @Test + public void customerCustomClient() throws Exception { + final Source customRequestPayload = new StringSource( + "" + + "CUSTOM BINDING SPRING. SCARLETT. IT IS CANON." + + ""); + final Source customResponsePayload = new StringSource( + "" + + "CUSTOM BINDING SNAKE EYES AND SCARLETT SPRING. IT IS CANON." + + ""); + mockServer.expect(payload(customRequestPayload)).andRespond( + withPayload(customResponsePayload)); + + final CustomBindingExampleResponse response = exampleClientService.sendAndReceiveSpringCustom(); + + assertEquals(response.getData(), "CUSTOM BINDING SNAKE EYES AND SCARLETT SPRING. IT IS CANON."); + mockServer.verify(); + } +} + diff --git a/SOAP/cxf/web-services-spring-cxf-globalxsds/pom.xml b/SOAP/cxf/web-services-spring-cxf-globalxsds/pom.xml new file mode 100644 index 0000000..ef09daf --- /dev/null +++ b/SOAP/cxf/web-services-spring-cxf-globalxsds/pom.xml @@ -0,0 +1,97 @@ + + 4.0.0 + + web-services-spring-cxf + de.spring.webservices + 1.0-SNAPSHOT + + web-services-spring-cxf-globalxsds + web-services-spring-cxf-globalxsds + http://gumartinm.name + + + src/main/resources + ${basedir}/target/generated-sources/src/main/java + de.spring.webservices.parent.auto + src/main/build-resources/bindings + + + + + + + junit + junit + test + + + + + ${project.artifactId} + + + ${basedir}/src/main/resources + + **/*.* + + + + + + + org.apache.cxf + cxf-xjc-plugin + 3.0.3 + + true + + org.apache.cxf.xjcplugins:cxf-xjc-dv:3.0.3 + + + + + generate-sources-from-xsd + generate-sources + + xsdtojava + + + ${project.xsd.schemas.target.path} + + + true + ${project.xsd.schemas.source.path}/parent.xsd + ${project.bindings.path}/custombinding.xjb + ${project.xsd.schemas.package.name} + + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + 1.9.1 + + + add-source + generate-sources + + add-source + + + + ${project.xsd.schemas.target.path} + + + + + + + + diff --git a/SOAP/cxf/web-services-spring-cxf-globalxsds/src/main/build-resources/bindings/custombinding.xjb b/SOAP/cxf/web-services-spring-cxf-globalxsds/src/main/build-resources/bindings/custombinding.xjb new file mode 100644 index 0000000..8b4a110 --- /dev/null +++ b/SOAP/cxf/web-services-spring-cxf-globalxsds/src/main/build-resources/bindings/custombinding.xjb @@ -0,0 +1,8 @@ + + + + + diff --git a/SOAP/cxf/web-services-spring-cxf-globalxsds/src/main/java/de/spring/webservices/binders/XSDateTimeCustomBinder.java b/SOAP/cxf/web-services-spring-cxf-globalxsds/src/main/java/de/spring/webservices/binders/XSDateTimeCustomBinder.java new file mode 100644 index 0000000..f39921a --- /dev/null +++ b/SOAP/cxf/web-services-spring-cxf-globalxsds/src/main/java/de/spring/webservices/binders/XSDateTimeCustomBinder.java @@ -0,0 +1,35 @@ +package de.spring.webservices.binders; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.TimeZone; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + + +/** + * ATTENTION: if you are using this custombinder you will have to create custom payload + * validators for Spring (AS FAR AS I KNOW) + * + */ +public class XSDateTimeCustomBinder extends XmlAdapter { + + @Override + public Date unmarshal(final String dateTime) throws Exception { + // X pattern just works from Java >= 1.7 + final DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssX"); + formatter.setTimeZone(TimeZone.getTimeZone("Europe/Madrid")); + + return formatter.parse(dateTime); + } + + @Override + public String marshal(final Date dateTime) throws Exception { + // X pattern just works from Java >= 1.7 + final DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssX"); + formatter.setTimeZone(TimeZone.getTimeZone("Europe/Madrid")); + + return formatter.format(dateTime); + } +} diff --git a/SOAP/cxf/web-services-spring-cxf-globalxsds/src/main/java/de/spring/webservices/operations/Operations.java b/SOAP/cxf/web-services-spring-cxf-globalxsds/src/main/java/de/spring/webservices/operations/Operations.java new file mode 100644 index 0000000..13b5113 --- /dev/null +++ b/SOAP/cxf/web-services-spring-cxf-globalxsds/src/main/java/de/spring/webservices/operations/Operations.java @@ -0,0 +1,111 @@ +package de.spring.webservices.operations; + +/** + *

+ * Operations: WSDL v1.1 and v2.0 + *

+ * See: http://www.w3.org/TR/wsdl#_porttypes
+ * See: + * http://www.w3.org/TR/2007/REC-wsdl20-adjuncts-20070626/#patterns + * + */ +public interface Operations { + + /** + *

+ * Request-response operation WSDL v1.1 + *

+ * See: http://www.w3.org + * /TR/wsdl#_request-response + * + * @param + * Describes {@link Response} + * @param + * Describes {@link Request} + */ + public static interface RequestResponse { + T requestResponse(E request); + } + + /** + *

+ * One-way operation WSDL v1.1 + *

+ * See: http://www.w3.org/TR/wsdl + * #_one-way + * + * @param + * Describes {@link Response} + * @param + * Describes {@link Request} + */ + public interface OneWay { + void oneWay(E request); + } + + /** + *

+ * Notification operation WSDL v1.1 + *

+ * See: http://www.w3.org/TR + * /wsdl#_notification + * + * @param + * Describes {@link Response} + * @param + * Describes {@link Request} + */ + public interface Notification { + T notification(); + } + + /** + *

+ * In-Only message exchange pattern WSDL 2.0 + *

+ * See: + * http://www.w3.org/TR/2007/REC-wsdl20-adjuncts-20070626/#patterns + * + * @param + * Describes {@link Request} + */ + public interface InOnly { + void inOnly(E request); + } + + /** + *

+ * Robust In-Only message exchange pattern WSDL 2.0 + *

+ * See: + * http://www.w3.org/TR/2007/REC-wsdl20-adjuncts-20070626/#patterns + * + * @param + * Describes {@link Request} + */ + public interface RobustInOnly { + void robustInOnly(E request); + } + + /** + *

+ * In-Out message exchange pattern WSDL 2.0 + *

+ * See: + * http://www.w3.org/TR/2007/REC-wsdl20-adjuncts-20070626/#patterns + * + * @param + * Describes {@link Response} + * @param + * Describes {@link Request} + */ + public interface InOut { + T inOut(E request); + } +} \ No newline at end of file diff --git a/SOAP/cxf/web-services-spring-cxf-globalxsds/src/main/java/de/spring/webservices/operations/Request.java b/SOAP/cxf/web-services-spring-cxf-globalxsds/src/main/java/de/spring/webservices/operations/Request.java new file mode 100644 index 0000000..77d81f4 --- /dev/null +++ b/SOAP/cxf/web-services-spring-cxf-globalxsds/src/main/java/de/spring/webservices/operations/Request.java @@ -0,0 +1,5 @@ +package de.spring.webservices.operations; + +public interface Request { + +} diff --git a/SOAP/cxf/web-services-spring-cxf-globalxsds/src/main/java/de/spring/webservices/operations/Response.java b/SOAP/cxf/web-services-spring-cxf-globalxsds/src/main/java/de/spring/webservices/operations/Response.java new file mode 100644 index 0000000..3a2cbea --- /dev/null +++ b/SOAP/cxf/web-services-spring-cxf-globalxsds/src/main/java/de/spring/webservices/operations/Response.java @@ -0,0 +1,5 @@ +package de.spring.webservices.operations; + +public interface Response { + +} diff --git a/SOAP/cxf/web-services-spring-cxf-globalxsds/src/main/resources/parent.xsd b/SOAP/cxf/web-services-spring-cxf-globalxsds/src/main/resources/parent.xsd new file mode 100644 index 0000000..b38ca36 --- /dev/null +++ b/SOAP/cxf/web-services-spring-cxf-globalxsds/src/main/resources/parent.xsd @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SOAP/cxf/web-services-spring-cxf-server/pom.xml b/SOAP/cxf/web-services-spring-cxf-server/pom.xml new file mode 100644 index 0000000..6807bad --- /dev/null +++ b/SOAP/cxf/web-services-spring-cxf-server/pom.xml @@ -0,0 +1,216 @@ + + 4.0.0 + + web-services-spring-cxf + de.spring.webservices + 1.0-SNAPSHOT + + web-services-spring-cxf-server + war + web-services-spring-cxf-server + http://gumartinm.name + + + 9.3.0.RC0 + src/main/resources + ${basedir}/target/generated-sources/src/main/java + de.spring.webservices.server.auto + src/main/build-resources/bindings + + ${basedir}/src/main/build-resources/catalogs + + + + + org.springframework.ws + spring-ws-core + + + org.springframework.ws + spring-xml + + + org.jdom + jdom + + + + + + de.spring.webservices + web-services-spring-cxf-globalxsds + ${project.version} + + + + + + wsdl4j + wsdl4j + + + + + org.jvnet.jaxb2_commons + jaxb2-basics-runtime + 0.9.4 + + + + + javax.servlet + javax.servlet-api + 4.0.0-b01 + provided + + + + + junit + junit + test + + + org.springframework + spring-test + test + + + org.springframework.ws + spring-ws-test + test + + + org.mockito + mockito-core + test + + + + + ${project.artifactId} + + + ${basedir}/src/main/webapp + + **/*.* + + + + ${basedir}/src/main/resources/ + + **/*.* + + + + + + + org.apache.cxf + cxf-xjc-plugin + + true + + org.apache.cxf.xjcplugins:cxf-xjc-dv:3.0.3 + + + + + generate-sources-from-xsd + generate-sources + + xsdtojava + + + ${project.xsd.schemas.target.path} + + + true + ${project.xsd.schemas.source.path}/examples.xsd + ${project.bindings.path}/custombinding.xjb + ${project.catalogs.path}/catalog.cat + ${project.xsd.schemas.package.name} + + -Xinheritance + -Xannotate + + + + + + + + + + org.jvnet.jaxb2_commons + jaxb2-basics + 0.9.4 + + + + + org.jvnet.jaxb2_commons + jaxb2-basics-annotate + 1.0.1 + + + + + org.codehaus.mojo + build-helper-maven-plugin + 1.9.1 + + + add-source + generate-sources + + add-source + + + + ${project.xsd.schemas.target.path} + + + + + + + org.apache.maven.plugins + maven-war-plugin + 2.6 + + + + true + src/main/webapp + + WEB-INF/web.xml + + + + + + + org.eclipse.jetty + jetty-maven-plugin + ${jetty.version} + + ${basedir}/src/main/jetty/jetty-http.xml + + + + + diff --git a/SOAP/cxf/web-services-spring-cxf-server/src/main/build-resources/bindings/custombinding.xjb b/SOAP/cxf/web-services-spring-cxf-server/src/main/build-resources/bindings/custombinding.xjb new file mode 100644 index 0000000..60740a4 --- /dev/null +++ b/SOAP/cxf/web-services-spring-cxf-server/src/main/build-resources/bindings/custombinding.xjb @@ -0,0 +1,51 @@ + + + + + + + + + de.spring.webservices.operations.Request + @java.lang.SuppressWarnings({"unchecked","rawtypes"}) + + + + + + + de.spring.webservices.operations.Response + @java.lang.SuppressWarnings({"unchecked","rawtypes"}) + + + + + + + + + + + diff --git a/SOAP/cxf/web-services-spring-cxf-server/src/main/build-resources/catalogs/catalog.cat b/SOAP/cxf/web-services-spring-cxf-server/src/main/build-resources/catalogs/catalog.cat new file mode 100644 index 0000000..4bc1c66 --- /dev/null +++ b/SOAP/cxf/web-services-spring-cxf-server/src/main/build-resources/catalogs/catalog.cat @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/SOAP/cxf/web-services-spring-cxf-server/src/main/java/de/spring/webservices/endpoints/CustomHeaderInterceptor.java b/SOAP/cxf/web-services-spring-cxf-server/src/main/java/de/spring/webservices/endpoints/CustomHeaderInterceptor.java new file mode 100644 index 0000000..e1d5302 --- /dev/null +++ b/SOAP/cxf/web-services-spring-cxf-server/src/main/java/de/spring/webservices/endpoints/CustomHeaderInterceptor.java @@ -0,0 +1,50 @@ +package de.spring.webservices.endpoints; + +import javax.servlet.http.HttpServletRequest; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.util.StringUtils; +import org.springframework.ws.context.MessageContext; +import org.springframework.ws.server.EndpointInterceptor; +import org.springframework.ws.transport.context.TransportContext; +import org.springframework.ws.transport.context.TransportContextHolder; +import org.springframework.ws.transport.http.HttpServletConnection; + +public class CustomHeaderInterceptor implements EndpointInterceptor { + private static final Logger LOGGER = LoggerFactory.getLogger(CustomHeaderInterceptor.class); + private static final String MY_CUSTOM_HEADER = "MY_CUSTOM_HEADER"; + + @Override + public boolean handleRequest(MessageContext messageContext, Object endpoint) throws Exception { + TransportContext transport = TransportContextHolder.getTransportContext(); + + if (transport != null) { + HttpServletConnection connection = (HttpServletConnection) transport.getConnection(); + HttpServletRequest headers = connection.getHttpServletRequest(); + String headerValue = headers.getHeader(MY_CUSTOM_HEADER); + + if (!StringUtils.isEmpty(headerValue)) { + LOGGER.info("Custom header value: " + headerValue); + } + } + + return true; + } + + @Override + public boolean handleResponse(MessageContext messageContext, Object endpoint) throws Exception { + return true; + } + + @Override + public boolean handleFault(MessageContext messageContext, Object endpoint) throws Exception { + return true; + } + + @Override + public void afterCompletion(MessageContext messageContext, Object endpoint, Exception ex) throws Exception { + + } + +} diff --git a/SOAP/cxf/web-services-spring-cxf-server/src/main/java/de/spring/webservices/endpoints/ExampleEndPoint.java b/SOAP/cxf/web-services-spring-cxf-server/src/main/java/de/spring/webservices/endpoints/ExampleEndPoint.java new file mode 100644 index 0000000..e3e8da6 --- /dev/null +++ b/SOAP/cxf/web-services-spring-cxf-server/src/main/java/de/spring/webservices/endpoints/ExampleEndPoint.java @@ -0,0 +1,57 @@ +package de.spring.webservices.endpoints; + +import org.jdom2.Element; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.ws.context.MessageContext; +import org.springframework.ws.server.endpoint.annotation.Endpoint; +import org.springframework.ws.server.endpoint.annotation.PayloadRoot; +import org.springframework.ws.server.endpoint.annotation.RequestPayload; +import org.springframework.ws.server.endpoint.annotation.ResponsePayload; + +import de.spring.webservices.operations.Operations; +import de.spring.webservices.operations.Operations.RequestResponse; +import de.spring.webservices.server.auto.CustomBindingExampleRequest; +import de.spring.webservices.server.auto.CustomBindingExampleResponse; +import de.spring.webservices.server.auto.ExampleRequest; +import de.spring.webservices.server.auto.ExampleResponse; +import de.spring.webservices.services.ExampleService; + + +@Endpoint +public class ExampleEndPoint { + private static final String NAMESPACE_URI = "http://gumartinm.name/spring-ws/example"; + + private final Operations.RequestResponse + customBindingExampleService; + + private final ExampleService exampleService; + + @Autowired + public ExampleEndPoint( + RequestResponse customBindingExampleService, + ExampleService exampleService) { + this.customBindingExampleService = customBindingExampleService; + this.exampleService = exampleService; + } + + @PayloadRoot(localPart = "ExampleRequest", namespace = NAMESPACE_URI) + @ResponsePayload + public ExampleResponse exampleResponse( + @RequestPayload final ExampleRequest request, + @RequestPayload final Element element, + final MessageContext messageContext) { + + return this.exampleService.doResponse(request); + } + + @PayloadRoot(localPart = "CustomBindingExampleRequest", namespace = NAMESPACE_URI) + @ResponsePayload + public CustomBindingExampleResponse cuntomBindingExampleResponse( + @RequestPayload final CustomBindingExampleRequest requestObject, + @RequestPayload final Element element, + final MessageContext messageContext) { + + return this.customBindingExampleService.requestResponse(requestObject); + } +} + diff --git a/SOAP/cxf/web-services-spring-cxf-server/src/main/java/de/spring/webservices/endpoints/MyCustomMappingExceptionResolver.java b/SOAP/cxf/web-services-spring-cxf-server/src/main/java/de/spring/webservices/endpoints/MyCustomMappingExceptionResolver.java new file mode 100644 index 0000000..9d05061 --- /dev/null +++ b/SOAP/cxf/web-services-spring-cxf-server/src/main/java/de/spring/webservices/endpoints/MyCustomMappingExceptionResolver.java @@ -0,0 +1,140 @@ +package de.spring.webservices.endpoints; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; + +import javax.xml.transform.Result; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.oxm.Marshaller; +import org.springframework.util.CollectionUtils; +import org.springframework.ws.soap.SoapFault; +import org.springframework.ws.soap.SoapFaultDetail; +import org.springframework.ws.soap.server.endpoint.AbstractSoapFaultDefinitionExceptionResolver; +import org.springframework.ws.soap.server.endpoint.SoapFaultDefinition; +import org.springframework.ws.soap.server.endpoint.SoapFaultDefinitionEditor; + +import de.spring.webservices.exceptions.CustomBusinessException; +import de.spring.webservices.server.auto.Element; +import de.spring.webservices.server.auto.GeneralFault; + +public class MyCustomMappingExceptionResolver extends AbstractSoapFaultDefinitionExceptionResolver { + private static final Logger LOGGER = LoggerFactory.getLogger(MyCustomMappingExceptionResolver.class); + + private Marshaller marshaller; + + private Map exceptionMappings = new LinkedHashMap<>(); + + /** + * Set the mappings between exception class names and SOAP Faults. The exception class name can be a substring, with + * no wildcard support at present. + * + *

The values of the given properties object should use the format described in + * {@code SoapFaultDefinitionEditor}. + * + *

Follows the same matching algorithm as {@code SimpleMappingExceptionResolver}. + * + * @param mappings exception patterns (can also be fully qualified class names) as keys, fault definition texts as + * values + * @see SoapFaultDefinitionEditor + */ + public void setExceptionMappings(Properties mappings) { + for (Map.Entry entry : mappings.entrySet()) { + if (entry.getKey() instanceof String && entry.getValue() instanceof String) { + exceptionMappings.put((String)entry.getKey(), (String)entry.getValue()); + } + } + } + + @Override + protected SoapFaultDefinition getFaultDefinition(Object endpoint, Exception ex) { + if (!CollectionUtils.isEmpty(exceptionMappings)) { + String definitionText = null; + int deepest = Integer.MAX_VALUE; + for (String exceptionMapping : exceptionMappings.keySet()) { + int depth = getDepth(exceptionMapping, ex); + if (depth >= 0 && depth < deepest) { + deepest = depth; + definitionText = exceptionMappings.get(exceptionMapping); + } + } + if (definitionText != null) { + SoapFaultDefinitionEditor editor = new SoapFaultDefinitionEditor(); + editor.setAsText(definitionText); + return (SoapFaultDefinition) editor.getValue(); + } + } + return null; + } + + /** + * Return the depth to the superclass matching. {@code 0} means ex matches exactly. Returns {@code -1} if + * there's no match. Otherwise, returns depth. Lowest depth wins. + * + *

Follows the same algorithm as RollbackRuleAttribute, and SimpleMappingExceptionResolver + */ + protected int getDepth(String exceptionMapping, Exception ex) { + return getDepth(exceptionMapping, ex.getClass(), 0); + } + + @SuppressWarnings("unchecked") + private int getDepth(String exceptionMapping, Class exceptionClass, int depth) { + if (exceptionClass.getName().indexOf(exceptionMapping) != -1) { + return depth; + } + if (exceptionClass.equals(Throwable.class)) { + return -1; + } + return getDepth(exceptionMapping, (Class) exceptionClass.getSuperclass(), depth + 1); + } + + protected void customizeFault(Object endpoint, Exception ex, SoapFault fault) { + GeneralFault customFault = new GeneralFault(); + customFault.setTechnicalError(getStackTrace(ex)); + + Element element = buildElement(ex); + List elements = customFault.getElements(); + elements.add(element); + + SoapFaultDetail detail = fault.addFaultDetail(); + Result result = detail.getResult(); + try { + marshaller.marshal(customFault, result); + } catch (Exception marshallEx) { + LOGGER.error("MyCustomMappingExceptionResolver: marshaller error", marshallEx); + } + } + + public void setMarshaller(Marshaller marshaller) { + this.marshaller = marshaller; + } + + private Element buildElement(Exception ex) { + Element element = new Element(); + element.setMessage(ex.getMessage()); + + if (ex instanceof CustomBusinessException) { + CustomBusinessException customEx = (CustomBusinessException) ex; + List messageArgs = element.getMessageArgs(); + List argumentsEx = customEx.getArguments(); + + for (String argumentEx: argumentsEx) { + messageArgs.add(argumentEx); + } + } + + return element; + } + + private String getStackTrace(Throwable throwable) { + final StringWriter sw = new StringWriter(); + final PrintWriter pw = new PrintWriter(sw, true); + throwable.printStackTrace(pw); + return sw.getBuffer().toString(); + } +} diff --git a/SOAP/cxf/web-services-spring-cxf-server/src/main/java/de/spring/webservices/exceptions/BusinessException.java b/SOAP/cxf/web-services-spring-cxf-server/src/main/java/de/spring/webservices/exceptions/BusinessException.java new file mode 100644 index 0000000..f13ae91 --- /dev/null +++ b/SOAP/cxf/web-services-spring-cxf-server/src/main/java/de/spring/webservices/exceptions/BusinessException.java @@ -0,0 +1,22 @@ +package de.spring.webservices.exceptions; + +/** + * This exception will be caught by org.springframework.ws.soap.server.endpoint.SoapFaultMappingExceptionResolver + * + */ +public class BusinessException extends RuntimeException { + + private static final long serialVersionUID = -4042139454770293299L; + + public BusinessException() { + super(); + } + + public BusinessException(String message) { + super(message); + } + + public BusinessException(String message, Throwable cause) { + super(message, cause); + } +} diff --git a/SOAP/cxf/web-services-spring-cxf-server/src/main/java/de/spring/webservices/exceptions/CustomBusinessException.java b/SOAP/cxf/web-services-spring-cxf-server/src/main/java/de/spring/webservices/exceptions/CustomBusinessException.java new file mode 100644 index 0000000..549c0b9 --- /dev/null +++ b/SOAP/cxf/web-services-spring-cxf-server/src/main/java/de/spring/webservices/exceptions/CustomBusinessException.java @@ -0,0 +1,32 @@ +package de.spring.webservices.exceptions; + +import java.util.List; + +/** + * This exception will be caught by de.spring.webservices.endpoints.MyCustomMappingExceptionResolver + * + */ +public class CustomBusinessException extends RuntimeException { + private final List arguments; + + public CustomBusinessException(List arguments) { + super(); + this.arguments = arguments; + } + + public CustomBusinessException(String message, List arguments) { + super(message); + + this.arguments = arguments; + } + + public CustomBusinessException(String message, Throwable cause, List arguments) { + super(message, cause); + + this.arguments = arguments; + } + + public List getArguments() { + return arguments; + } +} diff --git a/SOAP/cxf/web-services-spring-cxf-server/src/main/java/de/spring/webservices/services/ExampleService.java b/SOAP/cxf/web-services-spring-cxf-server/src/main/java/de/spring/webservices/services/ExampleService.java new file mode 100644 index 0000000..881be73 --- /dev/null +++ b/SOAP/cxf/web-services-spring-cxf-server/src/main/java/de/spring/webservices/services/ExampleService.java @@ -0,0 +1,11 @@ +package de.spring.webservices.services; + +import de.spring.webservices.server.auto.ExampleRequest; +import de.spring.webservices.server.auto.ExampleResponse; + + +public interface ExampleService { + + public ExampleResponse doResponse(ExampleRequest request); + +} diff --git a/SOAP/cxf/web-services-spring-cxf-server/src/main/java/de/spring/webservices/services/impl/CustomBindingExampleServiceImpl.java b/SOAP/cxf/web-services-spring-cxf-server/src/main/java/de/spring/webservices/services/impl/CustomBindingExampleServiceImpl.java new file mode 100644 index 0000000..0247a3f --- /dev/null +++ b/SOAP/cxf/web-services-spring-cxf-server/src/main/java/de/spring/webservices/services/impl/CustomBindingExampleServiceImpl.java @@ -0,0 +1,44 @@ +package de.spring.webservices.services.impl; + +//import java.util.ArrayList; +//import java.util.List; + +import org.springframework.stereotype.Service; + +import de.spring.webservices.operations.Operations; +import de.spring.webservices.server.auto.CustomBindingExampleRequest; +import de.spring.webservices.server.auto.CustomBindingExampleResponse; +import de.spring.webservices.server.auto.ParentEnumType; +//import de.spring.webservices.exceptions.BusinessException; +//import de.spring.webservices.exceptions.CustomBusinessException; + + +@Service("customBindingExampleService") +public class CustomBindingExampleServiceImpl implements + Operations.RequestResponse { + + + @Override + public CustomBindingExampleResponse requestResponse(final CustomBindingExampleRequest request) { + + + // Example about how works org.springframework.ws.soap.server.endpoint.SoapFaultMappingExceptionResolver + // see soap-ws.xml Spring configuration file. +// throw new BusinessException("This feature has not been implemented yet."); + + // Example about how works de.spring.webservices.endpoints.MyCustomMappingExceptionResolver + // see soap-ws.xml Spring configuration file. +// List arguments = new ArrayList<>(); +// arguments.add("ARGUMENT 1"); +// arguments.add("ARGUMENT 2"); +// throw new CustomBusinessException("This feature has not been implemented yet.", arguments); + + CustomBindingExampleResponse response = new CustomBindingExampleResponse(); + + response.setData("CUSTOM BINDING SNAKE EYES AND " + request.getData()); + response.setParentEnum(ParentEnumType.FIRST); + + return response; + } + +} diff --git a/SOAP/cxf/web-services-spring-cxf-server/src/main/java/de/spring/webservices/services/impl/ExampleServiceImpl.java b/SOAP/cxf/web-services-spring-cxf-server/src/main/java/de/spring/webservices/services/impl/ExampleServiceImpl.java new file mode 100644 index 0000000..ec80b60 --- /dev/null +++ b/SOAP/cxf/web-services-spring-cxf-server/src/main/java/de/spring/webservices/services/impl/ExampleServiceImpl.java @@ -0,0 +1,23 @@ +package de.spring.webservices.services.impl; + +import org.springframework.stereotype.Service; + +import de.spring.webservices.server.auto.ExampleRequest; +import de.spring.webservices.server.auto.ExampleResponse; +import de.spring.webservices.services.ExampleService; + + +@Service("exampleService") +public class ExampleServiceImpl implements ExampleService { + + @Override + public ExampleResponse doResponse(final ExampleRequest request) { + + ExampleResponse response = new ExampleResponse(); + + response.setData("SNAKE EYES AND " + request.getData()); + + return response; + } + +} diff --git a/SOAP/cxf/web-services-spring-cxf-server/src/main/jetty/jetty-http.xml b/SOAP/cxf/web-services-spring-cxf-server/src/main/jetty/jetty-http.xml new file mode 100644 index 0000000..d995630 --- /dev/null +++ b/SOAP/cxf/web-services-spring-cxf-server/src/main/jetty/jetty-http.xml @@ -0,0 +1,71 @@ + + + + + + + + + + + + https + + + + 32768 + 8192 + 8192 + true + false + 512 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SOAP/cxf/web-services-spring-cxf-server/src/main/resources/examples.xsd b/SOAP/cxf/web-services-spring-cxf-server/src/main/resources/examples.xsd new file mode 100644 index 0000000..59cd317 --- /dev/null +++ b/SOAP/cxf/web-services-spring-cxf-server/src/main/resources/examples.xsd @@ -0,0 +1,127 @@ + + + + + + + + + + + + + + + + @java.lang.SuppressWarnings({"unchecked","rawtypes"}) + de.spring.webservices.operations.Request + + + + + + + + + + + + de.spring.webservices.operations.Response + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SOAP/cxf/web-services-spring-cxf-server/src/main/resources/log4j2.xml b/SOAP/cxf/web-services-spring-cxf-server/src/main/resources/log4j2.xml new file mode 100644 index 0000000..ea6ded3 --- /dev/null +++ b/SOAP/cxf/web-services-spring-cxf-server/src/main/resources/log4j2.xml @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SOAP/cxf/web-services-spring-cxf-server/src/main/resources/spring-configuration/spring-configuration.xml b/SOAP/cxf/web-services-spring-cxf-server/src/main/resources/spring-configuration/spring-configuration.xml new file mode 100644 index 0000000..7341c77 --- /dev/null +++ b/SOAP/cxf/web-services-spring-cxf-server/src/main/resources/spring-configuration/spring-configuration.xml @@ -0,0 +1,14 @@ + + + + diff --git a/SOAP/cxf/web-services-spring-cxf-server/src/main/resources/spring-configuration/ws/soap-ws.xml b/SOAP/cxf/web-services-spring-cxf-server/src/main/resources/spring-configuration/ws/soap-ws.xml new file mode 100644 index 0000000..cf3e7d7 --- /dev/null +++ b/SOAP/cxf/web-services-spring-cxf-server/src/main/resources/spring-configuration/ws/soap-ws.xml @@ -0,0 +1,284 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + classpath:parent.xsd + + classpath:examples.xsd + + + + + + + + + + + + + + + + + + SERVER + + + + + + + + + + + + + + + SERVER + + + + + + + + diff --git a/SOAP/cxf/web-services-spring-cxf-server/src/main/webapp/WEB-INF/web.xml b/SOAP/cxf/web-services-spring-cxf-server/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..7e14eba --- /dev/null +++ b/SOAP/cxf/web-services-spring-cxf-server/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,44 @@ + + + + Spring Web Services: example + + + + org.springframework.web.context.ContextLoaderListener + + + + + spring.profiles.active + ${environment.profile} + contextConfigLocation + + classpath*:spring-configuration/*.xml + + + + + + spring-ws + org.springframework.ws.transport.http.MessageDispatcherServlet + 1 + true + + contextConfigLocation + classpath*:spring-configuration/ws/*.xml + + + transformWsdlLocations + true + + + + + spring-ws + /spring-ws/* + + + diff --git a/SOAP/cxf/web-services-spring-cxf-server/src/test/java/de/spring/webservices/endpoints/ExampleEndPointIntegrationTest.java b/SOAP/cxf/web-services-spring-cxf-server/src/test/java/de/spring/webservices/endpoints/ExampleEndPointIntegrationTest.java new file mode 100644 index 0000000..f0204cb --- /dev/null +++ b/SOAP/cxf/web-services-spring-cxf-server/src/test/java/de/spring/webservices/endpoints/ExampleEndPointIntegrationTest.java @@ -0,0 +1,62 @@ +package de.spring.webservices.endpoints; + +import static org.springframework.ws.test.server.RequestCreators.withPayload; +import static org.springframework.ws.test.server.ResponseMatchers.payload; + +import javax.xml.transform.Source; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.ws.test.server.MockWebServiceClient; +import org.springframework.xml.transform.StringSource; + + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(locations = { "classpath*:spring-configuration/ws/soap-ws.xml" } ) +public class ExampleEndPointIntegrationTest { + + @Autowired + private ApplicationContext applicationContext; + + private MockWebServiceClient mockClient; + + @Before + public void createClient() { + mockClient = MockWebServiceClient.createClient(applicationContext); + } + + @Test + public void exampleEndpoint() throws Exception { + final Source requestPayload = new StringSource( + "" + + "SCARLETT" + + ""); + final Source responsePayload = new StringSource( + "" + + "SNAKE EYES AND SCARLETT" + + ""); + mockClient.sendRequest(withPayload(requestPayload)).andExpect( + payload(responsePayload)); + + + final Source customRequestPayload = new StringSource( + "" + + "SCARLETT" + + "2015-06-03T10:20:30Z" + + "FIRST" + + ""); + final Source customResponsePayload = new StringSource( + "" + + "CUSTOM BINDING SNAKE EYES AND SCARLETT" + + "FIRST" + + ""); + mockClient.sendRequest(withPayload(customRequestPayload)).andExpect( + payload(customResponsePayload)); + } +} + diff --git a/SOAP/cxf/web-services-spring-cxf-server/src/test/java/de/spring/webservices/endpoints/ExampleEndPointTest.java b/SOAP/cxf/web-services-spring-cxf-server/src/test/java/de/spring/webservices/endpoints/ExampleEndPointTest.java new file mode 100644 index 0000000..a4a279f --- /dev/null +++ b/SOAP/cxf/web-services-spring-cxf-server/src/test/java/de/spring/webservices/endpoints/ExampleEndPointTest.java @@ -0,0 +1,52 @@ +package de.spring.webservices.endpoints; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; + +import org.junit.Before; +import org.junit.Test; + +import de.spring.webservices.operations.Operations; +import de.spring.webservices.server.auto.CustomBindingExampleRequest; +import de.spring.webservices.server.auto.CustomBindingExampleResponse; +import de.spring.webservices.server.auto.ExampleRequest; +import de.spring.webservices.services.ExampleService; + + +public class ExampleEndPointTest { + + private ExampleService exampleService; + + private Operations.RequestResponse + customBindingExampleService; + + private ExampleEndPoint exampleEndPoint; + + @Before + public void init() { + exampleService = mock(ExampleService.class); + customBindingExampleService = mock(Operations.RequestResponse.class); + exampleEndPoint = new ExampleEndPoint(customBindingExampleService, exampleService); + } + + @Test + public void givenExampleRequestThenInvokeExampleService() { + ExampleRequest request = new ExampleRequest(); + request.setData("SCARLETT"); + + exampleEndPoint.exampleResponse(request, null, null); + + verify(exampleService).doResponse(request); + } + + @Test + public void givenCustomBindingExampleRequestThenInvokeCustomBindingExampleService() { + CustomBindingExampleRequest request = new CustomBindingExampleRequest(); + request.setData("SCARLETT"); + + exampleEndPoint.cuntomBindingExampleResponse(request, null, null); + + verify(customBindingExampleService).requestResponse(request); + } + +} diff --git a/SOAP/cxf/web-services-spring-cxf-server/src/test/java/de/spring/webservices/services/CustomBindingExampleServiceTest.java b/SOAP/cxf/web-services-spring-cxf-server/src/test/java/de/spring/webservices/services/CustomBindingExampleServiceTest.java new file mode 100644 index 0000000..d3b56be --- /dev/null +++ b/SOAP/cxf/web-services-spring-cxf-server/src/test/java/de/spring/webservices/services/CustomBindingExampleServiceTest.java @@ -0,0 +1,34 @@ +package de.spring.webservices.services; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import de.spring.webservices.operations.Operations; +import de.spring.webservices.server.auto.CustomBindingExampleRequest; +import de.spring.webservices.server.auto.CustomBindingExampleResponse; +import de.spring.webservices.services.impl.CustomBindingExampleServiceImpl; + + +public class CustomBindingExampleServiceTest { + + private Operations.RequestResponse + customBindingExampleService; + + @Before + public void init() { + customBindingExampleService = new CustomBindingExampleServiceImpl(); + } + + @Test + public void givenCustomBindingExampleRequestThenReturnCustomBindingExampleResponse() { + CustomBindingExampleRequest request = new CustomBindingExampleRequest(); + request.setData("SCARLETT"); + CustomBindingExampleResponse expected = new CustomBindingExampleResponse(); + expected.setData("CUSTOM BINDING SNAKE EYES AND " + request.getData()); + + CustomBindingExampleResponse actual = customBindingExampleService.requestResponse(request); + + Assert.assertEquals(expected.getData(), actual.getData()); + } +} diff --git a/SOAP/cxf/web-services-spring-cxf-server/src/test/java/de/spring/webservices/services/ExampleServiceTest.java b/SOAP/cxf/web-services-spring-cxf-server/src/test/java/de/spring/webservices/services/ExampleServiceTest.java new file mode 100644 index 0000000..9f33c5e --- /dev/null +++ b/SOAP/cxf/web-services-spring-cxf-server/src/test/java/de/spring/webservices/services/ExampleServiceTest.java @@ -0,0 +1,32 @@ +package de.spring.webservices.services; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import de.spring.webservices.server.auto.ExampleRequest; +import de.spring.webservices.server.auto.ExampleResponse; +import de.spring.webservices.services.impl.ExampleServiceImpl; + +public class ExampleServiceTest { + + private ExampleService exampleService; + + @Before + public void init() { + exampleService = new ExampleServiceImpl(); + } + + @Test + public void givenExampleRequestThenReturnExampleResponse() { + ExampleRequest request = new ExampleRequest(); + request.setData("SCARLETT"); + ExampleResponse expected = new ExampleResponse(); + expected.setData("SNAKE EYES AND " + request.getData()); + + ExampleResponse actual = exampleService.doResponse(request); + + Assert.assertEquals(expected.getData(), actual.getData()); + } + +} diff --git a/SOAP/cxf/web-services-spring-cxf/pom.xml b/SOAP/cxf/web-services-spring-cxf/pom.xml new file mode 100644 index 0000000..0e33534 --- /dev/null +++ b/SOAP/cxf/web-services-spring-cxf/pom.xml @@ -0,0 +1,240 @@ + + 4.0.0 + de.spring.webservices + web-services-spring-cxf + pom + 1.0-SNAPSHOT + web-services-spring-cxf + http://gumartinm.name + Web Services Spring Framework + + Gustavo Martin Morcuende + http://www.gumartinm.name + + + scm:git:http://git.gumartinm.name/SpringWebServicesForFun + http://git.gumartinm.name/SpringWebServicesForFun + + + + UTF-8 + UTF-8 + + 4.0.9.RELEASE + 2.2.1.RELEASE + + + + + release + + release + + + true + + + + + + + + org.apache.logging.log4j + log4j-slf4j-impl + 2.3 + + + + org.apache.logging.log4j + log4j-core + 2.3 + + + + org.slf4j + jcl-over-slf4j + 1.7.12 + + + cglib + cglib + 2.2.2 + + + + + + org.springframework.ws + spring-ws-core + ${spring.ws.version} + + + + commons-logging + commons-logging + + + + + org.springframework.ws + spring-xml + ${spring.ws.version} + + + + commons-logging + commons-logging + + + + + org.jdom + jdom + 2.0.2 + + + + + wsdl4j + wsdl4j + 1.6.3 + + + + + junit + junit + 4.12 + test + + + org.springframework + spring-test + ${spring.version} + test + + + org.springframework.ws + spring-ws-test + ${spring.ws.version} + test + + + + commons-logging + commons-logging + + + + + org.mockito + mockito-core + 2.0.11-beta + test + + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.18.1 + + + org.apache.maven.plugins + maven-failsafe-plugin + 2.18.1 + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.3 + + 1.8 + 1.8 + ${project.build.sourceEncoding} + + + + org.apache.maven.plugins + maven-resources-plugin + 2.7 + + ${project.build.sourceEncoding} + + + + org.apache.maven.plugins + maven-jar-plugin + 2.4 + + + + ${project.description} + ${project.version} + ${project.organization.name} + ${project.description} + ${project.version} + ${project.organization.name} + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + **/*IntegrationTest.java + + + + + org.apache.maven.plugins + maven-failsafe-plugin + + + + integration-test + verify + + + + + + **/*IntegrationTest.java + + + + + + diff --git a/SOAP/jaxb2/web-services-spring-jaxb2-client/pom.xml b/SOAP/jaxb2/web-services-spring-jaxb2-client/pom.xml new file mode 100644 index 0000000..9bd8253 --- /dev/null +++ b/SOAP/jaxb2/web-services-spring-jaxb2-client/pom.xml @@ -0,0 +1,218 @@ + + 4.0.0 + + web-services-spring-jaxb2 + de.spring.webservices + 1.0-SNAPSHOT + + web-services-spring-jaxb2-client + web-services-spring-jaxb2-client + http://gumartinm.name + + + src/main/build-resources/wsdl + ${project.build.directory}/generated-sources/src/main/java + de.spring.webservices.client.auto + src/main/build-resources/bindings + + + + + org.springframework.ws + spring-ws-core + + + org.springframework.ws + spring-xml + + + org.jdom + jdom + + + + + + de.spring.webservices + web-services-spring-jaxb2-globalxsds + ${project.version} + + + + + + wsdl4j + wsdl4j + + + + + junit + junit + test + + + org.springframework + spring-test + test + + + org.springframework.ws + spring-ws-test + test + + + org.mockito + mockito-core + test + + + + + ${project.artifactId} + + + ${basedir}/src/main/resources/ + + **/*.* + + + + + + org.jvnet.jaxb2.maven2 + maven-jaxb2-plugin + 0.13.1 + + + generate-sources-from-xsd + + generate + + generate-sources + + + + + WSDL + ${project.xsd.schemas.source.path} + + *.wsdl + + + + + + + + false + + + ${project.xsd.schemas.target.path} + + + ${project.xsd.schemas.package.name} + + + true + + true + + + ${project.build.sourceEncoding} + + + en + + + true + false + + + false + + true + + true + + -Xinheritance + -Xannotate + + + + org.jvnet.jaxb2_commons + jaxb2-basics + 0.9.5 + + + org.jvnet.jaxb2_commons + jaxb2-basics-annotate + 1.0.2 + + + + + true + + + + + false + src/main/build-resources/catalogs/catalog.cat + + + de.spring.webservices + web-services-spring-jaxb2-globalxsds + + + + + + + diff --git a/SOAP/jaxb2/web-services-spring-jaxb2-client/src/main/build-resources/catalogs/catalog.cat b/SOAP/jaxb2/web-services-spring-jaxb2-client/src/main/build-resources/catalogs/catalog.cat new file mode 100644 index 0000000..113acd0 --- /dev/null +++ b/SOAP/jaxb2/web-services-spring-jaxb2-client/src/main/build-resources/catalogs/catalog.cat @@ -0,0 +1,12 @@ + + +REWRITE_SYSTEM "http://gumartinm.name/spring-ws/parent/parent.xsd" "maven:de.spring.webservices:web-services-spring-jaxb2-globalxsds:jar::!/schemas/parent.xsd" + +-- + This configuration is better (it relies on namespace instead of schemaLocation) but it doesn't work + because of this bug: https://java.net/jira/browse/JAXB-942 + + PUBLIC "xmlns:parent" "maven:de.spring.webservices:web-services-spring-jaxb2-globalxsds:jar::!/schemas/parent.xsd" + +-- + diff --git a/SOAP/jaxb2/web-services-spring-jaxb2-client/src/main/build-resources/wsdl/example.wsdl b/SOAP/jaxb2/web-services-spring-jaxb2-client/src/main/build-resources/wsdl/example.wsdl new file mode 100644 index 0000000..202d87b --- /dev/null +++ b/SOAP/jaxb2/web-services-spring-jaxb2-client/src/main/build-resources/wsdl/example.wsdl @@ -0,0 +1,194 @@ + + + + + + + + + + + + + + + + + @java.lang.SuppressWarnings({"unchecked","rawtypes"}) + de.spring.webservices.operations.Request + + + + + + + + + + + + de.spring.webservices.operations.Response + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/SOAP/jaxb2/web-services-spring-jaxb2-client/src/main/java/de/spring/webservices/client/CustomFaultMessageResolver.java b/SOAP/jaxb2/web-services-spring-jaxb2-client/src/main/java/de/spring/webservices/client/CustomFaultMessageResolver.java new file mode 100644 index 0000000..9fdea6b --- /dev/null +++ b/SOAP/jaxb2/web-services-spring-jaxb2-client/src/main/java/de/spring/webservices/client/CustomFaultMessageResolver.java @@ -0,0 +1,83 @@ +package de.spring.webservices.client; + +import java.io.IOException; +import java.util.Iterator; + +import javax.xml.transform.Source; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.oxm.Unmarshaller; +import org.springframework.oxm.XmlMappingException; +import org.springframework.ws.WebServiceMessage; +import org.springframework.ws.client.core.FaultMessageResolver; +import org.springframework.ws.soap.SoapBody; +import org.springframework.ws.soap.SoapFault; +import org.springframework.ws.soap.SoapFaultDetail; +import org.springframework.ws.soap.SoapFaultDetailElement; +import org.springframework.ws.soap.SoapMessage; +import org.springframework.ws.soap.client.core.SoapFaultMessageResolver; + +// maven-jaxb2-plugin for WSDL DOES generate again the objects in web-services-spring-jaxb2-globalxsds :( +// So I guess it is better to use the objects generated in this package +// than the ones from globalxsds even if they should be the same. +import de.spring.webservices.client.auto.GeneralFault; + +/** + * Enables us to log custom Fault remote messages. + * + */ +public class CustomFaultMessageResolver implements FaultMessageResolver { + +private static final Logger LOGGER = LoggerFactory.getLogger(CustomFaultMessageResolver.class); + + private final FaultMessageResolver defaultMessageResolver = new SoapFaultMessageResolver(); + + private Unmarshaller unmarshaller; + + @Override + public void resolveFault(WebServiceMessage message) throws IOException { + + // Same behavior as default message resolver (SoapFaultMessageResolver) but this implementation also + // logs error information. + if (LOGGER.isErrorEnabled()) { + try { + logErrorInformation(message); + } catch (Exception ex) { + LOGGER.error("CustomFaultMessageResolver exception:", ex); + } + } + + defaultMessageResolver.resolveFault(message); + } + + private void logErrorInformation(WebServiceMessage message) throws XmlMappingException, IOException { + SoapMessage soapMessage = (SoapMessage) message; + SoapBody body = soapMessage.getSoapBody(); + SoapFault soapFault = body != null ? body.getFault() : null; + SoapFaultDetail detail = soapFault != null ? soapFault.getFaultDetail() : null; + + if (detail != null) { + Iterator iterator = detail.getDetailEntries(); + while (iterator.hasNext()) { + SoapFaultDetailElement bodyElement = iterator.next(); + Source detailSource = bodyElement.getSource(); + // TODO: How to check if I am receiving GeneralFault before trying to unmarshal? + // Right now there will be exception if unmarshal doesn't return a GeneralFault object. + GeneralFault error = (GeneralFault)this.unmarshaller.unmarshal(detailSource); + LOGGER.error("TECHNICALERROR:"); + LOGGER.error(error.getTechnicalError()); + LOGGER.error("ELEMENTS:"); + error.getElements().forEach(element -> { + LOGGER.error("MESSAGE: " + element.getMessage()); + LOGGER.error("MESSAGEARGS:"); + element.getMessageArgs().forEach(messageArg -> LOGGER.error(messageArg)); + }); + } + } + } + + public void setUnmarshaller(Unmarshaller unmarshaller) { + this.unmarshaller = unmarshaller; + } +} diff --git a/SOAP/jaxb2/web-services-spring-jaxb2-client/src/main/java/de/spring/webservices/client/ExampleClientService.java b/SOAP/jaxb2/web-services-spring-jaxb2-client/src/main/java/de/spring/webservices/client/ExampleClientService.java new file mode 100644 index 0000000..f8bad46 --- /dev/null +++ b/SOAP/jaxb2/web-services-spring-jaxb2-client/src/main/java/de/spring/webservices/client/ExampleClientService.java @@ -0,0 +1,75 @@ +package de.spring.webservices.client; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.ws.client.core.WebServiceTemplate; + +import de.spring.webservices.client.auto.CustomBindingExampleRequest; +import de.spring.webservices.client.auto.CustomBindingExampleResponse; +import de.spring.webservices.client.auto.ExampleRequest; +import de.spring.webservices.client.auto.ExampleResponse; +//import de.spring.webservices.client.auto.Examples; +//import de.spring.webservices.client.auto.ExamplesService; +//import de.spring.webservices.client.auto.ParentEnumType; + +/** + * Someone could write code like this one in order to send and receive + * information from our Web Services. + * + */ +@Service("exampleClientService") +public class ExampleClientService { + private final WebServiceTemplate webServiceTemplate; + + @Autowired + public ExampleClientService(WebServiceTemplate webServiceTemplate) { + this.webServiceTemplate = webServiceTemplate; + } + +// maven-jaxb2-plugin DOESN'T CREATE @WebService, @WebServiceClient y @WebEndpoint +// public ExampleResponse sendAndReceiveJava() { +// final ExampleRequest exampleRequest = new ExampleRequest(); +// exampleRequest.setData("SCARLETT JAVA. IT IS CANON."); +// +// final Examples exampleService = new ExamplesService().getExamplesSoap12(); +// final ExampleResponse exampleResponse = exampleService.example(exampleRequest); +// +// return exampleResponse; +// } + + public ExampleResponse sendAndReceiveSpring() { + final ExampleRequest exampleRequest = new ExampleRequest(); + exampleRequest.setData("SCARLETT SPRING. IT IS CANON."); + + final ExampleResponse exampleResponse = (ExampleResponse) + this.webServiceTemplate.marshalSendAndReceive(exampleRequest); + + return exampleResponse; + } + +// maven-jaxb2-plugin DOESN'T CREATE @WebService, @WebServiceClient y @WebEndpoint +// public CustomBindingExampleResponse sendAndReceiveJavaCustom() { +// final CustomBindingExampleRequest customBindingxampleRequest = +// new CustomBindingExampleRequest(); +// customBindingxampleRequest.setData("CUSTOM BINDING JAVA. SCARLETT. IT IS CANON."); +// customBindingxampleRequest.setParentEnum(ParentEnumType.FIRST); +// +// final Examples exampleService = new ExamplesService().getExamplesSoap12(); +// final CustomBindingExampleResponse customBindingExampleResponse = +// exampleService.customBindingExample(customBindingxampleRequest); +// +// return customBindingExampleResponse; +// } + + public CustomBindingExampleResponse sendAndReceiveSpringCustom() { + final CustomBindingExampleRequest customBindingxampleRequest = + new CustomBindingExampleRequest(); + customBindingxampleRequest.setData("CUSTOM BINDING SPRING. SCARLETT. IT IS CANON."); + + final CustomBindingExampleResponse customBindingExampleResponse = + (CustomBindingExampleResponse) this.webServiceTemplate + .marshalSendAndReceive(customBindingxampleRequest); + + return customBindingExampleResponse; + } +} diff --git a/SOAP/jaxb2/web-services-spring-jaxb2-client/src/main/java/de/spring/webservices/client/MainTest.java b/SOAP/jaxb2/web-services-spring-jaxb2-client/src/main/java/de/spring/webservices/client/MainTest.java new file mode 100644 index 0000000..92b1638 --- /dev/null +++ b/SOAP/jaxb2/web-services-spring-jaxb2-client/src/main/java/de/spring/webservices/client/MainTest.java @@ -0,0 +1,53 @@ +package de.spring.webservices.client; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.context.ApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +import de.spring.webservices.client.auto.CustomBindingExampleResponse; +import de.spring.webservices.client.auto.ExampleResponse; + +/** + * This class is used just like a nice example about how to write and run client + * code which will send data to and from the Web Services. + * + */ +public class MainTest { + private static final Logger LOGGER = LoggerFactory.getLogger(MainTest.class); + + public ApplicationContext context; + + /** + * @param args + */ + public static void main(final String[] args) { + final MainTest test = new MainTest(); + + test.context = new ClassPathXmlApplicationContext( + "classpath:spring-configuration/ws/client-spring-configuration.xml"); + + final ExampleClientService example = + (ExampleClientService) test.context.getBean("exampleClientService"); + +// maven-jaxb2-plugin DOESN'T CREATE @WebService, @WebServiceClient y @WebEndpoint +// logger.info("ExampleResponse Java:"); +// ExampleResponse response = example.sendAndReceiveJava(); +// logger.info(response.getData()); + + +// logger.info("CustomBindingExampleResponse Java:"); +// CustomBindingExampleResponse customBindingResponse = example.sendAndReceiveJavaCustom(); +// logger.info(customBindingResponse.getData()); + + + LOGGER.info("ExampleResponse Spring:"); + ExampleResponse response = example.sendAndReceiveSpring(); + LOGGER.info(response.getData()); + + + LOGGER.info("CustomBindingExampleResponse Spring:"); + CustomBindingExampleResponse customBindingResponse = example.sendAndReceiveSpringCustom(); + LOGGER.info(customBindingResponse.getData()); + } +} diff --git a/SOAP/jaxb2/web-services-spring-jaxb2-client/src/main/java/de/spring/webservices/client/transport/http/CustomHttpRequestMessageSender.java b/SOAP/jaxb2/web-services-spring-jaxb2-client/src/main/java/de/spring/webservices/client/transport/http/CustomHttpRequestMessageSender.java new file mode 100644 index 0000000..cf44220 --- /dev/null +++ b/SOAP/jaxb2/web-services-spring-jaxb2-client/src/main/java/de/spring/webservices/client/transport/http/CustomHttpRequestMessageSender.java @@ -0,0 +1,57 @@ +package de.spring.webservices.client.transport.http; + +import java.io.IOException; +import java.net.URI; + +import org.springframework.http.HttpMethod; +import org.springframework.http.client.ClientHttpRequest; +import org.springframework.http.client.ClientHttpRequestFactory; +import org.springframework.http.client.SimpleClientHttpRequestFactory; +import org.springframework.ws.transport.WebServiceConnection; +import org.springframework.ws.transport.http.AbstractHttpWebServiceMessageSender; +import org.springframework.ws.transport.http.ClientHttpRequestConnection; +import org.springframework.ws.transport.http.HttpTransportConstants; + + +/** + * Based on ClientHttpRequestMessageSender from the Spring WS framework. + * + *

+ * Spring WS framework also provides implementations based on the HTTP clients by Jakarta and Apache HttpClient: + * {@link https://hc.apache.org/httpcomponents-client-ga/} and {@link http://hc.apache.org/httpclient-3.x/} + *

+ * + *

+ * Four implementations for four HTTP clients: + *

    + *
  • org.springframework.ws.transport.http.ClientHttpRequestMessageSender (ClientHttpRequestFactory from the Spring framework)
  • + *
  • org.springframework.ws.transport.http.CommonsHttpMessageSender (Jakarta implementation)
  • + *
  • org.springframework.ws.transport.http.HttpComponentsMessageSender (Apache HttpClient)
  • + *
  • org.springframework.ws.transport.http.HttpUrlConnectionMessageSender + * (org.springframework.ws.transport.http.HttpUrlConnection internal Spring framework implementation)
  • + *
+ *

+ */ +public class CustomHttpRequestMessageSender extends AbstractHttpWebServiceMessageSender { + private static final String MY_CUSTOM_HEADER = "MY_CUSTOM_HEADER"; + + private final ClientHttpRequestFactory requestFactory; + + public CustomHttpRequestMessageSender() { + requestFactory = new SimpleClientHttpRequestFactory(); + } + + @Override + public WebServiceConnection createConnection(URI uri) throws IOException { + ClientHttpRequest request = requestFactory.createRequest(uri, HttpMethod.POST); + if (isAcceptGzipEncoding()) { + request.getHeaders().add(HttpTransportConstants.HEADER_ACCEPT_ENCODING, + HttpTransportConstants.CONTENT_ENCODING_GZIP); + } + + request.getHeaders().add(MY_CUSTOM_HEADER, "gumartinm.name"); + + return new ClientHttpRequestConnection(request); + } + +} diff --git a/SOAP/jaxb2/web-services-spring-jaxb2-client/src/main/resources/log4j2.xml b/SOAP/jaxb2/web-services-spring-jaxb2-client/src/main/resources/log4j2.xml new file mode 100644 index 0000000..5d47d57 --- /dev/null +++ b/SOAP/jaxb2/web-services-spring-jaxb2-client/src/main/resources/log4j2.xml @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SOAP/jaxb2/web-services-spring-jaxb2-client/src/main/resources/schemas/examples.xsd b/SOAP/jaxb2/web-services-spring-jaxb2-client/src/main/resources/schemas/examples.xsd new file mode 100644 index 0000000..59cd317 --- /dev/null +++ b/SOAP/jaxb2/web-services-spring-jaxb2-client/src/main/resources/schemas/examples.xsd @@ -0,0 +1,127 @@ + + + + + + + + + + + + + + + + @java.lang.SuppressWarnings({"unchecked","rawtypes"}) + de.spring.webservices.operations.Request + + + + + + + + + + + + de.spring.webservices.operations.Response + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SOAP/jaxb2/web-services-spring-jaxb2-client/src/main/resources/spring-configuration/ws/client-spring-configuration.xml b/SOAP/jaxb2/web-services-spring-jaxb2-client/src/main/resources/spring-configuration/ws/client-spring-configuration.xml new file mode 100644 index 0000000..9358079 --- /dev/null +++ b/SOAP/jaxb2/web-services-spring-jaxb2-client/src/main/resources/spring-configuration/ws/client-spring-configuration.xml @@ -0,0 +1,177 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + classpath:schemas/parent.xsd + + classpath:schemas/examples.xsd + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SOAP/jaxb2/web-services-spring-jaxb2-client/src/test/java/de/spring/webservices/client/ExampleClientServiceIntegrationTest.java b/SOAP/jaxb2/web-services-spring-jaxb2-client/src/test/java/de/spring/webservices/client/ExampleClientServiceIntegrationTest.java new file mode 100644 index 0000000..4877a5d --- /dev/null +++ b/SOAP/jaxb2/web-services-spring-jaxb2-client/src/test/java/de/spring/webservices/client/ExampleClientServiceIntegrationTest.java @@ -0,0 +1,78 @@ +package de.spring.webservices.client; + +import static org.junit.Assert.assertEquals; +import static org.springframework.ws.test.client.RequestMatchers.payload; +import static org.springframework.ws.test.client.ResponseCreators.withPayload; + +import javax.xml.transform.Source; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.ws.client.core.WebServiceTemplate; +import org.springframework.ws.test.client.MockWebServiceServer; +import org.springframework.xml.transform.StringSource; + +import de.spring.webservices.client.auto.CustomBindingExampleResponse; +import de.spring.webservices.client.auto.ExampleResponse; + + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration("classpath*:spring-configuration/ws/client-spring-configuration.xml") +public class ExampleClientServiceIntegrationTest { + + @Autowired + ExampleClientService exampleClientService; + + @Autowired + private WebServiceTemplate webServiceTemplate; + + private MockWebServiceServer mockServer; + + @Before + public void createServer() throws Exception { + mockServer = MockWebServiceServer.createServer(webServiceTemplate); + } + + @Test + public void customerClient() throws Exception { + final Source requestPayload = new StringSource( + "" + + "SCARLETT SPRING. IT IS CANON." + + ""); + final Source responsePayload = new StringSource( + "" + + "SNAKE EYES AND SCARLETT SPRING. IT IS CANON." + + ""); + mockServer.expect(payload(requestPayload)).andRespond( + withPayload(responsePayload)); + + final ExampleResponse response = exampleClientService.sendAndReceiveSpring(); + + assertEquals(response.getData(), "SNAKE EYES AND SCARLETT SPRING. IT IS CANON."); + mockServer.verify(); + } + + @Test + public void customerCustomClient() throws Exception { + final Source customRequestPayload = new StringSource( + "" + + "CUSTOM BINDING SPRING. SCARLETT. IT IS CANON." + + ""); + final Source customResponsePayload = new StringSource( + "" + + "CUSTOM BINDING SNAKE EYES AND SCARLETT SPRING. IT IS CANON." + + ""); + mockServer.expect(payload(customRequestPayload)).andRespond( + withPayload(customResponsePayload)); + + final CustomBindingExampleResponse response = exampleClientService.sendAndReceiveSpringCustom(); + + assertEquals(response.getData(), "CUSTOM BINDING SNAKE EYES AND SCARLETT SPRING. IT IS CANON."); + mockServer.verify(); + } +} + diff --git a/SOAP/jaxb2/web-services-spring-jaxb2-globalxsds/pom.xml b/SOAP/jaxb2/web-services-spring-jaxb2-globalxsds/pom.xml new file mode 100644 index 0000000..35278a9 --- /dev/null +++ b/SOAP/jaxb2/web-services-spring-jaxb2-globalxsds/pom.xml @@ -0,0 +1,102 @@ + + 4.0.0 + + web-services-spring-jaxb2 + de.spring.webservices + 1.0-SNAPSHOT + + web-services-spring-jaxb2-globalxsds + web-services-spring-jaxb2-globalxsds + http://gumartinm.name + + + src/main/resources/schemas + ${project.build.directory}/generated-sources/src/main/java + de.spring.webservices.parent.auto + src/main/build-resources/bindings + + + + + + + junit + junit + test + + + + + ${project.artifactId} + + + ${basedir}/src/main/resources + + **/*.* + + + + + + org.jvnet.jaxb2.maven2 + maven-jaxb2-plugin + 0.13.1 + + + generate-sources-from-xsd + + generate + + generate-sources + + + + + ${project.xsd.schemas.source.path} + + + ${project.bindings.path} + + false + + + ${project.xsd.schemas.target.path} + + + ${project.xsd.schemas.package.name} + + + true + + true + + + ${project.build.sourceEncoding} + + + en + + + true + false + + + true + + true + + + + + diff --git a/SOAP/jaxb2/web-services-spring-jaxb2-globalxsds/src/main/build-resources/bindings/custombinding.xjb b/SOAP/jaxb2/web-services-spring-jaxb2-globalxsds/src/main/build-resources/bindings/custombinding.xjb new file mode 100644 index 0000000..8b4a110 --- /dev/null +++ b/SOAP/jaxb2/web-services-spring-jaxb2-globalxsds/src/main/build-resources/bindings/custombinding.xjb @@ -0,0 +1,8 @@ + + + + + diff --git a/SOAP/jaxb2/web-services-spring-jaxb2-globalxsds/src/main/java/de/spring/webservices/binders/XSDateTimeCustomBinder.java b/SOAP/jaxb2/web-services-spring-jaxb2-globalxsds/src/main/java/de/spring/webservices/binders/XSDateTimeCustomBinder.java new file mode 100644 index 0000000..f39921a --- /dev/null +++ b/SOAP/jaxb2/web-services-spring-jaxb2-globalxsds/src/main/java/de/spring/webservices/binders/XSDateTimeCustomBinder.java @@ -0,0 +1,35 @@ +package de.spring.webservices.binders; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.TimeZone; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + + +/** + * ATTENTION: if you are using this custombinder you will have to create custom payload + * validators for Spring (AS FAR AS I KNOW) + * + */ +public class XSDateTimeCustomBinder extends XmlAdapter { + + @Override + public Date unmarshal(final String dateTime) throws Exception { + // X pattern just works from Java >= 1.7 + final DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssX"); + formatter.setTimeZone(TimeZone.getTimeZone("Europe/Madrid")); + + return formatter.parse(dateTime); + } + + @Override + public String marshal(final Date dateTime) throws Exception { + // X pattern just works from Java >= 1.7 + final DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssX"); + formatter.setTimeZone(TimeZone.getTimeZone("Europe/Madrid")); + + return formatter.format(dateTime); + } +} diff --git a/SOAP/jaxb2/web-services-spring-jaxb2-globalxsds/src/main/java/de/spring/webservices/operations/Operations.java b/SOAP/jaxb2/web-services-spring-jaxb2-globalxsds/src/main/java/de/spring/webservices/operations/Operations.java new file mode 100644 index 0000000..13b5113 --- /dev/null +++ b/SOAP/jaxb2/web-services-spring-jaxb2-globalxsds/src/main/java/de/spring/webservices/operations/Operations.java @@ -0,0 +1,111 @@ +package de.spring.webservices.operations; + +/** + *

+ * Operations: WSDL v1.1 and v2.0 + *

+ * See: http://www.w3.org/TR/wsdl#_porttypes
+ * See: + * http://www.w3.org/TR/2007/REC-wsdl20-adjuncts-20070626/#patterns + * + */ +public interface Operations { + + /** + *

+ * Request-response operation WSDL v1.1 + *

+ * See: http://www.w3.org + * /TR/wsdl#_request-response + * + * @param + * Describes {@link Response} + * @param + * Describes {@link Request} + */ + public static interface RequestResponse { + T requestResponse(E request); + } + + /** + *

+ * One-way operation WSDL v1.1 + *

+ * See: http://www.w3.org/TR/wsdl + * #_one-way + * + * @param + * Describes {@link Response} + * @param + * Describes {@link Request} + */ + public interface OneWay { + void oneWay(E request); + } + + /** + *

+ * Notification operation WSDL v1.1 + *

+ * See: http://www.w3.org/TR + * /wsdl#_notification + * + * @param + * Describes {@link Response} + * @param + * Describes {@link Request} + */ + public interface Notification { + T notification(); + } + + /** + *

+ * In-Only message exchange pattern WSDL 2.0 + *

+ * See: + * http://www.w3.org/TR/2007/REC-wsdl20-adjuncts-20070626/#patterns + * + * @param + * Describes {@link Request} + */ + public interface InOnly { + void inOnly(E request); + } + + /** + *

+ * Robust In-Only message exchange pattern WSDL 2.0 + *

+ * See: + * http://www.w3.org/TR/2007/REC-wsdl20-adjuncts-20070626/#patterns + * + * @param + * Describes {@link Request} + */ + public interface RobustInOnly { + void robustInOnly(E request); + } + + /** + *

+ * In-Out message exchange pattern WSDL 2.0 + *

+ * See: + * http://www.w3.org/TR/2007/REC-wsdl20-adjuncts-20070626/#patterns + * + * @param + * Describes {@link Response} + * @param + * Describes {@link Request} + */ + public interface InOut { + T inOut(E request); + } +} \ No newline at end of file diff --git a/SOAP/jaxb2/web-services-spring-jaxb2-globalxsds/src/main/java/de/spring/webservices/operations/Request.java b/SOAP/jaxb2/web-services-spring-jaxb2-globalxsds/src/main/java/de/spring/webservices/operations/Request.java new file mode 100644 index 0000000..77d81f4 --- /dev/null +++ b/SOAP/jaxb2/web-services-spring-jaxb2-globalxsds/src/main/java/de/spring/webservices/operations/Request.java @@ -0,0 +1,5 @@ +package de.spring.webservices.operations; + +public interface Request { + +} diff --git a/SOAP/jaxb2/web-services-spring-jaxb2-globalxsds/src/main/java/de/spring/webservices/operations/Response.java b/SOAP/jaxb2/web-services-spring-jaxb2-globalxsds/src/main/java/de/spring/webservices/operations/Response.java new file mode 100644 index 0000000..3a2cbea --- /dev/null +++ b/SOAP/jaxb2/web-services-spring-jaxb2-globalxsds/src/main/java/de/spring/webservices/operations/Response.java @@ -0,0 +1,5 @@ +package de.spring.webservices.operations; + +public interface Response { + +} diff --git a/SOAP/jaxb2/web-services-spring-jaxb2-globalxsds/src/main/resources/schemas/parent.xsd b/SOAP/jaxb2/web-services-spring-jaxb2-globalxsds/src/main/resources/schemas/parent.xsd new file mode 100644 index 0000000..b38ca36 --- /dev/null +++ b/SOAP/jaxb2/web-services-spring-jaxb2-globalxsds/src/main/resources/schemas/parent.xsd @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SOAP/jaxb2/web-services-spring-jaxb2-server/pom.xml b/SOAP/jaxb2/web-services-spring-jaxb2-server/pom.xml new file mode 100644 index 0000000..a969b08 --- /dev/null +++ b/SOAP/jaxb2/web-services-spring-jaxb2-server/pom.xml @@ -0,0 +1,240 @@ + + 4.0.0 + + web-services-spring-jaxb2 + de.spring.webservices + 1.0-SNAPSHOT + + web-services-spring-jaxb2-server + war + web-services-spring-jaxb2-server + http://gumartinm.name + + + 9.3.0.RC0 + src/main/resources/schemas + ${project.build.directory}/generated-sources/src/main/java + de.spring.webservices.server.auto + src/main/build-resources/bindings + + + + + org.springframework.ws + spring-ws-core + + + org.springframework.ws + spring-xml + + + org.jdom + jdom + + + + + + de.spring.webservices + web-services-spring-jaxb2-globalxsds + ${project.version} + + + + + + wsdl4j + wsdl4j + + + + + javax.servlet + javax.servlet-api + 4.0.0-b01 + provided + + + + + junit + junit + test + + + org.springframework + spring-test + test + + + org.springframework.ws + spring-ws-test + test + + + org.mockito + mockito-core + test + + + + + ${project.artifactId} + + + ${basedir}/src/main/webapp + + **/*.* + + + + ${basedir}/src/main/resources/ + + **/*.* + + + + + + org.jvnet.jaxb2.maven2 + maven-jaxb2-plugin + 0.13.1 + + + generate-sources-from-xsd + + generate + + generate-sources + + + + XMLSCHEMA + + + ${project.xsd.schemas.source.path} + + + ${project.bindings.path} + + false + + + ${project.xsd.schemas.target.path} + + + ${project.xsd.schemas.package.name} + + + true + + true + + + ${project.build.sourceEncoding} + + + en + + + true + false + + + false + + true + + true + + -Xinheritance + -Xannotate + + + + org.jvnet.jaxb2_commons + jaxb2-basics + 0.9.5 + + + org.jvnet.jaxb2_commons + jaxb2-basics-annotate + 1.0.2 + + + + + true + + + + + false + src/main/build-resources/catalogs/catalog.cat + + + de.spring.webservices + web-services-spring-jaxb2-globalxsds + + + + + + org.apache.maven.plugins + maven-war-plugin + 2.6 + + + + true + src/main/webapp + + WEB-INF/web.xml + + + + + + + org.eclipse.jetty + jetty-maven-plugin + ${jetty.version} + + ${basedir}/src/main/jetty/jetty-http.xml + + + + + diff --git a/SOAP/jaxb2/web-services-spring-jaxb2-server/src/main/build-resources/bindings/custombinding.xjb b/SOAP/jaxb2/web-services-spring-jaxb2-server/src/main/build-resources/bindings/custombinding.xjb new file mode 100644 index 0000000..a7164c0 --- /dev/null +++ b/SOAP/jaxb2/web-services-spring-jaxb2-server/src/main/build-resources/bindings/custombinding.xjb @@ -0,0 +1,51 @@ + + + + + + + + + de.spring.webservices.operations.Request + @java.lang.SuppressWarnings({"unchecked","rawtypes"}) + + + + + + + de.spring.webservices.operations.Response + @java.lang.SuppressWarnings({"unchecked","rawtypes"}) + + + + + + + + + + + diff --git a/SOAP/jaxb2/web-services-spring-jaxb2-server/src/main/build-resources/catalogs/catalog.cat b/SOAP/jaxb2/web-services-spring-jaxb2-server/src/main/build-resources/catalogs/catalog.cat new file mode 100644 index 0000000..113acd0 --- /dev/null +++ b/SOAP/jaxb2/web-services-spring-jaxb2-server/src/main/build-resources/catalogs/catalog.cat @@ -0,0 +1,12 @@ + + +REWRITE_SYSTEM "http://gumartinm.name/spring-ws/parent/parent.xsd" "maven:de.spring.webservices:web-services-spring-jaxb2-globalxsds:jar::!/schemas/parent.xsd" + +-- + This configuration is better (it relies on namespace instead of schemaLocation) but it doesn't work + because of this bug: https://java.net/jira/browse/JAXB-942 + + PUBLIC "xmlns:parent" "maven:de.spring.webservices:web-services-spring-jaxb2-globalxsds:jar::!/schemas/parent.xsd" + +-- + diff --git a/SOAP/jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/endpoints/CustomHeaderInterceptor.java b/SOAP/jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/endpoints/CustomHeaderInterceptor.java new file mode 100644 index 0000000..e1d5302 --- /dev/null +++ b/SOAP/jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/endpoints/CustomHeaderInterceptor.java @@ -0,0 +1,50 @@ +package de.spring.webservices.endpoints; + +import javax.servlet.http.HttpServletRequest; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.util.StringUtils; +import org.springframework.ws.context.MessageContext; +import org.springframework.ws.server.EndpointInterceptor; +import org.springframework.ws.transport.context.TransportContext; +import org.springframework.ws.transport.context.TransportContextHolder; +import org.springframework.ws.transport.http.HttpServletConnection; + +public class CustomHeaderInterceptor implements EndpointInterceptor { + private static final Logger LOGGER = LoggerFactory.getLogger(CustomHeaderInterceptor.class); + private static final String MY_CUSTOM_HEADER = "MY_CUSTOM_HEADER"; + + @Override + public boolean handleRequest(MessageContext messageContext, Object endpoint) throws Exception { + TransportContext transport = TransportContextHolder.getTransportContext(); + + if (transport != null) { + HttpServletConnection connection = (HttpServletConnection) transport.getConnection(); + HttpServletRequest headers = connection.getHttpServletRequest(); + String headerValue = headers.getHeader(MY_CUSTOM_HEADER); + + if (!StringUtils.isEmpty(headerValue)) { + LOGGER.info("Custom header value: " + headerValue); + } + } + + return true; + } + + @Override + public boolean handleResponse(MessageContext messageContext, Object endpoint) throws Exception { + return true; + } + + @Override + public boolean handleFault(MessageContext messageContext, Object endpoint) throws Exception { + return true; + } + + @Override + public void afterCompletion(MessageContext messageContext, Object endpoint, Exception ex) throws Exception { + + } + +} diff --git a/SOAP/jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/endpoints/ExampleEndPoint.java b/SOAP/jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/endpoints/ExampleEndPoint.java new file mode 100644 index 0000000..e3e8da6 --- /dev/null +++ b/SOAP/jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/endpoints/ExampleEndPoint.java @@ -0,0 +1,57 @@ +package de.spring.webservices.endpoints; + +import org.jdom2.Element; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.ws.context.MessageContext; +import org.springframework.ws.server.endpoint.annotation.Endpoint; +import org.springframework.ws.server.endpoint.annotation.PayloadRoot; +import org.springframework.ws.server.endpoint.annotation.RequestPayload; +import org.springframework.ws.server.endpoint.annotation.ResponsePayload; + +import de.spring.webservices.operations.Operations; +import de.spring.webservices.operations.Operations.RequestResponse; +import de.spring.webservices.server.auto.CustomBindingExampleRequest; +import de.spring.webservices.server.auto.CustomBindingExampleResponse; +import de.spring.webservices.server.auto.ExampleRequest; +import de.spring.webservices.server.auto.ExampleResponse; +import de.spring.webservices.services.ExampleService; + + +@Endpoint +public class ExampleEndPoint { + private static final String NAMESPACE_URI = "http://gumartinm.name/spring-ws/example"; + + private final Operations.RequestResponse + customBindingExampleService; + + private final ExampleService exampleService; + + @Autowired + public ExampleEndPoint( + RequestResponse customBindingExampleService, + ExampleService exampleService) { + this.customBindingExampleService = customBindingExampleService; + this.exampleService = exampleService; + } + + @PayloadRoot(localPart = "ExampleRequest", namespace = NAMESPACE_URI) + @ResponsePayload + public ExampleResponse exampleResponse( + @RequestPayload final ExampleRequest request, + @RequestPayload final Element element, + final MessageContext messageContext) { + + return this.exampleService.doResponse(request); + } + + @PayloadRoot(localPart = "CustomBindingExampleRequest", namespace = NAMESPACE_URI) + @ResponsePayload + public CustomBindingExampleResponse cuntomBindingExampleResponse( + @RequestPayload final CustomBindingExampleRequest requestObject, + @RequestPayload final Element element, + final MessageContext messageContext) { + + return this.customBindingExampleService.requestResponse(requestObject); + } +} + diff --git a/SOAP/jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/endpoints/MyCustomMappingExceptionResolver.java b/SOAP/jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/endpoints/MyCustomMappingExceptionResolver.java new file mode 100644 index 0000000..382cd74 --- /dev/null +++ b/SOAP/jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/endpoints/MyCustomMappingExceptionResolver.java @@ -0,0 +1,140 @@ +package de.spring.webservices.endpoints; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; + +import javax.xml.transform.Result; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.oxm.Marshaller; +import org.springframework.util.CollectionUtils; +import org.springframework.ws.soap.SoapFault; +import org.springframework.ws.soap.SoapFaultDetail; +import org.springframework.ws.soap.server.endpoint.AbstractSoapFaultDefinitionExceptionResolver; +import org.springframework.ws.soap.server.endpoint.SoapFaultDefinition; +import org.springframework.ws.soap.server.endpoint.SoapFaultDefinitionEditor; + +import de.spring.webservices.exceptions.CustomBusinessException; +import de.spring.webservices.parent.auto.Element; +import de.spring.webservices.parent.auto.GeneralFault; + +public class MyCustomMappingExceptionResolver extends AbstractSoapFaultDefinitionExceptionResolver { + private static final Logger LOGGER = LoggerFactory.getLogger(MyCustomMappingExceptionResolver.class); + + private Marshaller marshaller; + + private Map exceptionMappings = new LinkedHashMap<>(); + + /** + * Set the mappings between exception class names and SOAP Faults. The exception class name can be a substring, with + * no wildcard support at present. + * + *

The values of the given properties object should use the format described in + * {@code SoapFaultDefinitionEditor}. + * + *

Follows the same matching algorithm as {@code SimpleMappingExceptionResolver}. + * + * @param mappings exception patterns (can also be fully qualified class names) as keys, fault definition texts as + * values + * @see SoapFaultDefinitionEditor + */ + public void setExceptionMappings(Properties mappings) { + for (Map.Entry entry : mappings.entrySet()) { + if (entry.getKey() instanceof String && entry.getValue() instanceof String) { + exceptionMappings.put((String)entry.getKey(), (String)entry.getValue()); + } + } + } + + @Override + protected SoapFaultDefinition getFaultDefinition(Object endpoint, Exception ex) { + if (!CollectionUtils.isEmpty(exceptionMappings)) { + String definitionText = null; + int deepest = Integer.MAX_VALUE; + for (String exceptionMapping : exceptionMappings.keySet()) { + int depth = getDepth(exceptionMapping, ex); + if (depth >= 0 && depth < deepest) { + deepest = depth; + definitionText = exceptionMappings.get(exceptionMapping); + } + } + if (definitionText != null) { + SoapFaultDefinitionEditor editor = new SoapFaultDefinitionEditor(); + editor.setAsText(definitionText); + return (SoapFaultDefinition) editor.getValue(); + } + } + return null; + } + + /** + * Return the depth to the superclass matching. {@code 0} means ex matches exactly. Returns {@code -1} if + * there's no match. Otherwise, returns depth. Lowest depth wins. + * + *

Follows the same algorithm as RollbackRuleAttribute, and SimpleMappingExceptionResolver + */ + protected int getDepth(String exceptionMapping, Exception ex) { + return getDepth(exceptionMapping, ex.getClass(), 0); + } + + @SuppressWarnings("unchecked") + private int getDepth(String exceptionMapping, Class exceptionClass, int depth) { + if (exceptionClass.getName().indexOf(exceptionMapping) != -1) { + return depth; + } + if (exceptionClass.equals(Throwable.class)) { + return -1; + } + return getDepth(exceptionMapping, (Class) exceptionClass.getSuperclass(), depth + 1); + } + + protected void customizeFault(Object endpoint, Exception ex, SoapFault fault) { + GeneralFault customFault = new GeneralFault(); + customFault.setTechnicalError(getStackTrace(ex)); + + Element element = buildElement(ex); + List elements = customFault.getElements(); + elements.add(element); + + SoapFaultDetail detail = fault.addFaultDetail(); + Result result = detail.getResult(); + try { + marshaller.marshal(customFault, result); + } catch (Exception marshallEx) { + LOGGER.error("MyCustomMappingExceptionResolver: marshaller error", marshallEx); + } + } + + public void setMarshaller(Marshaller marshaller) { + this.marshaller = marshaller; + } + + private Element buildElement(Exception ex) { + Element element = new Element(); + element.setMessage(ex.getMessage()); + + if (ex instanceof CustomBusinessException) { + CustomBusinessException customEx = (CustomBusinessException) ex; + List messageArgs = element.getMessageArgs(); + List argumentsEx = customEx.getArguments(); + + for (String argumentEx: argumentsEx) { + messageArgs.add(argumentEx); + } + } + + return element; + } + + private String getStackTrace(Throwable throwable) { + final StringWriter sw = new StringWriter(); + final PrintWriter pw = new PrintWriter(sw, true); + throwable.printStackTrace(pw); + return sw.getBuffer().toString(); + } +} diff --git a/SOAP/jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/exceptions/BusinessException.java b/SOAP/jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/exceptions/BusinessException.java new file mode 100644 index 0000000..f13ae91 --- /dev/null +++ b/SOAP/jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/exceptions/BusinessException.java @@ -0,0 +1,22 @@ +package de.spring.webservices.exceptions; + +/** + * This exception will be caught by org.springframework.ws.soap.server.endpoint.SoapFaultMappingExceptionResolver + * + */ +public class BusinessException extends RuntimeException { + + private static final long serialVersionUID = -4042139454770293299L; + + public BusinessException() { + super(); + } + + public BusinessException(String message) { + super(message); + } + + public BusinessException(String message, Throwable cause) { + super(message, cause); + } +} diff --git a/SOAP/jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/exceptions/CustomBusinessException.java b/SOAP/jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/exceptions/CustomBusinessException.java new file mode 100644 index 0000000..549c0b9 --- /dev/null +++ b/SOAP/jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/exceptions/CustomBusinessException.java @@ -0,0 +1,32 @@ +package de.spring.webservices.exceptions; + +import java.util.List; + +/** + * This exception will be caught by de.spring.webservices.endpoints.MyCustomMappingExceptionResolver + * + */ +public class CustomBusinessException extends RuntimeException { + private final List arguments; + + public CustomBusinessException(List arguments) { + super(); + this.arguments = arguments; + } + + public CustomBusinessException(String message, List arguments) { + super(message); + + this.arguments = arguments; + } + + public CustomBusinessException(String message, Throwable cause, List arguments) { + super(message, cause); + + this.arguments = arguments; + } + + public List getArguments() { + return arguments; + } +} diff --git a/SOAP/jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/services/ExampleService.java b/SOAP/jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/services/ExampleService.java new file mode 100644 index 0000000..881be73 --- /dev/null +++ b/SOAP/jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/services/ExampleService.java @@ -0,0 +1,11 @@ +package de.spring.webservices.services; + +import de.spring.webservices.server.auto.ExampleRequest; +import de.spring.webservices.server.auto.ExampleResponse; + + +public interface ExampleService { + + public ExampleResponse doResponse(ExampleRequest request); + +} diff --git a/SOAP/jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/services/impl/CustomBindingExampleServiceImpl.java b/SOAP/jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/services/impl/CustomBindingExampleServiceImpl.java new file mode 100644 index 0000000..88424b2 --- /dev/null +++ b/SOAP/jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/services/impl/CustomBindingExampleServiceImpl.java @@ -0,0 +1,44 @@ +package de.spring.webservices.services.impl; + +//import java.util.ArrayList; +//import java.util.List; + +import org.springframework.stereotype.Service; + +import de.spring.webservices.operations.Operations; +import de.spring.webservices.parent.auto.ParentEnumType; +import de.spring.webservices.server.auto.CustomBindingExampleRequest; +import de.spring.webservices.server.auto.CustomBindingExampleResponse; +//import de.spring.webservices.exceptions.BusinessException; +//import de.spring.webservices.exceptions.CustomBusinessException; + + +@Service("customBindingExampleService") +public class CustomBindingExampleServiceImpl implements + Operations.RequestResponse { + + + @Override + public CustomBindingExampleResponse requestResponse(final CustomBindingExampleRequest request) { + + + // Example about how works org.springframework.ws.soap.server.endpoint.SoapFaultMappingExceptionResolver + // see soap-ws.xml Spring configuration file. +// throw new BusinessException("This feature has not been implemented yet."); + + // Example about how works de.spring.webservices.endpoints.MyCustomMappingExceptionResolver + // see soap-ws.xml Spring configuration file. +// List arguments = new ArrayList<>(); +// arguments.add("ARGUMENT 1"); +// arguments.add("ARGUMENT 2"); +// throw new CustomBusinessException("This feature has not been implemented yet.", arguments); + + CustomBindingExampleResponse response = new CustomBindingExampleResponse(); + + response.setData("CUSTOM BINDING SNAKE EYES AND " + request.getData()); + response.setParentEnum(ParentEnumType.FIRST); + + return response; + } + +} diff --git a/SOAP/jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/services/impl/ExampleServiceImpl.java b/SOAP/jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/services/impl/ExampleServiceImpl.java new file mode 100644 index 0000000..ec80b60 --- /dev/null +++ b/SOAP/jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/services/impl/ExampleServiceImpl.java @@ -0,0 +1,23 @@ +package de.spring.webservices.services.impl; + +import org.springframework.stereotype.Service; + +import de.spring.webservices.server.auto.ExampleRequest; +import de.spring.webservices.server.auto.ExampleResponse; +import de.spring.webservices.services.ExampleService; + + +@Service("exampleService") +public class ExampleServiceImpl implements ExampleService { + + @Override + public ExampleResponse doResponse(final ExampleRequest request) { + + ExampleResponse response = new ExampleResponse(); + + response.setData("SNAKE EYES AND " + request.getData()); + + return response; + } + +} diff --git a/SOAP/jaxb2/web-services-spring-jaxb2-server/src/main/jetty/jetty-http.xml b/SOAP/jaxb2/web-services-spring-jaxb2-server/src/main/jetty/jetty-http.xml new file mode 100644 index 0000000..d995630 --- /dev/null +++ b/SOAP/jaxb2/web-services-spring-jaxb2-server/src/main/jetty/jetty-http.xml @@ -0,0 +1,71 @@ + + + + + + + + + + + + https + + + + 32768 + 8192 + 8192 + true + false + 512 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SOAP/jaxb2/web-services-spring-jaxb2-server/src/main/resources/log4j2.xml b/SOAP/jaxb2/web-services-spring-jaxb2-server/src/main/resources/log4j2.xml new file mode 100644 index 0000000..ea6ded3 --- /dev/null +++ b/SOAP/jaxb2/web-services-spring-jaxb2-server/src/main/resources/log4j2.xml @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SOAP/jaxb2/web-services-spring-jaxb2-server/src/main/resources/schemas/examples.xsd b/SOAP/jaxb2/web-services-spring-jaxb2-server/src/main/resources/schemas/examples.xsd new file mode 100644 index 0000000..59cd317 --- /dev/null +++ b/SOAP/jaxb2/web-services-spring-jaxb2-server/src/main/resources/schemas/examples.xsd @@ -0,0 +1,127 @@ + + + + + + + + + + + + + + + + @java.lang.SuppressWarnings({"unchecked","rawtypes"}) + de.spring.webservices.operations.Request + + + + + + + + + + + + de.spring.webservices.operations.Response + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SOAP/jaxb2/web-services-spring-jaxb2-server/src/main/resources/spring-configuration/spring-configuration.xml b/SOAP/jaxb2/web-services-spring-jaxb2-server/src/main/resources/spring-configuration/spring-configuration.xml new file mode 100644 index 0000000..7341c77 --- /dev/null +++ b/SOAP/jaxb2/web-services-spring-jaxb2-server/src/main/resources/spring-configuration/spring-configuration.xml @@ -0,0 +1,14 @@ + + + + diff --git a/SOAP/jaxb2/web-services-spring-jaxb2-server/src/main/resources/spring-configuration/ws/soap-ws.xml b/SOAP/jaxb2/web-services-spring-jaxb2-server/src/main/resources/spring-configuration/ws/soap-ws.xml new file mode 100644 index 0000000..40f2901 --- /dev/null +++ b/SOAP/jaxb2/web-services-spring-jaxb2-server/src/main/resources/spring-configuration/ws/soap-ws.xml @@ -0,0 +1,284 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + classpath:schemas/parent.xsd + + classpath:schemas/examples.xsd + + + + + + + + + + + + + + + + + + SERVER + + + + + + + + + + + + + + + SERVER + + + + + + + + diff --git a/SOAP/jaxb2/web-services-spring-jaxb2-server/src/main/webapp/WEB-INF/web.xml b/SOAP/jaxb2/web-services-spring-jaxb2-server/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..7e14eba --- /dev/null +++ b/SOAP/jaxb2/web-services-spring-jaxb2-server/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,44 @@ + + + + Spring Web Services: example + + + + org.springframework.web.context.ContextLoaderListener + + + + + spring.profiles.active + ${environment.profile} + contextConfigLocation + + classpath*:spring-configuration/*.xml + + + + + + spring-ws + org.springframework.ws.transport.http.MessageDispatcherServlet + 1 + true + + contextConfigLocation + classpath*:spring-configuration/ws/*.xml + + + transformWsdlLocations + true + + + + + spring-ws + /spring-ws/* + + + diff --git a/SOAP/jaxb2/web-services-spring-jaxb2-server/src/test/java/de/spring/webservices/endpoints/ExampleEndPointIntegrationTest.java b/SOAP/jaxb2/web-services-spring-jaxb2-server/src/test/java/de/spring/webservices/endpoints/ExampleEndPointIntegrationTest.java new file mode 100644 index 0000000..f0204cb --- /dev/null +++ b/SOAP/jaxb2/web-services-spring-jaxb2-server/src/test/java/de/spring/webservices/endpoints/ExampleEndPointIntegrationTest.java @@ -0,0 +1,62 @@ +package de.spring.webservices.endpoints; + +import static org.springframework.ws.test.server.RequestCreators.withPayload; +import static org.springframework.ws.test.server.ResponseMatchers.payload; + +import javax.xml.transform.Source; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.ws.test.server.MockWebServiceClient; +import org.springframework.xml.transform.StringSource; + + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(locations = { "classpath*:spring-configuration/ws/soap-ws.xml" } ) +public class ExampleEndPointIntegrationTest { + + @Autowired + private ApplicationContext applicationContext; + + private MockWebServiceClient mockClient; + + @Before + public void createClient() { + mockClient = MockWebServiceClient.createClient(applicationContext); + } + + @Test + public void exampleEndpoint() throws Exception { + final Source requestPayload = new StringSource( + "" + + "SCARLETT" + + ""); + final Source responsePayload = new StringSource( + "" + + "SNAKE EYES AND SCARLETT" + + ""); + mockClient.sendRequest(withPayload(requestPayload)).andExpect( + payload(responsePayload)); + + + final Source customRequestPayload = new StringSource( + "" + + "SCARLETT" + + "2015-06-03T10:20:30Z" + + "FIRST" + + ""); + final Source customResponsePayload = new StringSource( + "" + + "CUSTOM BINDING SNAKE EYES AND SCARLETT" + + "FIRST" + + ""); + mockClient.sendRequest(withPayload(customRequestPayload)).andExpect( + payload(customResponsePayload)); + } +} + diff --git a/SOAP/jaxb2/web-services-spring-jaxb2-server/src/test/java/de/spring/webservices/endpoints/ExampleEndPointTest.java b/SOAP/jaxb2/web-services-spring-jaxb2-server/src/test/java/de/spring/webservices/endpoints/ExampleEndPointTest.java new file mode 100644 index 0000000..a4a279f --- /dev/null +++ b/SOAP/jaxb2/web-services-spring-jaxb2-server/src/test/java/de/spring/webservices/endpoints/ExampleEndPointTest.java @@ -0,0 +1,52 @@ +package de.spring.webservices.endpoints; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; + +import org.junit.Before; +import org.junit.Test; + +import de.spring.webservices.operations.Operations; +import de.spring.webservices.server.auto.CustomBindingExampleRequest; +import de.spring.webservices.server.auto.CustomBindingExampleResponse; +import de.spring.webservices.server.auto.ExampleRequest; +import de.spring.webservices.services.ExampleService; + + +public class ExampleEndPointTest { + + private ExampleService exampleService; + + private Operations.RequestResponse + customBindingExampleService; + + private ExampleEndPoint exampleEndPoint; + + @Before + public void init() { + exampleService = mock(ExampleService.class); + customBindingExampleService = mock(Operations.RequestResponse.class); + exampleEndPoint = new ExampleEndPoint(customBindingExampleService, exampleService); + } + + @Test + public void givenExampleRequestThenInvokeExampleService() { + ExampleRequest request = new ExampleRequest(); + request.setData("SCARLETT"); + + exampleEndPoint.exampleResponse(request, null, null); + + verify(exampleService).doResponse(request); + } + + @Test + public void givenCustomBindingExampleRequestThenInvokeCustomBindingExampleService() { + CustomBindingExampleRequest request = new CustomBindingExampleRequest(); + request.setData("SCARLETT"); + + exampleEndPoint.cuntomBindingExampleResponse(request, null, null); + + verify(customBindingExampleService).requestResponse(request); + } + +} diff --git a/SOAP/jaxb2/web-services-spring-jaxb2-server/src/test/java/de/spring/webservices/services/CustomBindingExampleServiceTest.java b/SOAP/jaxb2/web-services-spring-jaxb2-server/src/test/java/de/spring/webservices/services/CustomBindingExampleServiceTest.java new file mode 100644 index 0000000..d3b56be --- /dev/null +++ b/SOAP/jaxb2/web-services-spring-jaxb2-server/src/test/java/de/spring/webservices/services/CustomBindingExampleServiceTest.java @@ -0,0 +1,34 @@ +package de.spring.webservices.services; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import de.spring.webservices.operations.Operations; +import de.spring.webservices.server.auto.CustomBindingExampleRequest; +import de.spring.webservices.server.auto.CustomBindingExampleResponse; +import de.spring.webservices.services.impl.CustomBindingExampleServiceImpl; + + +public class CustomBindingExampleServiceTest { + + private Operations.RequestResponse + customBindingExampleService; + + @Before + public void init() { + customBindingExampleService = new CustomBindingExampleServiceImpl(); + } + + @Test + public void givenCustomBindingExampleRequestThenReturnCustomBindingExampleResponse() { + CustomBindingExampleRequest request = new CustomBindingExampleRequest(); + request.setData("SCARLETT"); + CustomBindingExampleResponse expected = new CustomBindingExampleResponse(); + expected.setData("CUSTOM BINDING SNAKE EYES AND " + request.getData()); + + CustomBindingExampleResponse actual = customBindingExampleService.requestResponse(request); + + Assert.assertEquals(expected.getData(), actual.getData()); + } +} diff --git a/SOAP/jaxb2/web-services-spring-jaxb2-server/src/test/java/de/spring/webservices/services/ExampleServiceTest.java b/SOAP/jaxb2/web-services-spring-jaxb2-server/src/test/java/de/spring/webservices/services/ExampleServiceTest.java new file mode 100644 index 0000000..9f33c5e --- /dev/null +++ b/SOAP/jaxb2/web-services-spring-jaxb2-server/src/test/java/de/spring/webservices/services/ExampleServiceTest.java @@ -0,0 +1,32 @@ +package de.spring.webservices.services; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import de.spring.webservices.server.auto.ExampleRequest; +import de.spring.webservices.server.auto.ExampleResponse; +import de.spring.webservices.services.impl.ExampleServiceImpl; + +public class ExampleServiceTest { + + private ExampleService exampleService; + + @Before + public void init() { + exampleService = new ExampleServiceImpl(); + } + + @Test + public void givenExampleRequestThenReturnExampleResponse() { + ExampleRequest request = new ExampleRequest(); + request.setData("SCARLETT"); + ExampleResponse expected = new ExampleResponse(); + expected.setData("SNAKE EYES AND " + request.getData()); + + ExampleResponse actual = exampleService.doResponse(request); + + Assert.assertEquals(expected.getData(), actual.getData()); + } + +} diff --git a/SOAP/jaxb2/web-services-spring-jaxb2/pom.xml b/SOAP/jaxb2/web-services-spring-jaxb2/pom.xml new file mode 100644 index 0000000..4badaa6 --- /dev/null +++ b/SOAP/jaxb2/web-services-spring-jaxb2/pom.xml @@ -0,0 +1,240 @@ + + 4.0.0 + de.spring.webservices + web-services-spring-jaxb2 + pom + 1.0-SNAPSHOT + web-services-spring-jaxb2 + http://gumartinm.name + Web Services Spring Framework + + Gustavo Martin Morcuende + http://www.gumartinm.name + + + scm:git:http://git.gumartinm.name/SpringWebServicesForFun + http://git.gumartinm.name/SpringWebServicesForFun + + + + UTF-8 + UTF-8 + + 4.0.9.RELEASE + 2.2.1.RELEASE + + + + + release + + release + + + true + + + + + + + + org.apache.logging.log4j + log4j-slf4j-impl + 2.3 + + + + org.apache.logging.log4j + log4j-core + 2.3 + + + + org.slf4j + jcl-over-slf4j + 1.7.12 + + + cglib + cglib + 2.2.2 + + + + + + org.springframework.ws + spring-ws-core + ${spring.ws.version} + + + + commons-logging + commons-logging + + + + + org.springframework.ws + spring-xml + ${spring.ws.version} + + + + commons-logging + commons-logging + + + + + org.jdom + jdom + 2.0.2 + + + + + wsdl4j + wsdl4j + 1.6.3 + + + + + junit + junit + 4.12 + test + + + org.springframework + spring-test + ${spring.version} + test + + + org.springframework.ws + spring-ws-test + ${spring.ws.version} + test + + + + commons-logging + commons-logging + + + + + org.mockito + mockito-core + 2.0.11-beta + test + + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.18.1 + + + org.apache.maven.plugins + maven-failsafe-plugin + 2.18.1 + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.3 + + 1.8 + 1.8 + ${project.build.sourceEncoding} + + + + org.apache.maven.plugins + maven-resources-plugin + 2.7 + + ${project.build.sourceEncoding} + + + + org.apache.maven.plugins + maven-jar-plugin + 2.4 + + + + ${project.description} + ${project.version} + ${project.organization.name} + ${project.description} + ${project.version} + ${project.organization.name} + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + **/*IntegrationTest.java + + + + + org.apache.maven.plugins + maven-failsafe-plugin + + + + integration-test + verify + + + + + + **/*IntegrationTest.java + + + + + + diff --git a/cxf/web-services-spring-cxf-client/pom.xml b/cxf/web-services-spring-cxf-client/pom.xml deleted file mode 100644 index c3de39a..0000000 --- a/cxf/web-services-spring-cxf-client/pom.xml +++ /dev/null @@ -1,169 +0,0 @@ - - 4.0.0 - - web-services-spring-cxf - de.spring.webservices - 1.0-SNAPSHOT - - web-services-spring-cxf-client - web-services-spring-cxf-client - http://gumartinm.name - - - src/main/build-resources/wsdl - ${basedir}/target/generated-sources/src/main/java - src/main/build-resources/bindings - - ${basedir}/src/main/build-resources/catalogs - - - - - org.springframework.ws - spring-ws-core - - - org.springframework.ws - spring-xml - - - org.jdom - jdom - - - - - - de.spring.webservices - web-services-spring-cxf-globalxsds - ${project.version} - - - - - - wsdl4j - wsdl4j - - - - - org.jvnet.jaxb2_commons - jaxb2-basics-runtime - 0.9.4 - - - - - junit - junit - test - - - org.springframework - spring-test - test - - - org.springframework.ws - spring-ws-test - test - - - - - ${project.artifactId} - - - ${basedir}/src/main/resources/ - - **/*.* - - - - - - - org.apache.cxf - cxf-codegen-plugin - 3.1.0 - - - generate-sources-from-wsdl - generate-sources - - wsdl2java - - - true - ${project.wsdl.target.path} - - - ${project.wsdl.sources.path}/example.wsdl - - ${project.bindings.path}/custombinding.xjb - - - -xjc-Xinheritance - -xjc-Xannotate - -catalog - ${project.catalogs.path}/catalog.cat - -verbose - - - - - - - - - - org.jvnet.jaxb2_commons - jaxb2-basics - 0.9.4 - - - - - org.jvnet.jaxb2_commons - jaxb2-basics-annotate - 1.0.1 - - - - - org.codehaus.mojo - build-helper-maven-plugin - 1.9.1 - - - add-source - generate-sources - - add-source - - - - ${project.wsdl.target.path} - - - - - - - - - diff --git a/cxf/web-services-spring-cxf-client/src/main/build-resources/bindings/custombinding.xjb b/cxf/web-services-spring-cxf-client/src/main/build-resources/bindings/custombinding.xjb deleted file mode 100644 index d573e11..0000000 --- a/cxf/web-services-spring-cxf-client/src/main/build-resources/bindings/custombinding.xjb +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - - - - - - - - - - de.spring.webservices.operations.Request - @java.lang.suppresswarnings({"unchecked","rawtypes"}) - - - - de.spring.webservices.operations.Response - @java.lang.suppresswarnings({"unchecked","rawtypes"}) - - - - - - - - - diff --git a/cxf/web-services-spring-cxf-client/src/main/build-resources/catalogs/catalog.cat b/cxf/web-services-spring-cxf-client/src/main/build-resources/catalogs/catalog.cat deleted file mode 100644 index 4bc1c66..0000000 --- a/cxf/web-services-spring-cxf-client/src/main/build-resources/catalogs/catalog.cat +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/cxf/web-services-spring-cxf-client/src/main/build-resources/wsdl/example.wsdl b/cxf/web-services-spring-cxf-client/src/main/build-resources/wsdl/example.wsdl deleted file mode 100644 index e3f61ed..0000000 --- a/cxf/web-services-spring-cxf-client/src/main/build-resources/wsdl/example.wsdl +++ /dev/null @@ -1,194 +0,0 @@ - - - - - - - - - - - - - - - - - @java.lang.SuppressWarnings({"unchecked","rawtypes"}) - de.spring.webservices.operations.Request - - - - - - - - - - - - de.spring.webservices.operations.Response - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/cxf/web-services-spring-cxf-client/src/main/java/de/spring/webservices/client/CustomFaultMessageResolver.java b/cxf/web-services-spring-cxf-client/src/main/java/de/spring/webservices/client/CustomFaultMessageResolver.java deleted file mode 100644 index 244be4e..0000000 --- a/cxf/web-services-spring-cxf-client/src/main/java/de/spring/webservices/client/CustomFaultMessageResolver.java +++ /dev/null @@ -1,83 +0,0 @@ -package de.spring.webservices.client; - -import java.io.IOException; -import java.util.Iterator; - -import javax.xml.transform.Source; - -// cxf-codegen-plugin DOES generate again the objects in web-services-spring-jaxb2-globalxsds :( -// So I guess it is better to use the objects generated in this package -// than the ones from globalxsds even if they should be the same. -import name.gumartinm.spring_ws.parent.GeneralFault; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.oxm.Unmarshaller; -import org.springframework.oxm.XmlMappingException; -import org.springframework.ws.WebServiceMessage; -import org.springframework.ws.client.core.FaultMessageResolver; -import org.springframework.ws.soap.SoapBody; -import org.springframework.ws.soap.SoapFault; -import org.springframework.ws.soap.SoapFaultDetail; -import org.springframework.ws.soap.SoapFaultDetailElement; -import org.springframework.ws.soap.SoapMessage; -import org.springframework.ws.soap.client.core.SoapFaultMessageResolver; - -/** - * Enables us to log custom Fault remote messages. - * - */ -public class CustomFaultMessageResolver implements FaultMessageResolver { - -private static final Logger LOGGER = LoggerFactory.getLogger(CustomFaultMessageResolver.class); - - private final FaultMessageResolver defaultMessageResolver = new SoapFaultMessageResolver(); - - private Unmarshaller unmarshaller; - - @Override - public void resolveFault(WebServiceMessage message) throws IOException { - - // Same behavior as default message resolver (SoapFaultMessageResolver) but this implementation also - // logs error information. - if (LOGGER.isErrorEnabled()) { - try { - logErrorInformation(message); - } catch (Exception ex) { - LOGGER.error("CustomFaultMessageResolver exception:", ex); - } - } - - defaultMessageResolver.resolveFault(message); - } - - private void logErrorInformation(WebServiceMessage message) throws XmlMappingException, IOException { - SoapMessage soapMessage = (SoapMessage) message; - SoapBody body = soapMessage.getSoapBody(); - SoapFault soapFault = body != null ? body.getFault() : null; - SoapFaultDetail detail = soapFault != null ? soapFault.getFaultDetail() : null; - - if (detail != null) { - Iterator iterator = detail.getDetailEntries(); - while (iterator.hasNext()) { - SoapFaultDetailElement bodyElement = iterator.next(); - Source detailSource = bodyElement.getSource(); - // TODO: How to check if I am receiving GeneralFault before trying to unmarshal? - // Right now there will be exception if unmarshal doesn't return a GeneralFault object. - GeneralFault error = (GeneralFault)this.unmarshaller.unmarshal(detailSource); - LOGGER.error("TECHNICALERROR:"); - LOGGER.error(error.getTechnicalError()); - LOGGER.error("ELEMENTS:"); - error.getElements().forEach(element -> { - LOGGER.error("MESSAGE: " + element.getMessage()); - LOGGER.error("MESSAGEARGS:"); - element.getMessageArgs().forEach(messageArg -> LOGGER.error(messageArg)); - }); - } - } - } - - public void setUnmarshaller(Unmarshaller unmarshaller) { - this.unmarshaller = unmarshaller; - } -} diff --git a/cxf/web-services-spring-cxf-client/src/main/java/de/spring/webservices/client/ExampleClientService.java b/cxf/web-services-spring-cxf-client/src/main/java/de/spring/webservices/client/ExampleClientService.java deleted file mode 100644 index 32e1435..0000000 --- a/cxf/web-services-spring-cxf-client/src/main/java/de/spring/webservices/client/ExampleClientService.java +++ /dev/null @@ -1,76 +0,0 @@ -package de.spring.webservices.client; - -import name.gumartinm.spring_ws.parent.ParentEnumType; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.ws.client.core.WebServiceTemplate; - -import de.spring.webservices.client.auto.CustomBindingExampleFault_Exception; -import de.spring.webservices.client.auto.CustomBindingExampleRequest; -import de.spring.webservices.client.auto.CustomBindingExampleResponse; -import de.spring.webservices.client.auto.ExampleFault_Exception; -import de.spring.webservices.client.auto.ExampleRequest; -import de.spring.webservices.client.auto.ExampleResponse; -import de.spring.webservices.client.auto.Examples; -import de.spring.webservices.client.auto.ExamplesService; - -/** - * Someone could write code like this one in order to send and receive - * information from our Web Services. - * - */ -@Service("exampleClientService") -public class ExampleClientService { - private final WebServiceTemplate webServiceTemplate; - - @Autowired - public ExampleClientService(WebServiceTemplate webServiceTemplate) { - this.webServiceTemplate = webServiceTemplate; - } - - public ExampleResponse sendAndReceiveJava() throws ExampleFault_Exception { - final ExampleRequest exampleRequest = new ExampleRequest(); - exampleRequest.setData("SCARLETT JAVA. IT IS CANON."); - - final Examples exampleService = new ExamplesService().getExamplesSoap12(); - final ExampleResponse exampleResponse = exampleService.example(exampleRequest); - - return exampleResponse; - } - - public ExampleResponse sendAndReceiveSpring() { - final ExampleRequest exampleRequest = new ExampleRequest(); - exampleRequest.setData("SCARLETT SPRING. IT IS CANON."); - - final ExampleResponse exampleResponse = (ExampleResponse) - this.webServiceTemplate.marshalSendAndReceive(exampleRequest); - - return exampleResponse; - } - - public CustomBindingExampleResponse sendAndReceiveJavaCustom() throws CustomBindingExampleFault_Exception { - final CustomBindingExampleRequest customBindingxampleRequest = - new CustomBindingExampleRequest(); - customBindingxampleRequest.setData("CUSTOM BINDING JAVA. SCARLETT. IT IS CANON."); - customBindingxampleRequest.setParentEnum(ParentEnumType.FIRST); - - final Examples exampleService = new ExamplesService().getExamplesSoap12(); - final CustomBindingExampleResponse customBindingExampleResponse = - exampleService.customBindingExample(customBindingxampleRequest); - - return customBindingExampleResponse; - } - - public CustomBindingExampleResponse sendAndReceiveSpringCustom() { - final CustomBindingExampleRequest customBindingxampleRequest = - new CustomBindingExampleRequest(); - customBindingxampleRequest.setData("CUSTOM BINDING SPRING. SCARLETT. IT IS CANON."); - - final CustomBindingExampleResponse customBindingExampleResponse = - (CustomBindingExampleResponse) this.webServiceTemplate - .marshalSendAndReceive(customBindingxampleRequest); - - return customBindingExampleResponse; - } -} diff --git a/cxf/web-services-spring-cxf-client/src/main/java/de/spring/webservices/client/MainTest.java b/cxf/web-services-spring-cxf-client/src/main/java/de/spring/webservices/client/MainTest.java deleted file mode 100644 index 54cc644..0000000 --- a/cxf/web-services-spring-cxf-client/src/main/java/de/spring/webservices/client/MainTest.java +++ /dev/null @@ -1,68 +0,0 @@ -package de.spring.webservices.client; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.context.ApplicationContext; -import org.springframework.context.support.ClassPathXmlApplicationContext; - -import de.spring.webservices.client.auto.CustomBindingExampleFault; -import de.spring.webservices.client.auto.CustomBindingExampleResponse; -import de.spring.webservices.client.auto.ExampleFault; -import de.spring.webservices.client.auto.ExampleResponse; - -/** - * This class is used just like a nice example about how to write and run client - * code which will send data to and from the Web Services. - * - */ -public class MainTest { - private static final Logger LOGGER = LoggerFactory.getLogger(MainTest.class); - - public ApplicationContext context; - - /** - * @param args - * @throws ExampleFault_Exception - * @throws CustomBindingExampleFault_Exception - */ - public static void main(final String[] args) { - final MainTest test = new MainTest(); - - test.context = new ClassPathXmlApplicationContext( - "classpath:spring-configuration/ws/client-spring-configuration.xml"); - - final ExampleClientService example = - (ExampleClientService) test.context.getBean("exampleClientService"); - - LOGGER.info("ExampleResponse Java:"); - ExampleResponse response; - try { - response = example.sendAndReceiveJava(); - LOGGER.info(response.getData()); - } catch (Exception e) { - LOGGER.info("ExampleResponse Java error:", e); - } - - - - LOGGER.info("CustomBindingExampleResponse Java:"); - CustomBindingExampleResponse customBindingResponse; - try { - customBindingResponse = example.sendAndReceiveJavaCustom(); - LOGGER.info(customBindingResponse.getData()); - } catch (Exception e) { - LOGGER.info("CustomBindingExampleResponse Java error:", e); - } - - - - LOGGER.info("ExampleResponse Spring:"); - response = example.sendAndReceiveSpring(); - LOGGER.info(response.getData()); - - - LOGGER.info("CustomBindingExampleResponse Spring:"); - customBindingResponse = example.sendAndReceiveSpringCustom(); - LOGGER.info(customBindingResponse.getData()); - } -} diff --git a/cxf/web-services-spring-cxf-client/src/main/java/de/spring/webservices/client/transport/http/CustomHttpRequestMessageSender.java b/cxf/web-services-spring-cxf-client/src/main/java/de/spring/webservices/client/transport/http/CustomHttpRequestMessageSender.java deleted file mode 100644 index cf44220..0000000 --- a/cxf/web-services-spring-cxf-client/src/main/java/de/spring/webservices/client/transport/http/CustomHttpRequestMessageSender.java +++ /dev/null @@ -1,57 +0,0 @@ -package de.spring.webservices.client.transport.http; - -import java.io.IOException; -import java.net.URI; - -import org.springframework.http.HttpMethod; -import org.springframework.http.client.ClientHttpRequest; -import org.springframework.http.client.ClientHttpRequestFactory; -import org.springframework.http.client.SimpleClientHttpRequestFactory; -import org.springframework.ws.transport.WebServiceConnection; -import org.springframework.ws.transport.http.AbstractHttpWebServiceMessageSender; -import org.springframework.ws.transport.http.ClientHttpRequestConnection; -import org.springframework.ws.transport.http.HttpTransportConstants; - - -/** - * Based on ClientHttpRequestMessageSender from the Spring WS framework. - * - *

- * Spring WS framework also provides implementations based on the HTTP clients by Jakarta and Apache HttpClient: - * {@link https://hc.apache.org/httpcomponents-client-ga/} and {@link http://hc.apache.org/httpclient-3.x/} - *

- * - *

- * Four implementations for four HTTP clients: - *

    - *
  • org.springframework.ws.transport.http.ClientHttpRequestMessageSender (ClientHttpRequestFactory from the Spring framework)
  • - *
  • org.springframework.ws.transport.http.CommonsHttpMessageSender (Jakarta implementation)
  • - *
  • org.springframework.ws.transport.http.HttpComponentsMessageSender (Apache HttpClient)
  • - *
  • org.springframework.ws.transport.http.HttpUrlConnectionMessageSender - * (org.springframework.ws.transport.http.HttpUrlConnection internal Spring framework implementation)
  • - *
- *

- */ -public class CustomHttpRequestMessageSender extends AbstractHttpWebServiceMessageSender { - private static final String MY_CUSTOM_HEADER = "MY_CUSTOM_HEADER"; - - private final ClientHttpRequestFactory requestFactory; - - public CustomHttpRequestMessageSender() { - requestFactory = new SimpleClientHttpRequestFactory(); - } - - @Override - public WebServiceConnection createConnection(URI uri) throws IOException { - ClientHttpRequest request = requestFactory.createRequest(uri, HttpMethod.POST); - if (isAcceptGzipEncoding()) { - request.getHeaders().add(HttpTransportConstants.HEADER_ACCEPT_ENCODING, - HttpTransportConstants.CONTENT_ENCODING_GZIP); - } - - request.getHeaders().add(MY_CUSTOM_HEADER, "gumartinm.name"); - - return new ClientHttpRequestConnection(request); - } - -} diff --git a/cxf/web-services-spring-cxf-client/src/main/resources/examples.xsd b/cxf/web-services-spring-cxf-client/src/main/resources/examples.xsd deleted file mode 100644 index 59cd317..0000000 --- a/cxf/web-services-spring-cxf-client/src/main/resources/examples.xsd +++ /dev/null @@ -1,127 +0,0 @@ - - - - - - - - - - - - - - - - @java.lang.SuppressWarnings({"unchecked","rawtypes"}) - de.spring.webservices.operations.Request - - - - - - - - - - - - de.spring.webservices.operations.Response - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/cxf/web-services-spring-cxf-client/src/main/resources/log4j2.xml b/cxf/web-services-spring-cxf-client/src/main/resources/log4j2.xml deleted file mode 100644 index 5d47d57..0000000 --- a/cxf/web-services-spring-cxf-client/src/main/resources/log4j2.xml +++ /dev/null @@ -1,85 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/cxf/web-services-spring-cxf-client/src/main/resources/spring-configuration/ws/client-spring-configuration.xml b/cxf/web-services-spring-cxf-client/src/main/resources/spring-configuration/ws/client-spring-configuration.xml deleted file mode 100644 index 7f6f1f3..0000000 --- a/cxf/web-services-spring-cxf-client/src/main/resources/spring-configuration/ws/client-spring-configuration.xml +++ /dev/null @@ -1,198 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - classpath:parent.xsd - - classpath:examples.xsd - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/cxf/web-services-spring-cxf-client/src/test/java/de/spring/webservices/client/ExampleClientServiceIntegrationTest.java b/cxf/web-services-spring-cxf-client/src/test/java/de/spring/webservices/client/ExampleClientServiceIntegrationTest.java deleted file mode 100644 index 4877a5d..0000000 --- a/cxf/web-services-spring-cxf-client/src/test/java/de/spring/webservices/client/ExampleClientServiceIntegrationTest.java +++ /dev/null @@ -1,78 +0,0 @@ -package de.spring.webservices.client; - -import static org.junit.Assert.assertEquals; -import static org.springframework.ws.test.client.RequestMatchers.payload; -import static org.springframework.ws.test.client.ResponseCreators.withPayload; - -import javax.xml.transform.Source; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.ws.client.core.WebServiceTemplate; -import org.springframework.ws.test.client.MockWebServiceServer; -import org.springframework.xml.transform.StringSource; - -import de.spring.webservices.client.auto.CustomBindingExampleResponse; -import de.spring.webservices.client.auto.ExampleResponse; - - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration("classpath*:spring-configuration/ws/client-spring-configuration.xml") -public class ExampleClientServiceIntegrationTest { - - @Autowired - ExampleClientService exampleClientService; - - @Autowired - private WebServiceTemplate webServiceTemplate; - - private MockWebServiceServer mockServer; - - @Before - public void createServer() throws Exception { - mockServer = MockWebServiceServer.createServer(webServiceTemplate); - } - - @Test - public void customerClient() throws Exception { - final Source requestPayload = new StringSource( - "" - + "SCARLETT SPRING. IT IS CANON." - + ""); - final Source responsePayload = new StringSource( - "" - + "SNAKE EYES AND SCARLETT SPRING. IT IS CANON." - + ""); - mockServer.expect(payload(requestPayload)).andRespond( - withPayload(responsePayload)); - - final ExampleResponse response = exampleClientService.sendAndReceiveSpring(); - - assertEquals(response.getData(), "SNAKE EYES AND SCARLETT SPRING. IT IS CANON."); - mockServer.verify(); - } - - @Test - public void customerCustomClient() throws Exception { - final Source customRequestPayload = new StringSource( - "" + - "CUSTOM BINDING SPRING. SCARLETT. IT IS CANON." + - ""); - final Source customResponsePayload = new StringSource( - "" + - "CUSTOM BINDING SNAKE EYES AND SCARLETT SPRING. IT IS CANON." + - ""); - mockServer.expect(payload(customRequestPayload)).andRespond( - withPayload(customResponsePayload)); - - final CustomBindingExampleResponse response = exampleClientService.sendAndReceiveSpringCustom(); - - assertEquals(response.getData(), "CUSTOM BINDING SNAKE EYES AND SCARLETT SPRING. IT IS CANON."); - mockServer.verify(); - } -} - diff --git a/cxf/web-services-spring-cxf-globalxsds/pom.xml b/cxf/web-services-spring-cxf-globalxsds/pom.xml deleted file mode 100644 index ef09daf..0000000 --- a/cxf/web-services-spring-cxf-globalxsds/pom.xml +++ /dev/null @@ -1,97 +0,0 @@ - - 4.0.0 - - web-services-spring-cxf - de.spring.webservices - 1.0-SNAPSHOT - - web-services-spring-cxf-globalxsds - web-services-spring-cxf-globalxsds - http://gumartinm.name - - - src/main/resources - ${basedir}/target/generated-sources/src/main/java - de.spring.webservices.parent.auto - src/main/build-resources/bindings - - - - - - - junit - junit - test - - - - - ${project.artifactId} - - - ${basedir}/src/main/resources - - **/*.* - - - - - - - org.apache.cxf - cxf-xjc-plugin - 3.0.3 - - true - - org.apache.cxf.xjcplugins:cxf-xjc-dv:3.0.3 - - - - - generate-sources-from-xsd - generate-sources - - xsdtojava - - - ${project.xsd.schemas.target.path} - - - true - ${project.xsd.schemas.source.path}/parent.xsd - ${project.bindings.path}/custombinding.xjb - ${project.xsd.schemas.package.name} - - - - - - - - org.codehaus.mojo - build-helper-maven-plugin - 1.9.1 - - - add-source - generate-sources - - add-source - - - - ${project.xsd.schemas.target.path} - - - - - - - - diff --git a/cxf/web-services-spring-cxf-globalxsds/src/main/build-resources/bindings/custombinding.xjb b/cxf/web-services-spring-cxf-globalxsds/src/main/build-resources/bindings/custombinding.xjb deleted file mode 100644 index 8b4a110..0000000 --- a/cxf/web-services-spring-cxf-globalxsds/src/main/build-resources/bindings/custombinding.xjb +++ /dev/null @@ -1,8 +0,0 @@ - - - - - diff --git a/cxf/web-services-spring-cxf-globalxsds/src/main/java/de/spring/webservices/binders/XSDateTimeCustomBinder.java b/cxf/web-services-spring-cxf-globalxsds/src/main/java/de/spring/webservices/binders/XSDateTimeCustomBinder.java deleted file mode 100644 index f39921a..0000000 --- a/cxf/web-services-spring-cxf-globalxsds/src/main/java/de/spring/webservices/binders/XSDateTimeCustomBinder.java +++ /dev/null @@ -1,35 +0,0 @@ -package de.spring.webservices.binders; - -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.TimeZone; - -import javax.xml.bind.annotation.adapters.XmlAdapter; - - -/** - * ATTENTION: if you are using this custombinder you will have to create custom payload - * validators for Spring (AS FAR AS I KNOW) - * - */ -public class XSDateTimeCustomBinder extends XmlAdapter { - - @Override - public Date unmarshal(final String dateTime) throws Exception { - // X pattern just works from Java >= 1.7 - final DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssX"); - formatter.setTimeZone(TimeZone.getTimeZone("Europe/Madrid")); - - return formatter.parse(dateTime); - } - - @Override - public String marshal(final Date dateTime) throws Exception { - // X pattern just works from Java >= 1.7 - final DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssX"); - formatter.setTimeZone(TimeZone.getTimeZone("Europe/Madrid")); - - return formatter.format(dateTime); - } -} diff --git a/cxf/web-services-spring-cxf-globalxsds/src/main/java/de/spring/webservices/operations/Operations.java b/cxf/web-services-spring-cxf-globalxsds/src/main/java/de/spring/webservices/operations/Operations.java deleted file mode 100644 index 13b5113..0000000 --- a/cxf/web-services-spring-cxf-globalxsds/src/main/java/de/spring/webservices/operations/Operations.java +++ /dev/null @@ -1,111 +0,0 @@ -package de.spring.webservices.operations; - -/** - *

- * Operations: WSDL v1.1 and v2.0 - *

- * See: http://www.w3.org/TR/wsdl#_porttypes
- * See: - * http://www.w3.org/TR/2007/REC-wsdl20-adjuncts-20070626/#patterns - * - */ -public interface Operations { - - /** - *

- * Request-response operation WSDL v1.1 - *

- * See: http://www.w3.org - * /TR/wsdl#_request-response - * - * @param - * Describes {@link Response} - * @param - * Describes {@link Request} - */ - public static interface RequestResponse { - T requestResponse(E request); - } - - /** - *

- * One-way operation WSDL v1.1 - *

- * See: http://www.w3.org/TR/wsdl - * #_one-way - * - * @param - * Describes {@link Response} - * @param - * Describes {@link Request} - */ - public interface OneWay { - void oneWay(E request); - } - - /** - *

- * Notification operation WSDL v1.1 - *

- * See: http://www.w3.org/TR - * /wsdl#_notification - * - * @param - * Describes {@link Response} - * @param - * Describes {@link Request} - */ - public interface Notification { - T notification(); - } - - /** - *

- * In-Only message exchange pattern WSDL 2.0 - *

- * See: - * http://www.w3.org/TR/2007/REC-wsdl20-adjuncts-20070626/#patterns - * - * @param - * Describes {@link Request} - */ - public interface InOnly { - void inOnly(E request); - } - - /** - *

- * Robust In-Only message exchange pattern WSDL 2.0 - *

- * See: - * http://www.w3.org/TR/2007/REC-wsdl20-adjuncts-20070626/#patterns - * - * @param - * Describes {@link Request} - */ - public interface RobustInOnly { - void robustInOnly(E request); - } - - /** - *

- * In-Out message exchange pattern WSDL 2.0 - *

- * See: - * http://www.w3.org/TR/2007/REC-wsdl20-adjuncts-20070626/#patterns - * - * @param - * Describes {@link Response} - * @param - * Describes {@link Request} - */ - public interface InOut { - T inOut(E request); - } -} \ No newline at end of file diff --git a/cxf/web-services-spring-cxf-globalxsds/src/main/java/de/spring/webservices/operations/Request.java b/cxf/web-services-spring-cxf-globalxsds/src/main/java/de/spring/webservices/operations/Request.java deleted file mode 100644 index 77d81f4..0000000 --- a/cxf/web-services-spring-cxf-globalxsds/src/main/java/de/spring/webservices/operations/Request.java +++ /dev/null @@ -1,5 +0,0 @@ -package de.spring.webservices.operations; - -public interface Request { - -} diff --git a/cxf/web-services-spring-cxf-globalxsds/src/main/java/de/spring/webservices/operations/Response.java b/cxf/web-services-spring-cxf-globalxsds/src/main/java/de/spring/webservices/operations/Response.java deleted file mode 100644 index 3a2cbea..0000000 --- a/cxf/web-services-spring-cxf-globalxsds/src/main/java/de/spring/webservices/operations/Response.java +++ /dev/null @@ -1,5 +0,0 @@ -package de.spring.webservices.operations; - -public interface Response { - -} diff --git a/cxf/web-services-spring-cxf-globalxsds/src/main/resources/parent.xsd b/cxf/web-services-spring-cxf-globalxsds/src/main/resources/parent.xsd deleted file mode 100644 index b38ca36..0000000 --- a/cxf/web-services-spring-cxf-globalxsds/src/main/resources/parent.xsd +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/cxf/web-services-spring-cxf-server/pom.xml b/cxf/web-services-spring-cxf-server/pom.xml deleted file mode 100644 index 6807bad..0000000 --- a/cxf/web-services-spring-cxf-server/pom.xml +++ /dev/null @@ -1,216 +0,0 @@ - - 4.0.0 - - web-services-spring-cxf - de.spring.webservices - 1.0-SNAPSHOT - - web-services-spring-cxf-server - war - web-services-spring-cxf-server - http://gumartinm.name - - - 9.3.0.RC0 - src/main/resources - ${basedir}/target/generated-sources/src/main/java - de.spring.webservices.server.auto - src/main/build-resources/bindings - - ${basedir}/src/main/build-resources/catalogs - - - - - org.springframework.ws - spring-ws-core - - - org.springframework.ws - spring-xml - - - org.jdom - jdom - - - - - - de.spring.webservices - web-services-spring-cxf-globalxsds - ${project.version} - - - - - - wsdl4j - wsdl4j - - - - - org.jvnet.jaxb2_commons - jaxb2-basics-runtime - 0.9.4 - - - - - javax.servlet - javax.servlet-api - 4.0.0-b01 - provided - - - - - junit - junit - test - - - org.springframework - spring-test - test - - - org.springframework.ws - spring-ws-test - test - - - org.mockito - mockito-core - test - - - - - ${project.artifactId} - - - ${basedir}/src/main/webapp - - **/*.* - - - - ${basedir}/src/main/resources/ - - **/*.* - - - - - - - org.apache.cxf - cxf-xjc-plugin - - true - - org.apache.cxf.xjcplugins:cxf-xjc-dv:3.0.3 - - - - - generate-sources-from-xsd - generate-sources - - xsdtojava - - - ${project.xsd.schemas.target.path} - - - true - ${project.xsd.schemas.source.path}/examples.xsd - ${project.bindings.path}/custombinding.xjb - ${project.catalogs.path}/catalog.cat - ${project.xsd.schemas.package.name} - - -Xinheritance - -Xannotate - - - - - - - - - - org.jvnet.jaxb2_commons - jaxb2-basics - 0.9.4 - - - - - org.jvnet.jaxb2_commons - jaxb2-basics-annotate - 1.0.1 - - - - - org.codehaus.mojo - build-helper-maven-plugin - 1.9.1 - - - add-source - generate-sources - - add-source - - - - ${project.xsd.schemas.target.path} - - - - - - - org.apache.maven.plugins - maven-war-plugin - 2.6 - - - - true - src/main/webapp - - WEB-INF/web.xml - - - - - - - org.eclipse.jetty - jetty-maven-plugin - ${jetty.version} - - ${basedir}/src/main/jetty/jetty-http.xml - - - - - diff --git a/cxf/web-services-spring-cxf-server/src/main/build-resources/bindings/custombinding.xjb b/cxf/web-services-spring-cxf-server/src/main/build-resources/bindings/custombinding.xjb deleted file mode 100644 index 60740a4..0000000 --- a/cxf/web-services-spring-cxf-server/src/main/build-resources/bindings/custombinding.xjb +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - - de.spring.webservices.operations.Request - @java.lang.SuppressWarnings({"unchecked","rawtypes"}) - - - - - - - de.spring.webservices.operations.Response - @java.lang.SuppressWarnings({"unchecked","rawtypes"}) - - - - - - - - - - - diff --git a/cxf/web-services-spring-cxf-server/src/main/build-resources/catalogs/catalog.cat b/cxf/web-services-spring-cxf-server/src/main/build-resources/catalogs/catalog.cat deleted file mode 100644 index 4bc1c66..0000000 --- a/cxf/web-services-spring-cxf-server/src/main/build-resources/catalogs/catalog.cat +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/cxf/web-services-spring-cxf-server/src/main/java/de/spring/webservices/endpoints/CustomHeaderInterceptor.java b/cxf/web-services-spring-cxf-server/src/main/java/de/spring/webservices/endpoints/CustomHeaderInterceptor.java deleted file mode 100644 index e1d5302..0000000 --- a/cxf/web-services-spring-cxf-server/src/main/java/de/spring/webservices/endpoints/CustomHeaderInterceptor.java +++ /dev/null @@ -1,50 +0,0 @@ -package de.spring.webservices.endpoints; - -import javax.servlet.http.HttpServletRequest; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.util.StringUtils; -import org.springframework.ws.context.MessageContext; -import org.springframework.ws.server.EndpointInterceptor; -import org.springframework.ws.transport.context.TransportContext; -import org.springframework.ws.transport.context.TransportContextHolder; -import org.springframework.ws.transport.http.HttpServletConnection; - -public class CustomHeaderInterceptor implements EndpointInterceptor { - private static final Logger LOGGER = LoggerFactory.getLogger(CustomHeaderInterceptor.class); - private static final String MY_CUSTOM_HEADER = "MY_CUSTOM_HEADER"; - - @Override - public boolean handleRequest(MessageContext messageContext, Object endpoint) throws Exception { - TransportContext transport = TransportContextHolder.getTransportContext(); - - if (transport != null) { - HttpServletConnection connection = (HttpServletConnection) transport.getConnection(); - HttpServletRequest headers = connection.getHttpServletRequest(); - String headerValue = headers.getHeader(MY_CUSTOM_HEADER); - - if (!StringUtils.isEmpty(headerValue)) { - LOGGER.info("Custom header value: " + headerValue); - } - } - - return true; - } - - @Override - public boolean handleResponse(MessageContext messageContext, Object endpoint) throws Exception { - return true; - } - - @Override - public boolean handleFault(MessageContext messageContext, Object endpoint) throws Exception { - return true; - } - - @Override - public void afterCompletion(MessageContext messageContext, Object endpoint, Exception ex) throws Exception { - - } - -} diff --git a/cxf/web-services-spring-cxf-server/src/main/java/de/spring/webservices/endpoints/ExampleEndPoint.java b/cxf/web-services-spring-cxf-server/src/main/java/de/spring/webservices/endpoints/ExampleEndPoint.java deleted file mode 100644 index e3e8da6..0000000 --- a/cxf/web-services-spring-cxf-server/src/main/java/de/spring/webservices/endpoints/ExampleEndPoint.java +++ /dev/null @@ -1,57 +0,0 @@ -package de.spring.webservices.endpoints; - -import org.jdom2.Element; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.ws.context.MessageContext; -import org.springframework.ws.server.endpoint.annotation.Endpoint; -import org.springframework.ws.server.endpoint.annotation.PayloadRoot; -import org.springframework.ws.server.endpoint.annotation.RequestPayload; -import org.springframework.ws.server.endpoint.annotation.ResponsePayload; - -import de.spring.webservices.operations.Operations; -import de.spring.webservices.operations.Operations.RequestResponse; -import de.spring.webservices.server.auto.CustomBindingExampleRequest; -import de.spring.webservices.server.auto.CustomBindingExampleResponse; -import de.spring.webservices.server.auto.ExampleRequest; -import de.spring.webservices.server.auto.ExampleResponse; -import de.spring.webservices.services.ExampleService; - - -@Endpoint -public class ExampleEndPoint { - private static final String NAMESPACE_URI = "http://gumartinm.name/spring-ws/example"; - - private final Operations.RequestResponse - customBindingExampleService; - - private final ExampleService exampleService; - - @Autowired - public ExampleEndPoint( - RequestResponse customBindingExampleService, - ExampleService exampleService) { - this.customBindingExampleService = customBindingExampleService; - this.exampleService = exampleService; - } - - @PayloadRoot(localPart = "ExampleRequest", namespace = NAMESPACE_URI) - @ResponsePayload - public ExampleResponse exampleResponse( - @RequestPayload final ExampleRequest request, - @RequestPayload final Element element, - final MessageContext messageContext) { - - return this.exampleService.doResponse(request); - } - - @PayloadRoot(localPart = "CustomBindingExampleRequest", namespace = NAMESPACE_URI) - @ResponsePayload - public CustomBindingExampleResponse cuntomBindingExampleResponse( - @RequestPayload final CustomBindingExampleRequest requestObject, - @RequestPayload final Element element, - final MessageContext messageContext) { - - return this.customBindingExampleService.requestResponse(requestObject); - } -} - diff --git a/cxf/web-services-spring-cxf-server/src/main/java/de/spring/webservices/endpoints/MyCustomMappingExceptionResolver.java b/cxf/web-services-spring-cxf-server/src/main/java/de/spring/webservices/endpoints/MyCustomMappingExceptionResolver.java deleted file mode 100644 index 9d05061..0000000 --- a/cxf/web-services-spring-cxf-server/src/main/java/de/spring/webservices/endpoints/MyCustomMappingExceptionResolver.java +++ /dev/null @@ -1,140 +0,0 @@ -package de.spring.webservices.endpoints; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Properties; - -import javax.xml.transform.Result; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.oxm.Marshaller; -import org.springframework.util.CollectionUtils; -import org.springframework.ws.soap.SoapFault; -import org.springframework.ws.soap.SoapFaultDetail; -import org.springframework.ws.soap.server.endpoint.AbstractSoapFaultDefinitionExceptionResolver; -import org.springframework.ws.soap.server.endpoint.SoapFaultDefinition; -import org.springframework.ws.soap.server.endpoint.SoapFaultDefinitionEditor; - -import de.spring.webservices.exceptions.CustomBusinessException; -import de.spring.webservices.server.auto.Element; -import de.spring.webservices.server.auto.GeneralFault; - -public class MyCustomMappingExceptionResolver extends AbstractSoapFaultDefinitionExceptionResolver { - private static final Logger LOGGER = LoggerFactory.getLogger(MyCustomMappingExceptionResolver.class); - - private Marshaller marshaller; - - private Map exceptionMappings = new LinkedHashMap<>(); - - /** - * Set the mappings between exception class names and SOAP Faults. The exception class name can be a substring, with - * no wildcard support at present. - * - *

The values of the given properties object should use the format described in - * {@code SoapFaultDefinitionEditor}. - * - *

Follows the same matching algorithm as {@code SimpleMappingExceptionResolver}. - * - * @param mappings exception patterns (can also be fully qualified class names) as keys, fault definition texts as - * values - * @see SoapFaultDefinitionEditor - */ - public void setExceptionMappings(Properties mappings) { - for (Map.Entry entry : mappings.entrySet()) { - if (entry.getKey() instanceof String && entry.getValue() instanceof String) { - exceptionMappings.put((String)entry.getKey(), (String)entry.getValue()); - } - } - } - - @Override - protected SoapFaultDefinition getFaultDefinition(Object endpoint, Exception ex) { - if (!CollectionUtils.isEmpty(exceptionMappings)) { - String definitionText = null; - int deepest = Integer.MAX_VALUE; - for (String exceptionMapping : exceptionMappings.keySet()) { - int depth = getDepth(exceptionMapping, ex); - if (depth >= 0 && depth < deepest) { - deepest = depth; - definitionText = exceptionMappings.get(exceptionMapping); - } - } - if (definitionText != null) { - SoapFaultDefinitionEditor editor = new SoapFaultDefinitionEditor(); - editor.setAsText(definitionText); - return (SoapFaultDefinition) editor.getValue(); - } - } - return null; - } - - /** - * Return the depth to the superclass matching. {@code 0} means ex matches exactly. Returns {@code -1} if - * there's no match. Otherwise, returns depth. Lowest depth wins. - * - *

Follows the same algorithm as RollbackRuleAttribute, and SimpleMappingExceptionResolver - */ - protected int getDepth(String exceptionMapping, Exception ex) { - return getDepth(exceptionMapping, ex.getClass(), 0); - } - - @SuppressWarnings("unchecked") - private int getDepth(String exceptionMapping, Class exceptionClass, int depth) { - if (exceptionClass.getName().indexOf(exceptionMapping) != -1) { - return depth; - } - if (exceptionClass.equals(Throwable.class)) { - return -1; - } - return getDepth(exceptionMapping, (Class) exceptionClass.getSuperclass(), depth + 1); - } - - protected void customizeFault(Object endpoint, Exception ex, SoapFault fault) { - GeneralFault customFault = new GeneralFault(); - customFault.setTechnicalError(getStackTrace(ex)); - - Element element = buildElement(ex); - List elements = customFault.getElements(); - elements.add(element); - - SoapFaultDetail detail = fault.addFaultDetail(); - Result result = detail.getResult(); - try { - marshaller.marshal(customFault, result); - } catch (Exception marshallEx) { - LOGGER.error("MyCustomMappingExceptionResolver: marshaller error", marshallEx); - } - } - - public void setMarshaller(Marshaller marshaller) { - this.marshaller = marshaller; - } - - private Element buildElement(Exception ex) { - Element element = new Element(); - element.setMessage(ex.getMessage()); - - if (ex instanceof CustomBusinessException) { - CustomBusinessException customEx = (CustomBusinessException) ex; - List messageArgs = element.getMessageArgs(); - List argumentsEx = customEx.getArguments(); - - for (String argumentEx: argumentsEx) { - messageArgs.add(argumentEx); - } - } - - return element; - } - - private String getStackTrace(Throwable throwable) { - final StringWriter sw = new StringWriter(); - final PrintWriter pw = new PrintWriter(sw, true); - throwable.printStackTrace(pw); - return sw.getBuffer().toString(); - } -} diff --git a/cxf/web-services-spring-cxf-server/src/main/java/de/spring/webservices/exceptions/BusinessException.java b/cxf/web-services-spring-cxf-server/src/main/java/de/spring/webservices/exceptions/BusinessException.java deleted file mode 100644 index f13ae91..0000000 --- a/cxf/web-services-spring-cxf-server/src/main/java/de/spring/webservices/exceptions/BusinessException.java +++ /dev/null @@ -1,22 +0,0 @@ -package de.spring.webservices.exceptions; - -/** - * This exception will be caught by org.springframework.ws.soap.server.endpoint.SoapFaultMappingExceptionResolver - * - */ -public class BusinessException extends RuntimeException { - - private static final long serialVersionUID = -4042139454770293299L; - - public BusinessException() { - super(); - } - - public BusinessException(String message) { - super(message); - } - - public BusinessException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/cxf/web-services-spring-cxf-server/src/main/java/de/spring/webservices/exceptions/CustomBusinessException.java b/cxf/web-services-spring-cxf-server/src/main/java/de/spring/webservices/exceptions/CustomBusinessException.java deleted file mode 100644 index 549c0b9..0000000 --- a/cxf/web-services-spring-cxf-server/src/main/java/de/spring/webservices/exceptions/CustomBusinessException.java +++ /dev/null @@ -1,32 +0,0 @@ -package de.spring.webservices.exceptions; - -import java.util.List; - -/** - * This exception will be caught by de.spring.webservices.endpoints.MyCustomMappingExceptionResolver - * - */ -public class CustomBusinessException extends RuntimeException { - private final List arguments; - - public CustomBusinessException(List arguments) { - super(); - this.arguments = arguments; - } - - public CustomBusinessException(String message, List arguments) { - super(message); - - this.arguments = arguments; - } - - public CustomBusinessException(String message, Throwable cause, List arguments) { - super(message, cause); - - this.arguments = arguments; - } - - public List getArguments() { - return arguments; - } -} diff --git a/cxf/web-services-spring-cxf-server/src/main/java/de/spring/webservices/services/ExampleService.java b/cxf/web-services-spring-cxf-server/src/main/java/de/spring/webservices/services/ExampleService.java deleted file mode 100644 index 881be73..0000000 --- a/cxf/web-services-spring-cxf-server/src/main/java/de/spring/webservices/services/ExampleService.java +++ /dev/null @@ -1,11 +0,0 @@ -package de.spring.webservices.services; - -import de.spring.webservices.server.auto.ExampleRequest; -import de.spring.webservices.server.auto.ExampleResponse; - - -public interface ExampleService { - - public ExampleResponse doResponse(ExampleRequest request); - -} diff --git a/cxf/web-services-spring-cxf-server/src/main/java/de/spring/webservices/services/impl/CustomBindingExampleServiceImpl.java b/cxf/web-services-spring-cxf-server/src/main/java/de/spring/webservices/services/impl/CustomBindingExampleServiceImpl.java deleted file mode 100644 index 0247a3f..0000000 --- a/cxf/web-services-spring-cxf-server/src/main/java/de/spring/webservices/services/impl/CustomBindingExampleServiceImpl.java +++ /dev/null @@ -1,44 +0,0 @@ -package de.spring.webservices.services.impl; - -//import java.util.ArrayList; -//import java.util.List; - -import org.springframework.stereotype.Service; - -import de.spring.webservices.operations.Operations; -import de.spring.webservices.server.auto.CustomBindingExampleRequest; -import de.spring.webservices.server.auto.CustomBindingExampleResponse; -import de.spring.webservices.server.auto.ParentEnumType; -//import de.spring.webservices.exceptions.BusinessException; -//import de.spring.webservices.exceptions.CustomBusinessException; - - -@Service("customBindingExampleService") -public class CustomBindingExampleServiceImpl implements - Operations.RequestResponse { - - - @Override - public CustomBindingExampleResponse requestResponse(final CustomBindingExampleRequest request) { - - - // Example about how works org.springframework.ws.soap.server.endpoint.SoapFaultMappingExceptionResolver - // see soap-ws.xml Spring configuration file. -// throw new BusinessException("This feature has not been implemented yet."); - - // Example about how works de.spring.webservices.endpoints.MyCustomMappingExceptionResolver - // see soap-ws.xml Spring configuration file. -// List arguments = new ArrayList<>(); -// arguments.add("ARGUMENT 1"); -// arguments.add("ARGUMENT 2"); -// throw new CustomBusinessException("This feature has not been implemented yet.", arguments); - - CustomBindingExampleResponse response = new CustomBindingExampleResponse(); - - response.setData("CUSTOM BINDING SNAKE EYES AND " + request.getData()); - response.setParentEnum(ParentEnumType.FIRST); - - return response; - } - -} diff --git a/cxf/web-services-spring-cxf-server/src/main/java/de/spring/webservices/services/impl/ExampleServiceImpl.java b/cxf/web-services-spring-cxf-server/src/main/java/de/spring/webservices/services/impl/ExampleServiceImpl.java deleted file mode 100644 index ec80b60..0000000 --- a/cxf/web-services-spring-cxf-server/src/main/java/de/spring/webservices/services/impl/ExampleServiceImpl.java +++ /dev/null @@ -1,23 +0,0 @@ -package de.spring.webservices.services.impl; - -import org.springframework.stereotype.Service; - -import de.spring.webservices.server.auto.ExampleRequest; -import de.spring.webservices.server.auto.ExampleResponse; -import de.spring.webservices.services.ExampleService; - - -@Service("exampleService") -public class ExampleServiceImpl implements ExampleService { - - @Override - public ExampleResponse doResponse(final ExampleRequest request) { - - ExampleResponse response = new ExampleResponse(); - - response.setData("SNAKE EYES AND " + request.getData()); - - return response; - } - -} diff --git a/cxf/web-services-spring-cxf-server/src/main/jetty/jetty-http.xml b/cxf/web-services-spring-cxf-server/src/main/jetty/jetty-http.xml deleted file mode 100644 index d995630..0000000 --- a/cxf/web-services-spring-cxf-server/src/main/jetty/jetty-http.xml +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - - - - - - - https - - - - 32768 - 8192 - 8192 - true - false - 512 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/cxf/web-services-spring-cxf-server/src/main/resources/examples.xsd b/cxf/web-services-spring-cxf-server/src/main/resources/examples.xsd deleted file mode 100644 index 59cd317..0000000 --- a/cxf/web-services-spring-cxf-server/src/main/resources/examples.xsd +++ /dev/null @@ -1,127 +0,0 @@ - - - - - - - - - - - - - - - - @java.lang.SuppressWarnings({"unchecked","rawtypes"}) - de.spring.webservices.operations.Request - - - - - - - - - - - - de.spring.webservices.operations.Response - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/cxf/web-services-spring-cxf-server/src/main/resources/log4j2.xml b/cxf/web-services-spring-cxf-server/src/main/resources/log4j2.xml deleted file mode 100644 index ea6ded3..0000000 --- a/cxf/web-services-spring-cxf-server/src/main/resources/log4j2.xml +++ /dev/null @@ -1,80 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/cxf/web-services-spring-cxf-server/src/main/resources/spring-configuration/spring-configuration.xml b/cxf/web-services-spring-cxf-server/src/main/resources/spring-configuration/spring-configuration.xml deleted file mode 100644 index 7341c77..0000000 --- a/cxf/web-services-spring-cxf-server/src/main/resources/spring-configuration/spring-configuration.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - diff --git a/cxf/web-services-spring-cxf-server/src/main/resources/spring-configuration/ws/soap-ws.xml b/cxf/web-services-spring-cxf-server/src/main/resources/spring-configuration/ws/soap-ws.xml deleted file mode 100644 index cf3e7d7..0000000 --- a/cxf/web-services-spring-cxf-server/src/main/resources/spring-configuration/ws/soap-ws.xml +++ /dev/null @@ -1,284 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - classpath:parent.xsd - - classpath:examples.xsd - - - - - - - - - - - - - - - - - - SERVER - - - - - - - - - - - - - - - SERVER - - - - - - - - diff --git a/cxf/web-services-spring-cxf-server/src/main/webapp/WEB-INF/web.xml b/cxf/web-services-spring-cxf-server/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index 7e14eba..0000000 --- a/cxf/web-services-spring-cxf-server/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - Spring Web Services: example - - - - org.springframework.web.context.ContextLoaderListener - - - - - spring.profiles.active - ${environment.profile} - contextConfigLocation - - classpath*:spring-configuration/*.xml - - - - - - spring-ws - org.springframework.ws.transport.http.MessageDispatcherServlet - 1 - true - - contextConfigLocation - classpath*:spring-configuration/ws/*.xml - - - transformWsdlLocations - true - - - - - spring-ws - /spring-ws/* - - - diff --git a/cxf/web-services-spring-cxf-server/src/test/java/de/spring/webservices/endpoints/ExampleEndPointIntegrationTest.java b/cxf/web-services-spring-cxf-server/src/test/java/de/spring/webservices/endpoints/ExampleEndPointIntegrationTest.java deleted file mode 100644 index f0204cb..0000000 --- a/cxf/web-services-spring-cxf-server/src/test/java/de/spring/webservices/endpoints/ExampleEndPointIntegrationTest.java +++ /dev/null @@ -1,62 +0,0 @@ -package de.spring.webservices.endpoints; - -import static org.springframework.ws.test.server.RequestCreators.withPayload; -import static org.springframework.ws.test.server.ResponseMatchers.payload; - -import javax.xml.transform.Source; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.ws.test.server.MockWebServiceClient; -import org.springframework.xml.transform.StringSource; - - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = { "classpath*:spring-configuration/ws/soap-ws.xml" } ) -public class ExampleEndPointIntegrationTest { - - @Autowired - private ApplicationContext applicationContext; - - private MockWebServiceClient mockClient; - - @Before - public void createClient() { - mockClient = MockWebServiceClient.createClient(applicationContext); - } - - @Test - public void exampleEndpoint() throws Exception { - final Source requestPayload = new StringSource( - "" + - "SCARLETT" + - ""); - final Source responsePayload = new StringSource( - "" + - "SNAKE EYES AND SCARLETT" + - ""); - mockClient.sendRequest(withPayload(requestPayload)).andExpect( - payload(responsePayload)); - - - final Source customRequestPayload = new StringSource( - "" + - "SCARLETT" + - "2015-06-03T10:20:30Z" + - "FIRST" + - ""); - final Source customResponsePayload = new StringSource( - "" + - "CUSTOM BINDING SNAKE EYES AND SCARLETT" + - "FIRST" + - ""); - mockClient.sendRequest(withPayload(customRequestPayload)).andExpect( - payload(customResponsePayload)); - } -} - diff --git a/cxf/web-services-spring-cxf-server/src/test/java/de/spring/webservices/endpoints/ExampleEndPointTest.java b/cxf/web-services-spring-cxf-server/src/test/java/de/spring/webservices/endpoints/ExampleEndPointTest.java deleted file mode 100644 index a4a279f..0000000 --- a/cxf/web-services-spring-cxf-server/src/test/java/de/spring/webservices/endpoints/ExampleEndPointTest.java +++ /dev/null @@ -1,52 +0,0 @@ -package de.spring.webservices.endpoints; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; - -import org.junit.Before; -import org.junit.Test; - -import de.spring.webservices.operations.Operations; -import de.spring.webservices.server.auto.CustomBindingExampleRequest; -import de.spring.webservices.server.auto.CustomBindingExampleResponse; -import de.spring.webservices.server.auto.ExampleRequest; -import de.spring.webservices.services.ExampleService; - - -public class ExampleEndPointTest { - - private ExampleService exampleService; - - private Operations.RequestResponse - customBindingExampleService; - - private ExampleEndPoint exampleEndPoint; - - @Before - public void init() { - exampleService = mock(ExampleService.class); - customBindingExampleService = mock(Operations.RequestResponse.class); - exampleEndPoint = new ExampleEndPoint(customBindingExampleService, exampleService); - } - - @Test - public void givenExampleRequestThenInvokeExampleService() { - ExampleRequest request = new ExampleRequest(); - request.setData("SCARLETT"); - - exampleEndPoint.exampleResponse(request, null, null); - - verify(exampleService).doResponse(request); - } - - @Test - public void givenCustomBindingExampleRequestThenInvokeCustomBindingExampleService() { - CustomBindingExampleRequest request = new CustomBindingExampleRequest(); - request.setData("SCARLETT"); - - exampleEndPoint.cuntomBindingExampleResponse(request, null, null); - - verify(customBindingExampleService).requestResponse(request); - } - -} diff --git a/cxf/web-services-spring-cxf-server/src/test/java/de/spring/webservices/services/CustomBindingExampleServiceTest.java b/cxf/web-services-spring-cxf-server/src/test/java/de/spring/webservices/services/CustomBindingExampleServiceTest.java deleted file mode 100644 index d3b56be..0000000 --- a/cxf/web-services-spring-cxf-server/src/test/java/de/spring/webservices/services/CustomBindingExampleServiceTest.java +++ /dev/null @@ -1,34 +0,0 @@ -package de.spring.webservices.services; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import de.spring.webservices.operations.Operations; -import de.spring.webservices.server.auto.CustomBindingExampleRequest; -import de.spring.webservices.server.auto.CustomBindingExampleResponse; -import de.spring.webservices.services.impl.CustomBindingExampleServiceImpl; - - -public class CustomBindingExampleServiceTest { - - private Operations.RequestResponse - customBindingExampleService; - - @Before - public void init() { - customBindingExampleService = new CustomBindingExampleServiceImpl(); - } - - @Test - public void givenCustomBindingExampleRequestThenReturnCustomBindingExampleResponse() { - CustomBindingExampleRequest request = new CustomBindingExampleRequest(); - request.setData("SCARLETT"); - CustomBindingExampleResponse expected = new CustomBindingExampleResponse(); - expected.setData("CUSTOM BINDING SNAKE EYES AND " + request.getData()); - - CustomBindingExampleResponse actual = customBindingExampleService.requestResponse(request); - - Assert.assertEquals(expected.getData(), actual.getData()); - } -} diff --git a/cxf/web-services-spring-cxf-server/src/test/java/de/spring/webservices/services/ExampleServiceTest.java b/cxf/web-services-spring-cxf-server/src/test/java/de/spring/webservices/services/ExampleServiceTest.java deleted file mode 100644 index 9f33c5e..0000000 --- a/cxf/web-services-spring-cxf-server/src/test/java/de/spring/webservices/services/ExampleServiceTest.java +++ /dev/null @@ -1,32 +0,0 @@ -package de.spring.webservices.services; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import de.spring.webservices.server.auto.ExampleRequest; -import de.spring.webservices.server.auto.ExampleResponse; -import de.spring.webservices.services.impl.ExampleServiceImpl; - -public class ExampleServiceTest { - - private ExampleService exampleService; - - @Before - public void init() { - exampleService = new ExampleServiceImpl(); - } - - @Test - public void givenExampleRequestThenReturnExampleResponse() { - ExampleRequest request = new ExampleRequest(); - request.setData("SCARLETT"); - ExampleResponse expected = new ExampleResponse(); - expected.setData("SNAKE EYES AND " + request.getData()); - - ExampleResponse actual = exampleService.doResponse(request); - - Assert.assertEquals(expected.getData(), actual.getData()); - } - -} diff --git a/cxf/web-services-spring-cxf/pom.xml b/cxf/web-services-spring-cxf/pom.xml deleted file mode 100644 index 0e33534..0000000 --- a/cxf/web-services-spring-cxf/pom.xml +++ /dev/null @@ -1,240 +0,0 @@ - - 4.0.0 - de.spring.webservices - web-services-spring-cxf - pom - 1.0-SNAPSHOT - web-services-spring-cxf - http://gumartinm.name - Web Services Spring Framework - - Gustavo Martin Morcuende - http://www.gumartinm.name - - - scm:git:http://git.gumartinm.name/SpringWebServicesForFun - http://git.gumartinm.name/SpringWebServicesForFun - - - - UTF-8 - UTF-8 - - 4.0.9.RELEASE - 2.2.1.RELEASE - - - - - release - - release - - - true - - - - - - - - org.apache.logging.log4j - log4j-slf4j-impl - 2.3 - - - - org.apache.logging.log4j - log4j-core - 2.3 - - - - org.slf4j - jcl-over-slf4j - 1.7.12 - - - cglib - cglib - 2.2.2 - - - - - - org.springframework.ws - spring-ws-core - ${spring.ws.version} - - - - commons-logging - commons-logging - - - - - org.springframework.ws - spring-xml - ${spring.ws.version} - - - - commons-logging - commons-logging - - - - - org.jdom - jdom - 2.0.2 - - - - - wsdl4j - wsdl4j - 1.6.3 - - - - - junit - junit - 4.12 - test - - - org.springframework - spring-test - ${spring.version} - test - - - org.springframework.ws - spring-ws-test - ${spring.ws.version} - test - - - - commons-logging - commons-logging - - - - - org.mockito - mockito-core - 2.0.11-beta - test - - - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.18.1 - - - org.apache.maven.plugins - maven-failsafe-plugin - 2.18.1 - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.3 - - 1.8 - 1.8 - ${project.build.sourceEncoding} - - - - org.apache.maven.plugins - maven-resources-plugin - 2.7 - - ${project.build.sourceEncoding} - - - - org.apache.maven.plugins - maven-jar-plugin - 2.4 - - - - ${project.description} - ${project.version} - ${project.organization.name} - ${project.description} - ${project.version} - ${project.organization.name} - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - **/*IntegrationTest.java - - - - - org.apache.maven.plugins - maven-failsafe-plugin - - - - integration-test - verify - - - - - - **/*IntegrationTest.java - - - - - - diff --git a/jaxb2/web-services-spring-jaxb2-client/pom.xml b/jaxb2/web-services-spring-jaxb2-client/pom.xml deleted file mode 100644 index 9bd8253..0000000 --- a/jaxb2/web-services-spring-jaxb2-client/pom.xml +++ /dev/null @@ -1,218 +0,0 @@ - - 4.0.0 - - web-services-spring-jaxb2 - de.spring.webservices - 1.0-SNAPSHOT - - web-services-spring-jaxb2-client - web-services-spring-jaxb2-client - http://gumartinm.name - - - src/main/build-resources/wsdl - ${project.build.directory}/generated-sources/src/main/java - de.spring.webservices.client.auto - src/main/build-resources/bindings - - - - - org.springframework.ws - spring-ws-core - - - org.springframework.ws - spring-xml - - - org.jdom - jdom - - - - - - de.spring.webservices - web-services-spring-jaxb2-globalxsds - ${project.version} - - - - - - wsdl4j - wsdl4j - - - - - junit - junit - test - - - org.springframework - spring-test - test - - - org.springframework.ws - spring-ws-test - test - - - org.mockito - mockito-core - test - - - - - ${project.artifactId} - - - ${basedir}/src/main/resources/ - - **/*.* - - - - - - org.jvnet.jaxb2.maven2 - maven-jaxb2-plugin - 0.13.1 - - - generate-sources-from-xsd - - generate - - generate-sources - - - - - WSDL - ${project.xsd.schemas.source.path} - - *.wsdl - - - - - - - - false - - - ${project.xsd.schemas.target.path} - - - ${project.xsd.schemas.package.name} - - - true - - true - - - ${project.build.sourceEncoding} - - - en - - - true - false - - - false - - true - - true - - -Xinheritance - -Xannotate - - - - org.jvnet.jaxb2_commons - jaxb2-basics - 0.9.5 - - - org.jvnet.jaxb2_commons - jaxb2-basics-annotate - 1.0.2 - - - - - true - - - - - false - src/main/build-resources/catalogs/catalog.cat - - - de.spring.webservices - web-services-spring-jaxb2-globalxsds - - - - - - - diff --git a/jaxb2/web-services-spring-jaxb2-client/src/main/build-resources/catalogs/catalog.cat b/jaxb2/web-services-spring-jaxb2-client/src/main/build-resources/catalogs/catalog.cat deleted file mode 100644 index 113acd0..0000000 --- a/jaxb2/web-services-spring-jaxb2-client/src/main/build-resources/catalogs/catalog.cat +++ /dev/null @@ -1,12 +0,0 @@ - - -REWRITE_SYSTEM "http://gumartinm.name/spring-ws/parent/parent.xsd" "maven:de.spring.webservices:web-services-spring-jaxb2-globalxsds:jar::!/schemas/parent.xsd" - --- - This configuration is better (it relies on namespace instead of schemaLocation) but it doesn't work - because of this bug: https://java.net/jira/browse/JAXB-942 - - PUBLIC "xmlns:parent" "maven:de.spring.webservices:web-services-spring-jaxb2-globalxsds:jar::!/schemas/parent.xsd" - --- - diff --git a/jaxb2/web-services-spring-jaxb2-client/src/main/build-resources/wsdl/example.wsdl b/jaxb2/web-services-spring-jaxb2-client/src/main/build-resources/wsdl/example.wsdl deleted file mode 100644 index 202d87b..0000000 --- a/jaxb2/web-services-spring-jaxb2-client/src/main/build-resources/wsdl/example.wsdl +++ /dev/null @@ -1,194 +0,0 @@ - - - - - - - - - - - - - - - - - @java.lang.SuppressWarnings({"unchecked","rawtypes"}) - de.spring.webservices.operations.Request - - - - - - - - - - - - de.spring.webservices.operations.Response - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/jaxb2/web-services-spring-jaxb2-client/src/main/java/de/spring/webservices/client/CustomFaultMessageResolver.java b/jaxb2/web-services-spring-jaxb2-client/src/main/java/de/spring/webservices/client/CustomFaultMessageResolver.java deleted file mode 100644 index 9fdea6b..0000000 --- a/jaxb2/web-services-spring-jaxb2-client/src/main/java/de/spring/webservices/client/CustomFaultMessageResolver.java +++ /dev/null @@ -1,83 +0,0 @@ -package de.spring.webservices.client; - -import java.io.IOException; -import java.util.Iterator; - -import javax.xml.transform.Source; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.oxm.Unmarshaller; -import org.springframework.oxm.XmlMappingException; -import org.springframework.ws.WebServiceMessage; -import org.springframework.ws.client.core.FaultMessageResolver; -import org.springframework.ws.soap.SoapBody; -import org.springframework.ws.soap.SoapFault; -import org.springframework.ws.soap.SoapFaultDetail; -import org.springframework.ws.soap.SoapFaultDetailElement; -import org.springframework.ws.soap.SoapMessage; -import org.springframework.ws.soap.client.core.SoapFaultMessageResolver; - -// maven-jaxb2-plugin for WSDL DOES generate again the objects in web-services-spring-jaxb2-globalxsds :( -// So I guess it is better to use the objects generated in this package -// than the ones from globalxsds even if they should be the same. -import de.spring.webservices.client.auto.GeneralFault; - -/** - * Enables us to log custom Fault remote messages. - * - */ -public class CustomFaultMessageResolver implements FaultMessageResolver { - -private static final Logger LOGGER = LoggerFactory.getLogger(CustomFaultMessageResolver.class); - - private final FaultMessageResolver defaultMessageResolver = new SoapFaultMessageResolver(); - - private Unmarshaller unmarshaller; - - @Override - public void resolveFault(WebServiceMessage message) throws IOException { - - // Same behavior as default message resolver (SoapFaultMessageResolver) but this implementation also - // logs error information. - if (LOGGER.isErrorEnabled()) { - try { - logErrorInformation(message); - } catch (Exception ex) { - LOGGER.error("CustomFaultMessageResolver exception:", ex); - } - } - - defaultMessageResolver.resolveFault(message); - } - - private void logErrorInformation(WebServiceMessage message) throws XmlMappingException, IOException { - SoapMessage soapMessage = (SoapMessage) message; - SoapBody body = soapMessage.getSoapBody(); - SoapFault soapFault = body != null ? body.getFault() : null; - SoapFaultDetail detail = soapFault != null ? soapFault.getFaultDetail() : null; - - if (detail != null) { - Iterator iterator = detail.getDetailEntries(); - while (iterator.hasNext()) { - SoapFaultDetailElement bodyElement = iterator.next(); - Source detailSource = bodyElement.getSource(); - // TODO: How to check if I am receiving GeneralFault before trying to unmarshal? - // Right now there will be exception if unmarshal doesn't return a GeneralFault object. - GeneralFault error = (GeneralFault)this.unmarshaller.unmarshal(detailSource); - LOGGER.error("TECHNICALERROR:"); - LOGGER.error(error.getTechnicalError()); - LOGGER.error("ELEMENTS:"); - error.getElements().forEach(element -> { - LOGGER.error("MESSAGE: " + element.getMessage()); - LOGGER.error("MESSAGEARGS:"); - element.getMessageArgs().forEach(messageArg -> LOGGER.error(messageArg)); - }); - } - } - } - - public void setUnmarshaller(Unmarshaller unmarshaller) { - this.unmarshaller = unmarshaller; - } -} diff --git a/jaxb2/web-services-spring-jaxb2-client/src/main/java/de/spring/webservices/client/ExampleClientService.java b/jaxb2/web-services-spring-jaxb2-client/src/main/java/de/spring/webservices/client/ExampleClientService.java deleted file mode 100644 index f8bad46..0000000 --- a/jaxb2/web-services-spring-jaxb2-client/src/main/java/de/spring/webservices/client/ExampleClientService.java +++ /dev/null @@ -1,75 +0,0 @@ -package de.spring.webservices.client; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.ws.client.core.WebServiceTemplate; - -import de.spring.webservices.client.auto.CustomBindingExampleRequest; -import de.spring.webservices.client.auto.CustomBindingExampleResponse; -import de.spring.webservices.client.auto.ExampleRequest; -import de.spring.webservices.client.auto.ExampleResponse; -//import de.spring.webservices.client.auto.Examples; -//import de.spring.webservices.client.auto.ExamplesService; -//import de.spring.webservices.client.auto.ParentEnumType; - -/** - * Someone could write code like this one in order to send and receive - * information from our Web Services. - * - */ -@Service("exampleClientService") -public class ExampleClientService { - private final WebServiceTemplate webServiceTemplate; - - @Autowired - public ExampleClientService(WebServiceTemplate webServiceTemplate) { - this.webServiceTemplate = webServiceTemplate; - } - -// maven-jaxb2-plugin DOESN'T CREATE @WebService, @WebServiceClient y @WebEndpoint -// public ExampleResponse sendAndReceiveJava() { -// final ExampleRequest exampleRequest = new ExampleRequest(); -// exampleRequest.setData("SCARLETT JAVA. IT IS CANON."); -// -// final Examples exampleService = new ExamplesService().getExamplesSoap12(); -// final ExampleResponse exampleResponse = exampleService.example(exampleRequest); -// -// return exampleResponse; -// } - - public ExampleResponse sendAndReceiveSpring() { - final ExampleRequest exampleRequest = new ExampleRequest(); - exampleRequest.setData("SCARLETT SPRING. IT IS CANON."); - - final ExampleResponse exampleResponse = (ExampleResponse) - this.webServiceTemplate.marshalSendAndReceive(exampleRequest); - - return exampleResponse; - } - -// maven-jaxb2-plugin DOESN'T CREATE @WebService, @WebServiceClient y @WebEndpoint -// public CustomBindingExampleResponse sendAndReceiveJavaCustom() { -// final CustomBindingExampleRequest customBindingxampleRequest = -// new CustomBindingExampleRequest(); -// customBindingxampleRequest.setData("CUSTOM BINDING JAVA. SCARLETT. IT IS CANON."); -// customBindingxampleRequest.setParentEnum(ParentEnumType.FIRST); -// -// final Examples exampleService = new ExamplesService().getExamplesSoap12(); -// final CustomBindingExampleResponse customBindingExampleResponse = -// exampleService.customBindingExample(customBindingxampleRequest); -// -// return customBindingExampleResponse; -// } - - public CustomBindingExampleResponse sendAndReceiveSpringCustom() { - final CustomBindingExampleRequest customBindingxampleRequest = - new CustomBindingExampleRequest(); - customBindingxampleRequest.setData("CUSTOM BINDING SPRING. SCARLETT. IT IS CANON."); - - final CustomBindingExampleResponse customBindingExampleResponse = - (CustomBindingExampleResponse) this.webServiceTemplate - .marshalSendAndReceive(customBindingxampleRequest); - - return customBindingExampleResponse; - } -} diff --git a/jaxb2/web-services-spring-jaxb2-client/src/main/java/de/spring/webservices/client/MainTest.java b/jaxb2/web-services-spring-jaxb2-client/src/main/java/de/spring/webservices/client/MainTest.java deleted file mode 100644 index 92b1638..0000000 --- a/jaxb2/web-services-spring-jaxb2-client/src/main/java/de/spring/webservices/client/MainTest.java +++ /dev/null @@ -1,53 +0,0 @@ -package de.spring.webservices.client; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.context.ApplicationContext; -import org.springframework.context.support.ClassPathXmlApplicationContext; - -import de.spring.webservices.client.auto.CustomBindingExampleResponse; -import de.spring.webservices.client.auto.ExampleResponse; - -/** - * This class is used just like a nice example about how to write and run client - * code which will send data to and from the Web Services. - * - */ -public class MainTest { - private static final Logger LOGGER = LoggerFactory.getLogger(MainTest.class); - - public ApplicationContext context; - - /** - * @param args - */ - public static void main(final String[] args) { - final MainTest test = new MainTest(); - - test.context = new ClassPathXmlApplicationContext( - "classpath:spring-configuration/ws/client-spring-configuration.xml"); - - final ExampleClientService example = - (ExampleClientService) test.context.getBean("exampleClientService"); - -// maven-jaxb2-plugin DOESN'T CREATE @WebService, @WebServiceClient y @WebEndpoint -// logger.info("ExampleResponse Java:"); -// ExampleResponse response = example.sendAndReceiveJava(); -// logger.info(response.getData()); - - -// logger.info("CustomBindingExampleResponse Java:"); -// CustomBindingExampleResponse customBindingResponse = example.sendAndReceiveJavaCustom(); -// logger.info(customBindingResponse.getData()); - - - LOGGER.info("ExampleResponse Spring:"); - ExampleResponse response = example.sendAndReceiveSpring(); - LOGGER.info(response.getData()); - - - LOGGER.info("CustomBindingExampleResponse Spring:"); - CustomBindingExampleResponse customBindingResponse = example.sendAndReceiveSpringCustom(); - LOGGER.info(customBindingResponse.getData()); - } -} diff --git a/jaxb2/web-services-spring-jaxb2-client/src/main/java/de/spring/webservices/client/transport/http/CustomHttpRequestMessageSender.java b/jaxb2/web-services-spring-jaxb2-client/src/main/java/de/spring/webservices/client/transport/http/CustomHttpRequestMessageSender.java deleted file mode 100644 index cf44220..0000000 --- a/jaxb2/web-services-spring-jaxb2-client/src/main/java/de/spring/webservices/client/transport/http/CustomHttpRequestMessageSender.java +++ /dev/null @@ -1,57 +0,0 @@ -package de.spring.webservices.client.transport.http; - -import java.io.IOException; -import java.net.URI; - -import org.springframework.http.HttpMethod; -import org.springframework.http.client.ClientHttpRequest; -import org.springframework.http.client.ClientHttpRequestFactory; -import org.springframework.http.client.SimpleClientHttpRequestFactory; -import org.springframework.ws.transport.WebServiceConnection; -import org.springframework.ws.transport.http.AbstractHttpWebServiceMessageSender; -import org.springframework.ws.transport.http.ClientHttpRequestConnection; -import org.springframework.ws.transport.http.HttpTransportConstants; - - -/** - * Based on ClientHttpRequestMessageSender from the Spring WS framework. - * - *

- * Spring WS framework also provides implementations based on the HTTP clients by Jakarta and Apache HttpClient: - * {@link https://hc.apache.org/httpcomponents-client-ga/} and {@link http://hc.apache.org/httpclient-3.x/} - *

- * - *

- * Four implementations for four HTTP clients: - *

    - *
  • org.springframework.ws.transport.http.ClientHttpRequestMessageSender (ClientHttpRequestFactory from the Spring framework)
  • - *
  • org.springframework.ws.transport.http.CommonsHttpMessageSender (Jakarta implementation)
  • - *
  • org.springframework.ws.transport.http.HttpComponentsMessageSender (Apache HttpClient)
  • - *
  • org.springframework.ws.transport.http.HttpUrlConnectionMessageSender - * (org.springframework.ws.transport.http.HttpUrlConnection internal Spring framework implementation)
  • - *
- *

- */ -public class CustomHttpRequestMessageSender extends AbstractHttpWebServiceMessageSender { - private static final String MY_CUSTOM_HEADER = "MY_CUSTOM_HEADER"; - - private final ClientHttpRequestFactory requestFactory; - - public CustomHttpRequestMessageSender() { - requestFactory = new SimpleClientHttpRequestFactory(); - } - - @Override - public WebServiceConnection createConnection(URI uri) throws IOException { - ClientHttpRequest request = requestFactory.createRequest(uri, HttpMethod.POST); - if (isAcceptGzipEncoding()) { - request.getHeaders().add(HttpTransportConstants.HEADER_ACCEPT_ENCODING, - HttpTransportConstants.CONTENT_ENCODING_GZIP); - } - - request.getHeaders().add(MY_CUSTOM_HEADER, "gumartinm.name"); - - return new ClientHttpRequestConnection(request); - } - -} diff --git a/jaxb2/web-services-spring-jaxb2-client/src/main/resources/log4j2.xml b/jaxb2/web-services-spring-jaxb2-client/src/main/resources/log4j2.xml deleted file mode 100644 index 5d47d57..0000000 --- a/jaxb2/web-services-spring-jaxb2-client/src/main/resources/log4j2.xml +++ /dev/null @@ -1,85 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/jaxb2/web-services-spring-jaxb2-client/src/main/resources/schemas/examples.xsd b/jaxb2/web-services-spring-jaxb2-client/src/main/resources/schemas/examples.xsd deleted file mode 100644 index 59cd317..0000000 --- a/jaxb2/web-services-spring-jaxb2-client/src/main/resources/schemas/examples.xsd +++ /dev/null @@ -1,127 +0,0 @@ - - - - - - - - - - - - - - - - @java.lang.SuppressWarnings({"unchecked","rawtypes"}) - de.spring.webservices.operations.Request - - - - - - - - - - - - de.spring.webservices.operations.Response - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/jaxb2/web-services-spring-jaxb2-client/src/main/resources/spring-configuration/ws/client-spring-configuration.xml b/jaxb2/web-services-spring-jaxb2-client/src/main/resources/spring-configuration/ws/client-spring-configuration.xml deleted file mode 100644 index 9358079..0000000 --- a/jaxb2/web-services-spring-jaxb2-client/src/main/resources/spring-configuration/ws/client-spring-configuration.xml +++ /dev/null @@ -1,177 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - classpath:schemas/parent.xsd - - classpath:schemas/examples.xsd - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/jaxb2/web-services-spring-jaxb2-client/src/test/java/de/spring/webservices/client/ExampleClientServiceIntegrationTest.java b/jaxb2/web-services-spring-jaxb2-client/src/test/java/de/spring/webservices/client/ExampleClientServiceIntegrationTest.java deleted file mode 100644 index 4877a5d..0000000 --- a/jaxb2/web-services-spring-jaxb2-client/src/test/java/de/spring/webservices/client/ExampleClientServiceIntegrationTest.java +++ /dev/null @@ -1,78 +0,0 @@ -package de.spring.webservices.client; - -import static org.junit.Assert.assertEquals; -import static org.springframework.ws.test.client.RequestMatchers.payload; -import static org.springframework.ws.test.client.ResponseCreators.withPayload; - -import javax.xml.transform.Source; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.ws.client.core.WebServiceTemplate; -import org.springframework.ws.test.client.MockWebServiceServer; -import org.springframework.xml.transform.StringSource; - -import de.spring.webservices.client.auto.CustomBindingExampleResponse; -import de.spring.webservices.client.auto.ExampleResponse; - - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration("classpath*:spring-configuration/ws/client-spring-configuration.xml") -public class ExampleClientServiceIntegrationTest { - - @Autowired - ExampleClientService exampleClientService; - - @Autowired - private WebServiceTemplate webServiceTemplate; - - private MockWebServiceServer mockServer; - - @Before - public void createServer() throws Exception { - mockServer = MockWebServiceServer.createServer(webServiceTemplate); - } - - @Test - public void customerClient() throws Exception { - final Source requestPayload = new StringSource( - "" - + "SCARLETT SPRING. IT IS CANON." - + ""); - final Source responsePayload = new StringSource( - "" - + "SNAKE EYES AND SCARLETT SPRING. IT IS CANON." - + ""); - mockServer.expect(payload(requestPayload)).andRespond( - withPayload(responsePayload)); - - final ExampleResponse response = exampleClientService.sendAndReceiveSpring(); - - assertEquals(response.getData(), "SNAKE EYES AND SCARLETT SPRING. IT IS CANON."); - mockServer.verify(); - } - - @Test - public void customerCustomClient() throws Exception { - final Source customRequestPayload = new StringSource( - "" + - "CUSTOM BINDING SPRING. SCARLETT. IT IS CANON." + - ""); - final Source customResponsePayload = new StringSource( - "" + - "CUSTOM BINDING SNAKE EYES AND SCARLETT SPRING. IT IS CANON." + - ""); - mockServer.expect(payload(customRequestPayload)).andRespond( - withPayload(customResponsePayload)); - - final CustomBindingExampleResponse response = exampleClientService.sendAndReceiveSpringCustom(); - - assertEquals(response.getData(), "CUSTOM BINDING SNAKE EYES AND SCARLETT SPRING. IT IS CANON."); - mockServer.verify(); - } -} - diff --git a/jaxb2/web-services-spring-jaxb2-globalxsds/pom.xml b/jaxb2/web-services-spring-jaxb2-globalxsds/pom.xml deleted file mode 100644 index 35278a9..0000000 --- a/jaxb2/web-services-spring-jaxb2-globalxsds/pom.xml +++ /dev/null @@ -1,102 +0,0 @@ - - 4.0.0 - - web-services-spring-jaxb2 - de.spring.webservices - 1.0-SNAPSHOT - - web-services-spring-jaxb2-globalxsds - web-services-spring-jaxb2-globalxsds - http://gumartinm.name - - - src/main/resources/schemas - ${project.build.directory}/generated-sources/src/main/java - de.spring.webservices.parent.auto - src/main/build-resources/bindings - - - - - - - junit - junit - test - - - - - ${project.artifactId} - - - ${basedir}/src/main/resources - - **/*.* - - - - - - org.jvnet.jaxb2.maven2 - maven-jaxb2-plugin - 0.13.1 - - - generate-sources-from-xsd - - generate - - generate-sources - - - - - ${project.xsd.schemas.source.path} - - - ${project.bindings.path} - - false - - - ${project.xsd.schemas.target.path} - - - ${project.xsd.schemas.package.name} - - - true - - true - - - ${project.build.sourceEncoding} - - - en - - - true - false - - - true - - true - - - - - diff --git a/jaxb2/web-services-spring-jaxb2-globalxsds/src/main/build-resources/bindings/custombinding.xjb b/jaxb2/web-services-spring-jaxb2-globalxsds/src/main/build-resources/bindings/custombinding.xjb deleted file mode 100644 index 8b4a110..0000000 --- a/jaxb2/web-services-spring-jaxb2-globalxsds/src/main/build-resources/bindings/custombinding.xjb +++ /dev/null @@ -1,8 +0,0 @@ - - - - - diff --git a/jaxb2/web-services-spring-jaxb2-globalxsds/src/main/java/de/spring/webservices/binders/XSDateTimeCustomBinder.java b/jaxb2/web-services-spring-jaxb2-globalxsds/src/main/java/de/spring/webservices/binders/XSDateTimeCustomBinder.java deleted file mode 100644 index f39921a..0000000 --- a/jaxb2/web-services-spring-jaxb2-globalxsds/src/main/java/de/spring/webservices/binders/XSDateTimeCustomBinder.java +++ /dev/null @@ -1,35 +0,0 @@ -package de.spring.webservices.binders; - -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.TimeZone; - -import javax.xml.bind.annotation.adapters.XmlAdapter; - - -/** - * ATTENTION: if you are using this custombinder you will have to create custom payload - * validators for Spring (AS FAR AS I KNOW) - * - */ -public class XSDateTimeCustomBinder extends XmlAdapter { - - @Override - public Date unmarshal(final String dateTime) throws Exception { - // X pattern just works from Java >= 1.7 - final DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssX"); - formatter.setTimeZone(TimeZone.getTimeZone("Europe/Madrid")); - - return formatter.parse(dateTime); - } - - @Override - public String marshal(final Date dateTime) throws Exception { - // X pattern just works from Java >= 1.7 - final DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssX"); - formatter.setTimeZone(TimeZone.getTimeZone("Europe/Madrid")); - - return formatter.format(dateTime); - } -} diff --git a/jaxb2/web-services-spring-jaxb2-globalxsds/src/main/java/de/spring/webservices/operations/Operations.java b/jaxb2/web-services-spring-jaxb2-globalxsds/src/main/java/de/spring/webservices/operations/Operations.java deleted file mode 100644 index 13b5113..0000000 --- a/jaxb2/web-services-spring-jaxb2-globalxsds/src/main/java/de/spring/webservices/operations/Operations.java +++ /dev/null @@ -1,111 +0,0 @@ -package de.spring.webservices.operations; - -/** - *

- * Operations: WSDL v1.1 and v2.0 - *

- * See: http://www.w3.org/TR/wsdl#_porttypes
- * See: - * http://www.w3.org/TR/2007/REC-wsdl20-adjuncts-20070626/#patterns - * - */ -public interface Operations { - - /** - *

- * Request-response operation WSDL v1.1 - *

- * See: http://www.w3.org - * /TR/wsdl#_request-response - * - * @param - * Describes {@link Response} - * @param - * Describes {@link Request} - */ - public static interface RequestResponse { - T requestResponse(E request); - } - - /** - *

- * One-way operation WSDL v1.1 - *

- * See: http://www.w3.org/TR/wsdl - * #_one-way - * - * @param - * Describes {@link Response} - * @param - * Describes {@link Request} - */ - public interface OneWay { - void oneWay(E request); - } - - /** - *

- * Notification operation WSDL v1.1 - *

- * See: http://www.w3.org/TR - * /wsdl#_notification - * - * @param - * Describes {@link Response} - * @param - * Describes {@link Request} - */ - public interface Notification { - T notification(); - } - - /** - *

- * In-Only message exchange pattern WSDL 2.0 - *

- * See: - * http://www.w3.org/TR/2007/REC-wsdl20-adjuncts-20070626/#patterns - * - * @param - * Describes {@link Request} - */ - public interface InOnly { - void inOnly(E request); - } - - /** - *

- * Robust In-Only message exchange pattern WSDL 2.0 - *

- * See: - * http://www.w3.org/TR/2007/REC-wsdl20-adjuncts-20070626/#patterns - * - * @param - * Describes {@link Request} - */ - public interface RobustInOnly { - void robustInOnly(E request); - } - - /** - *

- * In-Out message exchange pattern WSDL 2.0 - *

- * See: - * http://www.w3.org/TR/2007/REC-wsdl20-adjuncts-20070626/#patterns - * - * @param - * Describes {@link Response} - * @param - * Describes {@link Request} - */ - public interface InOut { - T inOut(E request); - } -} \ No newline at end of file diff --git a/jaxb2/web-services-spring-jaxb2-globalxsds/src/main/java/de/spring/webservices/operations/Request.java b/jaxb2/web-services-spring-jaxb2-globalxsds/src/main/java/de/spring/webservices/operations/Request.java deleted file mode 100644 index 77d81f4..0000000 --- a/jaxb2/web-services-spring-jaxb2-globalxsds/src/main/java/de/spring/webservices/operations/Request.java +++ /dev/null @@ -1,5 +0,0 @@ -package de.spring.webservices.operations; - -public interface Request { - -} diff --git a/jaxb2/web-services-spring-jaxb2-globalxsds/src/main/java/de/spring/webservices/operations/Response.java b/jaxb2/web-services-spring-jaxb2-globalxsds/src/main/java/de/spring/webservices/operations/Response.java deleted file mode 100644 index 3a2cbea..0000000 --- a/jaxb2/web-services-spring-jaxb2-globalxsds/src/main/java/de/spring/webservices/operations/Response.java +++ /dev/null @@ -1,5 +0,0 @@ -package de.spring.webservices.operations; - -public interface Response { - -} diff --git a/jaxb2/web-services-spring-jaxb2-globalxsds/src/main/resources/schemas/parent.xsd b/jaxb2/web-services-spring-jaxb2-globalxsds/src/main/resources/schemas/parent.xsd deleted file mode 100644 index b38ca36..0000000 --- a/jaxb2/web-services-spring-jaxb2-globalxsds/src/main/resources/schemas/parent.xsd +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/jaxb2/web-services-spring-jaxb2-server/pom.xml b/jaxb2/web-services-spring-jaxb2-server/pom.xml deleted file mode 100644 index a969b08..0000000 --- a/jaxb2/web-services-spring-jaxb2-server/pom.xml +++ /dev/null @@ -1,240 +0,0 @@ - - 4.0.0 - - web-services-spring-jaxb2 - de.spring.webservices - 1.0-SNAPSHOT - - web-services-spring-jaxb2-server - war - web-services-spring-jaxb2-server - http://gumartinm.name - - - 9.3.0.RC0 - src/main/resources/schemas - ${project.build.directory}/generated-sources/src/main/java - de.spring.webservices.server.auto - src/main/build-resources/bindings - - - - - org.springframework.ws - spring-ws-core - - - org.springframework.ws - spring-xml - - - org.jdom - jdom - - - - - - de.spring.webservices - web-services-spring-jaxb2-globalxsds - ${project.version} - - - - - - wsdl4j - wsdl4j - - - - - javax.servlet - javax.servlet-api - 4.0.0-b01 - provided - - - - - junit - junit - test - - - org.springframework - spring-test - test - - - org.springframework.ws - spring-ws-test - test - - - org.mockito - mockito-core - test - - - - - ${project.artifactId} - - - ${basedir}/src/main/webapp - - **/*.* - - - - ${basedir}/src/main/resources/ - - **/*.* - - - - - - org.jvnet.jaxb2.maven2 - maven-jaxb2-plugin - 0.13.1 - - - generate-sources-from-xsd - - generate - - generate-sources - - - - XMLSCHEMA - - - ${project.xsd.schemas.source.path} - - - ${project.bindings.path} - - false - - - ${project.xsd.schemas.target.path} - - - ${project.xsd.schemas.package.name} - - - true - - true - - - ${project.build.sourceEncoding} - - - en - - - true - false - - - false - - true - - true - - -Xinheritance - -Xannotate - - - - org.jvnet.jaxb2_commons - jaxb2-basics - 0.9.5 - - - org.jvnet.jaxb2_commons - jaxb2-basics-annotate - 1.0.2 - - - - - true - - - - - false - src/main/build-resources/catalogs/catalog.cat - - - de.spring.webservices - web-services-spring-jaxb2-globalxsds - - - - - - org.apache.maven.plugins - maven-war-plugin - 2.6 - - - - true - src/main/webapp - - WEB-INF/web.xml - - - - - - - org.eclipse.jetty - jetty-maven-plugin - ${jetty.version} - - ${basedir}/src/main/jetty/jetty-http.xml - - - - - diff --git a/jaxb2/web-services-spring-jaxb2-server/src/main/build-resources/bindings/custombinding.xjb b/jaxb2/web-services-spring-jaxb2-server/src/main/build-resources/bindings/custombinding.xjb deleted file mode 100644 index a7164c0..0000000 --- a/jaxb2/web-services-spring-jaxb2-server/src/main/build-resources/bindings/custombinding.xjb +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - - de.spring.webservices.operations.Request - @java.lang.SuppressWarnings({"unchecked","rawtypes"}) - - - - - - - de.spring.webservices.operations.Response - @java.lang.SuppressWarnings({"unchecked","rawtypes"}) - - - - - - - - - - - diff --git a/jaxb2/web-services-spring-jaxb2-server/src/main/build-resources/catalogs/catalog.cat b/jaxb2/web-services-spring-jaxb2-server/src/main/build-resources/catalogs/catalog.cat deleted file mode 100644 index 113acd0..0000000 --- a/jaxb2/web-services-spring-jaxb2-server/src/main/build-resources/catalogs/catalog.cat +++ /dev/null @@ -1,12 +0,0 @@ - - -REWRITE_SYSTEM "http://gumartinm.name/spring-ws/parent/parent.xsd" "maven:de.spring.webservices:web-services-spring-jaxb2-globalxsds:jar::!/schemas/parent.xsd" - --- - This configuration is better (it relies on namespace instead of schemaLocation) but it doesn't work - because of this bug: https://java.net/jira/browse/JAXB-942 - - PUBLIC "xmlns:parent" "maven:de.spring.webservices:web-services-spring-jaxb2-globalxsds:jar::!/schemas/parent.xsd" - --- - diff --git a/jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/endpoints/CustomHeaderInterceptor.java b/jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/endpoints/CustomHeaderInterceptor.java deleted file mode 100644 index e1d5302..0000000 --- a/jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/endpoints/CustomHeaderInterceptor.java +++ /dev/null @@ -1,50 +0,0 @@ -package de.spring.webservices.endpoints; - -import javax.servlet.http.HttpServletRequest; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.util.StringUtils; -import org.springframework.ws.context.MessageContext; -import org.springframework.ws.server.EndpointInterceptor; -import org.springframework.ws.transport.context.TransportContext; -import org.springframework.ws.transport.context.TransportContextHolder; -import org.springframework.ws.transport.http.HttpServletConnection; - -public class CustomHeaderInterceptor implements EndpointInterceptor { - private static final Logger LOGGER = LoggerFactory.getLogger(CustomHeaderInterceptor.class); - private static final String MY_CUSTOM_HEADER = "MY_CUSTOM_HEADER"; - - @Override - public boolean handleRequest(MessageContext messageContext, Object endpoint) throws Exception { - TransportContext transport = TransportContextHolder.getTransportContext(); - - if (transport != null) { - HttpServletConnection connection = (HttpServletConnection) transport.getConnection(); - HttpServletRequest headers = connection.getHttpServletRequest(); - String headerValue = headers.getHeader(MY_CUSTOM_HEADER); - - if (!StringUtils.isEmpty(headerValue)) { - LOGGER.info("Custom header value: " + headerValue); - } - } - - return true; - } - - @Override - public boolean handleResponse(MessageContext messageContext, Object endpoint) throws Exception { - return true; - } - - @Override - public boolean handleFault(MessageContext messageContext, Object endpoint) throws Exception { - return true; - } - - @Override - public void afterCompletion(MessageContext messageContext, Object endpoint, Exception ex) throws Exception { - - } - -} diff --git a/jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/endpoints/ExampleEndPoint.java b/jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/endpoints/ExampleEndPoint.java deleted file mode 100644 index e3e8da6..0000000 --- a/jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/endpoints/ExampleEndPoint.java +++ /dev/null @@ -1,57 +0,0 @@ -package de.spring.webservices.endpoints; - -import org.jdom2.Element; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.ws.context.MessageContext; -import org.springframework.ws.server.endpoint.annotation.Endpoint; -import org.springframework.ws.server.endpoint.annotation.PayloadRoot; -import org.springframework.ws.server.endpoint.annotation.RequestPayload; -import org.springframework.ws.server.endpoint.annotation.ResponsePayload; - -import de.spring.webservices.operations.Operations; -import de.spring.webservices.operations.Operations.RequestResponse; -import de.spring.webservices.server.auto.CustomBindingExampleRequest; -import de.spring.webservices.server.auto.CustomBindingExampleResponse; -import de.spring.webservices.server.auto.ExampleRequest; -import de.spring.webservices.server.auto.ExampleResponse; -import de.spring.webservices.services.ExampleService; - - -@Endpoint -public class ExampleEndPoint { - private static final String NAMESPACE_URI = "http://gumartinm.name/spring-ws/example"; - - private final Operations.RequestResponse - customBindingExampleService; - - private final ExampleService exampleService; - - @Autowired - public ExampleEndPoint( - RequestResponse customBindingExampleService, - ExampleService exampleService) { - this.customBindingExampleService = customBindingExampleService; - this.exampleService = exampleService; - } - - @PayloadRoot(localPart = "ExampleRequest", namespace = NAMESPACE_URI) - @ResponsePayload - public ExampleResponse exampleResponse( - @RequestPayload final ExampleRequest request, - @RequestPayload final Element element, - final MessageContext messageContext) { - - return this.exampleService.doResponse(request); - } - - @PayloadRoot(localPart = "CustomBindingExampleRequest", namespace = NAMESPACE_URI) - @ResponsePayload - public CustomBindingExampleResponse cuntomBindingExampleResponse( - @RequestPayload final CustomBindingExampleRequest requestObject, - @RequestPayload final Element element, - final MessageContext messageContext) { - - return this.customBindingExampleService.requestResponse(requestObject); - } -} - diff --git a/jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/endpoints/MyCustomMappingExceptionResolver.java b/jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/endpoints/MyCustomMappingExceptionResolver.java deleted file mode 100644 index 382cd74..0000000 --- a/jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/endpoints/MyCustomMappingExceptionResolver.java +++ /dev/null @@ -1,140 +0,0 @@ -package de.spring.webservices.endpoints; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Properties; - -import javax.xml.transform.Result; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.oxm.Marshaller; -import org.springframework.util.CollectionUtils; -import org.springframework.ws.soap.SoapFault; -import org.springframework.ws.soap.SoapFaultDetail; -import org.springframework.ws.soap.server.endpoint.AbstractSoapFaultDefinitionExceptionResolver; -import org.springframework.ws.soap.server.endpoint.SoapFaultDefinition; -import org.springframework.ws.soap.server.endpoint.SoapFaultDefinitionEditor; - -import de.spring.webservices.exceptions.CustomBusinessException; -import de.spring.webservices.parent.auto.Element; -import de.spring.webservices.parent.auto.GeneralFault; - -public class MyCustomMappingExceptionResolver extends AbstractSoapFaultDefinitionExceptionResolver { - private static final Logger LOGGER = LoggerFactory.getLogger(MyCustomMappingExceptionResolver.class); - - private Marshaller marshaller; - - private Map exceptionMappings = new LinkedHashMap<>(); - - /** - * Set the mappings between exception class names and SOAP Faults. The exception class name can be a substring, with - * no wildcard support at present. - * - *

The values of the given properties object should use the format described in - * {@code SoapFaultDefinitionEditor}. - * - *

Follows the same matching algorithm as {@code SimpleMappingExceptionResolver}. - * - * @param mappings exception patterns (can also be fully qualified class names) as keys, fault definition texts as - * values - * @see SoapFaultDefinitionEditor - */ - public void setExceptionMappings(Properties mappings) { - for (Map.Entry entry : mappings.entrySet()) { - if (entry.getKey() instanceof String && entry.getValue() instanceof String) { - exceptionMappings.put((String)entry.getKey(), (String)entry.getValue()); - } - } - } - - @Override - protected SoapFaultDefinition getFaultDefinition(Object endpoint, Exception ex) { - if (!CollectionUtils.isEmpty(exceptionMappings)) { - String definitionText = null; - int deepest = Integer.MAX_VALUE; - for (String exceptionMapping : exceptionMappings.keySet()) { - int depth = getDepth(exceptionMapping, ex); - if (depth >= 0 && depth < deepest) { - deepest = depth; - definitionText = exceptionMappings.get(exceptionMapping); - } - } - if (definitionText != null) { - SoapFaultDefinitionEditor editor = new SoapFaultDefinitionEditor(); - editor.setAsText(definitionText); - return (SoapFaultDefinition) editor.getValue(); - } - } - return null; - } - - /** - * Return the depth to the superclass matching. {@code 0} means ex matches exactly. Returns {@code -1} if - * there's no match. Otherwise, returns depth. Lowest depth wins. - * - *

Follows the same algorithm as RollbackRuleAttribute, and SimpleMappingExceptionResolver - */ - protected int getDepth(String exceptionMapping, Exception ex) { - return getDepth(exceptionMapping, ex.getClass(), 0); - } - - @SuppressWarnings("unchecked") - private int getDepth(String exceptionMapping, Class exceptionClass, int depth) { - if (exceptionClass.getName().indexOf(exceptionMapping) != -1) { - return depth; - } - if (exceptionClass.equals(Throwable.class)) { - return -1; - } - return getDepth(exceptionMapping, (Class) exceptionClass.getSuperclass(), depth + 1); - } - - protected void customizeFault(Object endpoint, Exception ex, SoapFault fault) { - GeneralFault customFault = new GeneralFault(); - customFault.setTechnicalError(getStackTrace(ex)); - - Element element = buildElement(ex); - List elements = customFault.getElements(); - elements.add(element); - - SoapFaultDetail detail = fault.addFaultDetail(); - Result result = detail.getResult(); - try { - marshaller.marshal(customFault, result); - } catch (Exception marshallEx) { - LOGGER.error("MyCustomMappingExceptionResolver: marshaller error", marshallEx); - } - } - - public void setMarshaller(Marshaller marshaller) { - this.marshaller = marshaller; - } - - private Element buildElement(Exception ex) { - Element element = new Element(); - element.setMessage(ex.getMessage()); - - if (ex instanceof CustomBusinessException) { - CustomBusinessException customEx = (CustomBusinessException) ex; - List messageArgs = element.getMessageArgs(); - List argumentsEx = customEx.getArguments(); - - for (String argumentEx: argumentsEx) { - messageArgs.add(argumentEx); - } - } - - return element; - } - - private String getStackTrace(Throwable throwable) { - final StringWriter sw = new StringWriter(); - final PrintWriter pw = new PrintWriter(sw, true); - throwable.printStackTrace(pw); - return sw.getBuffer().toString(); - } -} diff --git a/jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/exceptions/BusinessException.java b/jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/exceptions/BusinessException.java deleted file mode 100644 index f13ae91..0000000 --- a/jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/exceptions/BusinessException.java +++ /dev/null @@ -1,22 +0,0 @@ -package de.spring.webservices.exceptions; - -/** - * This exception will be caught by org.springframework.ws.soap.server.endpoint.SoapFaultMappingExceptionResolver - * - */ -public class BusinessException extends RuntimeException { - - private static final long serialVersionUID = -4042139454770293299L; - - public BusinessException() { - super(); - } - - public BusinessException(String message) { - super(message); - } - - public BusinessException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/exceptions/CustomBusinessException.java b/jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/exceptions/CustomBusinessException.java deleted file mode 100644 index 549c0b9..0000000 --- a/jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/exceptions/CustomBusinessException.java +++ /dev/null @@ -1,32 +0,0 @@ -package de.spring.webservices.exceptions; - -import java.util.List; - -/** - * This exception will be caught by de.spring.webservices.endpoints.MyCustomMappingExceptionResolver - * - */ -public class CustomBusinessException extends RuntimeException { - private final List arguments; - - public CustomBusinessException(List arguments) { - super(); - this.arguments = arguments; - } - - public CustomBusinessException(String message, List arguments) { - super(message); - - this.arguments = arguments; - } - - public CustomBusinessException(String message, Throwable cause, List arguments) { - super(message, cause); - - this.arguments = arguments; - } - - public List getArguments() { - return arguments; - } -} diff --git a/jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/services/ExampleService.java b/jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/services/ExampleService.java deleted file mode 100644 index 881be73..0000000 --- a/jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/services/ExampleService.java +++ /dev/null @@ -1,11 +0,0 @@ -package de.spring.webservices.services; - -import de.spring.webservices.server.auto.ExampleRequest; -import de.spring.webservices.server.auto.ExampleResponse; - - -public interface ExampleService { - - public ExampleResponse doResponse(ExampleRequest request); - -} diff --git a/jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/services/impl/CustomBindingExampleServiceImpl.java b/jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/services/impl/CustomBindingExampleServiceImpl.java deleted file mode 100644 index 88424b2..0000000 --- a/jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/services/impl/CustomBindingExampleServiceImpl.java +++ /dev/null @@ -1,44 +0,0 @@ -package de.spring.webservices.services.impl; - -//import java.util.ArrayList; -//import java.util.List; - -import org.springframework.stereotype.Service; - -import de.spring.webservices.operations.Operations; -import de.spring.webservices.parent.auto.ParentEnumType; -import de.spring.webservices.server.auto.CustomBindingExampleRequest; -import de.spring.webservices.server.auto.CustomBindingExampleResponse; -//import de.spring.webservices.exceptions.BusinessException; -//import de.spring.webservices.exceptions.CustomBusinessException; - - -@Service("customBindingExampleService") -public class CustomBindingExampleServiceImpl implements - Operations.RequestResponse { - - - @Override - public CustomBindingExampleResponse requestResponse(final CustomBindingExampleRequest request) { - - - // Example about how works org.springframework.ws.soap.server.endpoint.SoapFaultMappingExceptionResolver - // see soap-ws.xml Spring configuration file. -// throw new BusinessException("This feature has not been implemented yet."); - - // Example about how works de.spring.webservices.endpoints.MyCustomMappingExceptionResolver - // see soap-ws.xml Spring configuration file. -// List arguments = new ArrayList<>(); -// arguments.add("ARGUMENT 1"); -// arguments.add("ARGUMENT 2"); -// throw new CustomBusinessException("This feature has not been implemented yet.", arguments); - - CustomBindingExampleResponse response = new CustomBindingExampleResponse(); - - response.setData("CUSTOM BINDING SNAKE EYES AND " + request.getData()); - response.setParentEnum(ParentEnumType.FIRST); - - return response; - } - -} diff --git a/jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/services/impl/ExampleServiceImpl.java b/jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/services/impl/ExampleServiceImpl.java deleted file mode 100644 index ec80b60..0000000 --- a/jaxb2/web-services-spring-jaxb2-server/src/main/java/de/spring/webservices/services/impl/ExampleServiceImpl.java +++ /dev/null @@ -1,23 +0,0 @@ -package de.spring.webservices.services.impl; - -import org.springframework.stereotype.Service; - -import de.spring.webservices.server.auto.ExampleRequest; -import de.spring.webservices.server.auto.ExampleResponse; -import de.spring.webservices.services.ExampleService; - - -@Service("exampleService") -public class ExampleServiceImpl implements ExampleService { - - @Override - public ExampleResponse doResponse(final ExampleRequest request) { - - ExampleResponse response = new ExampleResponse(); - - response.setData("SNAKE EYES AND " + request.getData()); - - return response; - } - -} diff --git a/jaxb2/web-services-spring-jaxb2-server/src/main/jetty/jetty-http.xml b/jaxb2/web-services-spring-jaxb2-server/src/main/jetty/jetty-http.xml deleted file mode 100644 index d995630..0000000 --- a/jaxb2/web-services-spring-jaxb2-server/src/main/jetty/jetty-http.xml +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - - - - - - - https - - - - 32768 - 8192 - 8192 - true - false - 512 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/jaxb2/web-services-spring-jaxb2-server/src/main/resources/log4j2.xml b/jaxb2/web-services-spring-jaxb2-server/src/main/resources/log4j2.xml deleted file mode 100644 index ea6ded3..0000000 --- a/jaxb2/web-services-spring-jaxb2-server/src/main/resources/log4j2.xml +++ /dev/null @@ -1,80 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/jaxb2/web-services-spring-jaxb2-server/src/main/resources/schemas/examples.xsd b/jaxb2/web-services-spring-jaxb2-server/src/main/resources/schemas/examples.xsd deleted file mode 100644 index 59cd317..0000000 --- a/jaxb2/web-services-spring-jaxb2-server/src/main/resources/schemas/examples.xsd +++ /dev/null @@ -1,127 +0,0 @@ - - - - - - - - - - - - - - - - @java.lang.SuppressWarnings({"unchecked","rawtypes"}) - de.spring.webservices.operations.Request - - - - - - - - - - - - de.spring.webservices.operations.Response - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/jaxb2/web-services-spring-jaxb2-server/src/main/resources/spring-configuration/spring-configuration.xml b/jaxb2/web-services-spring-jaxb2-server/src/main/resources/spring-configuration/spring-configuration.xml deleted file mode 100644 index 7341c77..0000000 --- a/jaxb2/web-services-spring-jaxb2-server/src/main/resources/spring-configuration/spring-configuration.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - diff --git a/jaxb2/web-services-spring-jaxb2-server/src/main/resources/spring-configuration/ws/soap-ws.xml b/jaxb2/web-services-spring-jaxb2-server/src/main/resources/spring-configuration/ws/soap-ws.xml deleted file mode 100644 index 40f2901..0000000 --- a/jaxb2/web-services-spring-jaxb2-server/src/main/resources/spring-configuration/ws/soap-ws.xml +++ /dev/null @@ -1,284 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - classpath:schemas/parent.xsd - - classpath:schemas/examples.xsd - - - - - - - - - - - - - - - - - - SERVER - - - - - - - - - - - - - - - SERVER - - - - - - - - diff --git a/jaxb2/web-services-spring-jaxb2-server/src/main/webapp/WEB-INF/web.xml b/jaxb2/web-services-spring-jaxb2-server/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index 7e14eba..0000000 --- a/jaxb2/web-services-spring-jaxb2-server/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - Spring Web Services: example - - - - org.springframework.web.context.ContextLoaderListener - - - - - spring.profiles.active - ${environment.profile} - contextConfigLocation - - classpath*:spring-configuration/*.xml - - - - - - spring-ws - org.springframework.ws.transport.http.MessageDispatcherServlet - 1 - true - - contextConfigLocation - classpath*:spring-configuration/ws/*.xml - - - transformWsdlLocations - true - - - - - spring-ws - /spring-ws/* - - - diff --git a/jaxb2/web-services-spring-jaxb2-server/src/test/java/de/spring/webservices/endpoints/ExampleEndPointIntegrationTest.java b/jaxb2/web-services-spring-jaxb2-server/src/test/java/de/spring/webservices/endpoints/ExampleEndPointIntegrationTest.java deleted file mode 100644 index f0204cb..0000000 --- a/jaxb2/web-services-spring-jaxb2-server/src/test/java/de/spring/webservices/endpoints/ExampleEndPointIntegrationTest.java +++ /dev/null @@ -1,62 +0,0 @@ -package de.spring.webservices.endpoints; - -import static org.springframework.ws.test.server.RequestCreators.withPayload; -import static org.springframework.ws.test.server.ResponseMatchers.payload; - -import javax.xml.transform.Source; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.ws.test.server.MockWebServiceClient; -import org.springframework.xml.transform.StringSource; - - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = { "classpath*:spring-configuration/ws/soap-ws.xml" } ) -public class ExampleEndPointIntegrationTest { - - @Autowired - private ApplicationContext applicationContext; - - private MockWebServiceClient mockClient; - - @Before - public void createClient() { - mockClient = MockWebServiceClient.createClient(applicationContext); - } - - @Test - public void exampleEndpoint() throws Exception { - final Source requestPayload = new StringSource( - "" + - "SCARLETT" + - ""); - final Source responsePayload = new StringSource( - "" + - "SNAKE EYES AND SCARLETT" + - ""); - mockClient.sendRequest(withPayload(requestPayload)).andExpect( - payload(responsePayload)); - - - final Source customRequestPayload = new StringSource( - "" + - "SCARLETT" + - "2015-06-03T10:20:30Z" + - "FIRST" + - ""); - final Source customResponsePayload = new StringSource( - "" + - "CUSTOM BINDING SNAKE EYES AND SCARLETT" + - "FIRST" + - ""); - mockClient.sendRequest(withPayload(customRequestPayload)).andExpect( - payload(customResponsePayload)); - } -} - diff --git a/jaxb2/web-services-spring-jaxb2-server/src/test/java/de/spring/webservices/endpoints/ExampleEndPointTest.java b/jaxb2/web-services-spring-jaxb2-server/src/test/java/de/spring/webservices/endpoints/ExampleEndPointTest.java deleted file mode 100644 index a4a279f..0000000 --- a/jaxb2/web-services-spring-jaxb2-server/src/test/java/de/spring/webservices/endpoints/ExampleEndPointTest.java +++ /dev/null @@ -1,52 +0,0 @@ -package de.spring.webservices.endpoints; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; - -import org.junit.Before; -import org.junit.Test; - -import de.spring.webservices.operations.Operations; -import de.spring.webservices.server.auto.CustomBindingExampleRequest; -import de.spring.webservices.server.auto.CustomBindingExampleResponse; -import de.spring.webservices.server.auto.ExampleRequest; -import de.spring.webservices.services.ExampleService; - - -public class ExampleEndPointTest { - - private ExampleService exampleService; - - private Operations.RequestResponse - customBindingExampleService; - - private ExampleEndPoint exampleEndPoint; - - @Before - public void init() { - exampleService = mock(ExampleService.class); - customBindingExampleService = mock(Operations.RequestResponse.class); - exampleEndPoint = new ExampleEndPoint(customBindingExampleService, exampleService); - } - - @Test - public void givenExampleRequestThenInvokeExampleService() { - ExampleRequest request = new ExampleRequest(); - request.setData("SCARLETT"); - - exampleEndPoint.exampleResponse(request, null, null); - - verify(exampleService).doResponse(request); - } - - @Test - public void givenCustomBindingExampleRequestThenInvokeCustomBindingExampleService() { - CustomBindingExampleRequest request = new CustomBindingExampleRequest(); - request.setData("SCARLETT"); - - exampleEndPoint.cuntomBindingExampleResponse(request, null, null); - - verify(customBindingExampleService).requestResponse(request); - } - -} diff --git a/jaxb2/web-services-spring-jaxb2-server/src/test/java/de/spring/webservices/services/CustomBindingExampleServiceTest.java b/jaxb2/web-services-spring-jaxb2-server/src/test/java/de/spring/webservices/services/CustomBindingExampleServiceTest.java deleted file mode 100644 index d3b56be..0000000 --- a/jaxb2/web-services-spring-jaxb2-server/src/test/java/de/spring/webservices/services/CustomBindingExampleServiceTest.java +++ /dev/null @@ -1,34 +0,0 @@ -package de.spring.webservices.services; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import de.spring.webservices.operations.Operations; -import de.spring.webservices.server.auto.CustomBindingExampleRequest; -import de.spring.webservices.server.auto.CustomBindingExampleResponse; -import de.spring.webservices.services.impl.CustomBindingExampleServiceImpl; - - -public class CustomBindingExampleServiceTest { - - private Operations.RequestResponse - customBindingExampleService; - - @Before - public void init() { - customBindingExampleService = new CustomBindingExampleServiceImpl(); - } - - @Test - public void givenCustomBindingExampleRequestThenReturnCustomBindingExampleResponse() { - CustomBindingExampleRequest request = new CustomBindingExampleRequest(); - request.setData("SCARLETT"); - CustomBindingExampleResponse expected = new CustomBindingExampleResponse(); - expected.setData("CUSTOM BINDING SNAKE EYES AND " + request.getData()); - - CustomBindingExampleResponse actual = customBindingExampleService.requestResponse(request); - - Assert.assertEquals(expected.getData(), actual.getData()); - } -} diff --git a/jaxb2/web-services-spring-jaxb2-server/src/test/java/de/spring/webservices/services/ExampleServiceTest.java b/jaxb2/web-services-spring-jaxb2-server/src/test/java/de/spring/webservices/services/ExampleServiceTest.java deleted file mode 100644 index 9f33c5e..0000000 --- a/jaxb2/web-services-spring-jaxb2-server/src/test/java/de/spring/webservices/services/ExampleServiceTest.java +++ /dev/null @@ -1,32 +0,0 @@ -package de.spring.webservices.services; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import de.spring.webservices.server.auto.ExampleRequest; -import de.spring.webservices.server.auto.ExampleResponse; -import de.spring.webservices.services.impl.ExampleServiceImpl; - -public class ExampleServiceTest { - - private ExampleService exampleService; - - @Before - public void init() { - exampleService = new ExampleServiceImpl(); - } - - @Test - public void givenExampleRequestThenReturnExampleResponse() { - ExampleRequest request = new ExampleRequest(); - request.setData("SCARLETT"); - ExampleResponse expected = new ExampleResponse(); - expected.setData("SNAKE EYES AND " + request.getData()); - - ExampleResponse actual = exampleService.doResponse(request); - - Assert.assertEquals(expected.getData(), actual.getData()); - } - -} diff --git a/jaxb2/web-services-spring-jaxb2/pom.xml b/jaxb2/web-services-spring-jaxb2/pom.xml deleted file mode 100644 index 4badaa6..0000000 --- a/jaxb2/web-services-spring-jaxb2/pom.xml +++ /dev/null @@ -1,240 +0,0 @@ - - 4.0.0 - de.spring.webservices - web-services-spring-jaxb2 - pom - 1.0-SNAPSHOT - web-services-spring-jaxb2 - http://gumartinm.name - Web Services Spring Framework - - Gustavo Martin Morcuende - http://www.gumartinm.name - - - scm:git:http://git.gumartinm.name/SpringWebServicesForFun - http://git.gumartinm.name/SpringWebServicesForFun - - - - UTF-8 - UTF-8 - - 4.0.9.RELEASE - 2.2.1.RELEASE - - - - - release - - release - - - true - - - - - - - - org.apache.logging.log4j - log4j-slf4j-impl - 2.3 - - - - org.apache.logging.log4j - log4j-core - 2.3 - - - - org.slf4j - jcl-over-slf4j - 1.7.12 - - - cglib - cglib - 2.2.2 - - - - - - org.springframework.ws - spring-ws-core - ${spring.ws.version} - - - - commons-logging - commons-logging - - - - - org.springframework.ws - spring-xml - ${spring.ws.version} - - - - commons-logging - commons-logging - - - - - org.jdom - jdom - 2.0.2 - - - - - wsdl4j - wsdl4j - 1.6.3 - - - - - junit - junit - 4.12 - test - - - org.springframework - spring-test - ${spring.version} - test - - - org.springframework.ws - spring-ws-test - ${spring.ws.version} - test - - - - commons-logging - commons-logging - - - - - org.mockito - mockito-core - 2.0.11-beta - test - - - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.18.1 - - - org.apache.maven.plugins - maven-failsafe-plugin - 2.18.1 - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.3 - - 1.8 - 1.8 - ${project.build.sourceEncoding} - - - - org.apache.maven.plugins - maven-resources-plugin - 2.7 - - ${project.build.sourceEncoding} - - - - org.apache.maven.plugins - maven-jar-plugin - 2.4 - - - - ${project.description} - ${project.version} - ${project.organization.name} - ${project.description} - ${project.version} - ${project.organization.name} - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - **/*IntegrationTest.java - - - - - org.apache.maven.plugins - maven-failsafe-plugin - - - - integration-test - verify - - - - - - **/*IntegrationTest.java - - - - - -