aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/gv/egiz/moazs/client
diff options
context:
space:
mode:
authorChristof Rabensteiner <christof.rabensteiner@iaik.tugraz.at>2019-11-29 15:56:44 +0100
committerChristof Rabensteiner <christof.rabensteiner@iaik.tugraz.at>2019-11-29 15:56:44 +0100
commit6dbe979e0b6bd6236db304b034ad592a4aeacabc (patch)
tree4c5c10279b01e3602da8195c741191f660561e9b /src/main/java/at/gv/egiz/moazs/client
parenta5b8668c0c7916a8fe2b84122d537a3e0bd67002 (diff)
downloadmoa-zs-6dbe979e0b6bd6236db304b034ad592a4aeacabc.tar.gz
moa-zs-6dbe979e0b6bd6236db304b034ad592a4aeacabc.tar.bz2
moa-zs-6dbe979e0b6bd6236db304b034ad592a4aeacabc.zip
Refactor & Fix Client Creation in Client Factory
- Refactor: Replace createSoap1{1,2} with create{Tnvz,App,Msg}Client. Configure each method with zusespec's specific parameters. Reason: Each service requires different parameters (e.g. with / without MTOM? soap11 / soap12? store responses in binary respository - yes/no?). These parameters could be placed in the client configuration of application.yaml. Since the parameters are tied to zusespecs, they do not need to be configurable via application.yaml. Another benefit for this refactoring is to improve readability. - Fix: Disable "Store Response" for TNVZ Client and App Client
Diffstat (limited to 'src/main/java/at/gv/egiz/moazs/client')
-rw-r--r--src/main/java/at/gv/egiz/moazs/client/ClientFactory.java45
1 files changed, 23 insertions, 22 deletions
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 c294aa3..18fcdd9 100644
--- a/src/main/java/at/gv/egiz/moazs/client/ClientFactory.java
+++ b/src/main/java/at/gv/egiz/moazs/client/ClientFactory.java
@@ -26,7 +26,10 @@ import at.gv.egiz.moazs.util.FileUtils;
import at.gv.egiz.moazs.util.StoreSOAPBodyBinaryInRepositoryInterceptor;
import at.gv.zustellung.app2mzs.xsd.ClientType;
import at.gv.zustellung.app2mzs.xsd.KeyStoreType;
+import at.gv.zustellung.app2mzs.xsd.Mzs2AppPortType;
import at.gv.zustellung.app2mzs.xsd.SSLType;
+import at.gv.zustellung.msg.xsd.App2ZusePort;
+import at.gv.zustellung.tnvz.xsd.TNVZServicePort;
import org.apache.cxf.configuration.jsse.TLSClientParameters;
import org.apache.cxf.endpoint.Client;
import org.apache.cxf.ext.logging.LoggingInInterceptor;
@@ -78,48 +81,46 @@ public class ClientFactory {
this.configUtil = configUtil;
}
- /**
- * 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> T createSOAP12(ClientType params, Class<T> clazz) {
- return createSOAPClient(params, clazz, true);
+ public TNVZServicePort createTnvzClient(ClientType params) {
+ return createSOAPClient(params, TNVZServicePort.class, true, false, false);
}
- /**
- * 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> T createSOAP11(ClientType params, Class<T> clazz) {
- return createSOAPClient(params, clazz, false);
+ public Mzs2AppPortType createAppClient(ClientType params) {
+ return createSOAPClient(params, Mzs2AppPortType.class, false, false, true);
+ }
+
+ public App2ZusePort createMsgClient(ClientType params) {
+ return createSOAPClient(params, App2ZusePort.class, true, true, true);
}
- private <T> T createSOAPClient(ClientType params, Class<T> clazz, boolean isSoap12) {
+ private <T> T createSOAPClient(ClientType params, Class<T> clazz, boolean isSoap12, boolean storeResponse, boolean mtomEnabled) {
log.info("Create client for service {}", params.getURL());
var factory = new JaxWsClientFactoryBean();
factory.setServiceClass(clazz);
factory.setAddress(params.getURL());
- factory.getInInterceptors().add(storeResponseInterceptor);
+
+ if (storeResponse) {
+ factory.getInInterceptors().add(storeResponseInterceptor);
+ }
if (isSoap12) {
- factory.setBindingId(SOAPBinding.SOAP12HTTP_MTOM_BINDING);
+ factory.setBindingId(SOAPBinding.SOAP12HTTP_BINDING);
}
+
setupLoggingInterceptors(factory);
var proxy = new JaxWsProxyFactoryBean(factory).create();
Client client = ClientProxy.getClient(proxy);
HTTPConduit http = (HTTPConduit) client.getConduit();
- var bindingProvider = (BindingProvider) proxy;
- SOAPBinding binding = (SOAPBinding) bindingProvider.getBinding();
- binding.setMTOMEnabled(true);
+ if (mtomEnabled) {
+ var bindingProvider = (BindingProvider) proxy;
+ SOAPBinding binding = (SOAPBinding) bindingProvider.getBinding();
+ binding.setMTOMEnabled(true);
+ }
var httpClientPolicy = new HTTPClientPolicy();
httpClientPolicy.setConnectionTimeout(params.getConnectionTimeout().longValueExact());