From b3060f8ba40280d438e2b4b06b39aed84c587f7a Mon Sep 17 00:00:00 2001 From: Christof Rabensteiner Date: Wed, 2 Oct 2019 14:30:43 +0200 Subject: For {TNVZ, MSG}: Switch to Soap 1.2 - But: Leave MZS Interface at Soap 1.1 - Add ClientFactory.createSOAP11 to ensure that we can talk back to the app. --- .../moazs/backend/ForwardResponseToServiceSink.java | 2 +- .../java/at/gv/egiz/moazs/client/ClientFactory.java | 21 ++++++++++++++++++--- .../java/at/gv/egiz/moazs/scheme/SOAPUtils.java | 12 ++++++------ src/test/java/at/gv/egiz/moazs/ITEndToEndTest.java | 2 +- src/test/java/at/gv/egiz/moazs/SOAPUtilsTest.java | 14 +++++++------- .../ITEndToEndTest/msg-delivery-notification.xml | 2 +- .../ITEndToEndTest/msg-delivery-request-status.xml | 2 +- .../valid-signed-shuffled-soaped-notification.xml | 2 +- .../valid-signed-soaped-notification.xml | 2 +- 9 files changed, 37 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/main/java/at/gv/egiz/moazs/backend/ForwardResponseToServiceSink.java b/src/main/java/at/gv/egiz/moazs/backend/ForwardResponseToServiceSink.java index d870aa8..8e1566e 100644 --- a/src/main/java/at/gv/egiz/moazs/backend/ForwardResponseToServiceSink.java +++ b/src/main/java/at/gv/egiz/moazs/backend/ForwardResponseToServiceSink.java @@ -33,7 +33,7 @@ public class ForwardResponseToServiceSink { log.info("Forward msg:{} with AppDeliveryID={} to service at {}.", msgResponse.getRootElementLocalPart(), msgResponse.getAppDeliveryID(), params.getURL()); var binaryResponse = repository.retrieveBinaryResponse(msgResponse.getResponseID()); - Mzs2AppPortType client = factory.create(params, Mzs2AppPortType.class); + Mzs2AppPortType client = factory.createSoap11(params, Mzs2AppPortType.class); return msgResponse.sendToAppClient(converter, binaryResponse, client); } } diff --git a/src/main/java/at/gv/egiz/moazs/client/ClientFactory.java b/src/main/java/at/gv/egiz/moazs/client/ClientFactory.java index 44da83a..8b2054b 100644 --- a/src/main/java/at/gv/egiz/moazs/client/ClientFactory.java +++ b/src/main/java/at/gv/egiz/moazs/client/ClientFactory.java @@ -55,16 +55,27 @@ public class ClientFactory { } /** - * Creates a client that communicates with a soap service. + * Creates a client that communicates with a soap 1.2 service. * * @param params for the client, such as service url and ssl parameters. * @return the client */ public T create(ClientType params, Class clazz) { - return JAXBClassNotFoundFix.runInTheadWithClassClassLoader(() -> createClient(params, clazz)); + return JAXBClassNotFoundFix.runInTheadWithClassClassLoader(() -> create(params, clazz, true)); } - private T createClient(ClientType params, Class clazz) { + /** + * Creates a client that communicates with a soap 1.1 service. + * + * @param params for the client, such as service url and ssl parameters. + * @return the client + */ + public T createSoap11(ClientType params, Class clazz) { + return JAXBClassNotFoundFix.runInTheadWithClassClassLoader(() -> create(params, clazz, false)); + } + + + private T create(ClientType params, Class clazz, boolean isSoap12) { log.info("Create client for service {}", params.getURL()); @@ -72,6 +83,10 @@ public class ClientFactory { factory.setServiceClass(clazz); factory.setAddress(params.getURL()); factory.getInInterceptors().add(storeResponseInterceptor); + + if (isSoap12) { + factory.setBindingId(SOAPBinding.SOAP12HTTP_MTOM_BINDING); + } setupLoggingInterceptors(factory); var proxy = new JaxWsProxyFactoryBean(factory).create(); diff --git a/src/main/java/at/gv/egiz/moazs/scheme/SOAPUtils.java b/src/main/java/at/gv/egiz/moazs/scheme/SOAPUtils.java index f44fb3d..6ec120f 100644 --- a/src/main/java/at/gv/egiz/moazs/scheme/SOAPUtils.java +++ b/src/main/java/at/gv/egiz/moazs/scheme/SOAPUtils.java @@ -2,7 +2,7 @@ package at.gv.egiz.moazs.scheme; import at.gv.egiz.eaaf.core.impl.utils.DOMUtils; import at.gv.egiz.moazs.MoaZSException; -import org.apache.cxf.binding.soap.Soap11; +import org.apache.cxf.binding.soap.Soap12; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; @@ -26,8 +26,8 @@ import static at.gv.egiz.moazs.MoaZSException.moaZSException; public class SOAPUtils { private static final Logger log = LoggerFactory.getLogger(SOAPUtils.class); - private static final String SOAP_BODY_MISSING_ERROR_MSG = " is missing."; - private static final String SOAP_BODY_CHILDREN_MISSING_ERROR_MSG = " has no child elements."; + private static final String SOAP_BODY_MISSING_ERROR_MSG = " is missing."; + private static final String SOAP_BODY_CHILDREN_MISSING_ERROR_MSG = " has no child elements."; private static final String APP_DELIVERY_ID_FULL_TAG_NAME = ""; private static final String MULTIPLE_MSG = "Found multiple {} elements. Will choose first element."; private static final String APP_DELIVERY_ID_MISSING_ERROR_MSG = APP_DELIVERY_ID_FULL_TAG_NAME + " is missing."; @@ -40,16 +40,16 @@ public class SOAPUtils { public Node getChildElementOfSoapBody(Element document) throws MoaZSException { - var bodyList = document.getElementsByTagNameNS(Soap11.SOAP_NAMESPACE, "Body"); + var bodyList = document.getElementsByTagNameNS(Soap12.SOAP_NAMESPACE, "Body"); if (bodyList.getLength() == 0) throw moaZSException(SOAP_BODY_MISSING_ERROR_MSG); - if (bodyList.getLength() > 1) log.warn(MULTIPLE_MSG, ""); + if (bodyList.getLength() > 1) log.warn(MULTIPLE_MSG, ""); var body = bodyList.item(0); var children = body.getChildNodes(); var candidates = filterNodeByType(children, Node.ELEMENT_NODE); if (candidates.isEmpty()) throw moaZSException(SOAP_BODY_CHILDREN_MISSING_ERROR_MSG); - if (candidates.size() > 1) log.warn(MULTIPLE_MSG, " child"); + if (candidates.size() > 1) log.warn(MULTIPLE_MSG, " child"); return candidates.get(0); } diff --git a/src/test/java/at/gv/egiz/moazs/ITEndToEndTest.java b/src/test/java/at/gv/egiz/moazs/ITEndToEndTest.java index 29b7b53..95c7140 100644 --- a/src/test/java/at/gv/egiz/moazs/ITEndToEndTest.java +++ b/src/test/java/at/gv/egiz/moazs/ITEndToEndTest.java @@ -92,7 +92,7 @@ public class ITEndToEndTest { APP = mockApp(); when(factory.create(any(), same(TNVZServicePort.class))).thenReturn(tnvz); when(factory.create(any(), same(App2ZusePort.class))).thenReturn(msg); - when(factory.create(any(), same(Mzs2AppPortType.class))).thenReturn(APP); + when(factory.createSoap11(any(), same(Mzs2AppPortType.class))).thenReturn(APP); return factory; } diff --git a/src/test/java/at/gv/egiz/moazs/SOAPUtilsTest.java b/src/test/java/at/gv/egiz/moazs/SOAPUtilsTest.java index ff0060e..bf74ac0 100644 --- a/src/test/java/at/gv/egiz/moazs/SOAPUtilsTest.java +++ b/src/test/java/at/gv/egiz/moazs/SOAPUtilsTest.java @@ -15,7 +15,7 @@ public class SOAPUtilsTest { SOAPUtils utils; private static final String SOAP_MESSAGE = - "" + + "" + "\n" + " \n" + " \n" + @@ -38,7 +38,7 @@ public class SOAPUtilsTest { public static final String CLUTTERED_MESSAGE = "\n" + "\n" + " \n" + " \n" + @@ -48,14 +48,14 @@ public class SOAPUtilsTest { "\n"; private static final String MISSING_BODY_MESSAGE = - ""; + ""; private static final String EMPTY_BODY_MESSAGE = - " "; + " "; public static final String EMPTY_APP_DELIVERY_ID_MESSAGE = "\n" + " \n" + " \n" + @@ -66,7 +66,7 @@ public class SOAPUtilsTest { public static final String BLANK_APP_DELIVERY_ID_MESSAGE = "\n" + " \n" + " \n" + diff --git a/src/test/resources/at/gv/egiz/moazs/ITEndToEndTest/msg-delivery-notification.xml b/src/test/resources/at/gv/egiz/moazs/ITEndToEndTest/msg-delivery-notification.xml index 3a90d36..2f99af5 100644 --- a/src/test/resources/at/gv/egiz/moazs/ITEndToEndTest/msg-delivery-notification.xml +++ b/src/test/resources/at/gv/egiz/moazs/ITEndToEndTest/msg-delivery-notification.xml @@ -1,6 +1,6 @@ diff --git a/src/test/resources/at/gv/egiz/moazs/ITSignatureVerifierTest/valid-signed-shuffled-soaped-notification.xml b/src/test/resources/at/gv/egiz/moazs/ITSignatureVerifierTest/valid-signed-shuffled-soaped-notification.xml index 1262c3e..f40a6f0 100644 --- a/src/test/resources/at/gv/egiz/moazs/ITSignatureVerifierTest/valid-signed-shuffled-soaped-notification.xml +++ b/src/test/resources/at/gv/egiz/moazs/ITSignatureVerifierTest/valid-signed-shuffled-soaped-notification.xml @@ -1,5 +1,5 @@ - + https://localhost/example-delivery-system diff --git a/src/test/resources/at/gv/egiz/moazs/ITSignatureVerifierTest/valid-signed-soaped-notification.xml b/src/test/resources/at/gv/egiz/moazs/ITSignatureVerifierTest/valid-signed-soaped-notification.xml index 54e9918..535b2ad 100644 --- a/src/test/resources/at/gv/egiz/moazs/ITSignatureVerifierTest/valid-signed-soaped-notification.xml +++ b/src/test/resources/at/gv/egiz/moazs/ITSignatureVerifierTest/valid-signed-soaped-notification.xml @@ -1,5 +1,5 @@ - + https://localhost/example-delivery-system -- cgit v1.2.3