diff options
author | Thomas Lenz <thomas.lenz@egiz.gv.at> | 2014-10-16 13:42:04 +0200 |
---|---|---|
committer | Thomas Lenz <thomas.lenz@egiz.gv.at> | 2014-10-16 13:42:04 +0200 |
commit | e2150f22562b4bc06307f4ac7b842687390e4856 (patch) | |
tree | 768250437cca30ab4fda039d924269e37fd99414 /src/main/java/at/gv/util/client/mis | |
parent | 2f3b7f180511a5e0af674e3a25ddbaabaa38d36c (diff) | |
download | egovutils-e2150f22562b4bc06307f4ac7b842687390e4856.tar.gz egovutils-e2150f22562b4bc06307f4ac7b842687390e4856.tar.bz2 egovutils-e2150f22562b4bc06307f4ac7b842687390e4856.zip |
change webservice implementation to Apache CXF
Diffstat (limited to 'src/main/java/at/gv/util/client/mis')
-rw-r--r-- | src/main/java/at/gv/util/client/mis/MISClient.java | 34 | ||||
-rw-r--r-- | src/main/java/at/gv/util/client/mis/usp/USPClient.java | 35 |
2 files changed, 48 insertions, 21 deletions
diff --git a/src/main/java/at/gv/util/client/mis/MISClient.java b/src/main/java/at/gv/util/client/mis/MISClient.java index 88afc8b..722db42 100644 --- a/src/main/java/at/gv/util/client/mis/MISClient.java +++ b/src/main/java/at/gv/util/client/mis/MISClient.java @@ -12,6 +12,11 @@ import javax.xml.ws.BindingProvider; import javax.xml.ws.WebServiceContext; import javax.xml.ws.handler.Handler; +import org.apache.cxf.configuration.jsse.TLSClientParameters; +import org.apache.cxf.endpoint.Client; +import org.apache.cxf.frontend.ClientProxy; +import org.apache.cxf.transport.http.HTTPConduit; +import org.apache.cxf.transports.http.configuration.HTTPClientPolicy; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -27,8 +32,6 @@ import at.gv.util.wsdl.szr.SZRException; import at.gv.util.xsd.mis.MandateIssueRequestType; import at.gv.util.xsd.mis.MandateIssueResponseType; -import com.sun.xml.ws.developer.JAXWSProperties; - public class MISClient { @Resource @@ -79,13 +82,26 @@ public class MISClient { if (sslContext == null) { throw new EgovUtilException("SSL context from configuration is empty. Please configure an SSL context in the configuration first."); } - requestContext.put(JAXWSProperties.SSL_SOCKET_FACTORY, sslContext.getSocketFactory()); - - // check for lax hostname - if (this.config.getMISsslConfiguration().useLaxHostNameVerifier()) { - log.trace("LaxHostnameVerifier enabled. This setting is not recommended to use."); - requestContext.put(JAXWSProperties.HOSTNAME_VERIFIER, new LaxHostNameVerifier()); - } + Client client = ClientProxy.getClient(port); + HTTPConduit http = (HTTPConduit) client.getConduit(); + HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy(); + + httpClientPolicy.setConnectionTimeout(36000); + httpClientPolicy.setAllowChunking(false); + httpClientPolicy.setReceiveTimeout(32000); + + http.setClient(httpClientPolicy); + + TLSClientParameters tlsParams = new TLSClientParameters(); + tlsParams.setSSLSocketFactory(sslContext.getSocketFactory()); + + // check for lax hostname + if (this.config.getMISsslConfiguration().useLaxHostNameVerifier()) { + log.trace("LaxHostnameVerifier enabled. This setting is not recommended to use."); + tlsParams.setHostnameVerifier(new LaxHostNameVerifier()); + } + + http.setTlsClientParameters(tlsParams ); } return port.mandateIssueOperation(mir); } diff --git a/src/main/java/at/gv/util/client/mis/usp/USPClient.java b/src/main/java/at/gv/util/client/mis/usp/USPClient.java index ac8315a..fb88e05 100644 --- a/src/main/java/at/gv/util/client/mis/usp/USPClient.java +++ b/src/main/java/at/gv/util/client/mis/usp/USPClient.java @@ -15,6 +15,11 @@ import javax.xml.ws.WebServiceContext; import javax.xml.ws.handler.Handler; import org.apache.commons.lang.RandomStringUtils; +import org.apache.cxf.configuration.jsse.TLSClientParameters; +import org.apache.cxf.endpoint.Client; +import org.apache.cxf.frontend.ClientProxy; +import org.apache.cxf.transport.http.HTTPConduit; +import org.apache.cxf.transports.http.configuration.HTTPClientPolicy; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -32,8 +37,6 @@ import at.gv.util.xsd.mis.usp.GetMandatesResponse; import at.gv.util.xsd.mis.usp.IdentificationType; import at.gv.util.xsd.szr.pvp.PvpTokenType; -import com.sun.xml.ws.developer.JAXWSProperties; - public class USPClient { @Resource @@ -122,10 +125,16 @@ public class USPClient { handlerList.add(szrSOAPHandler); bindingProvider.getBinding().setHandlerChain(handlerList); - + Client client = ClientProxy.getClient(uspSuche); + HTTPConduit http = (HTTPConduit) client.getConduit(); + HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy(); + //set HTTP Client Timeout (Default Timeout 60sec) - requestContext.put(JAXWSProperties.CONNECT_TIMEOUT, this.config.getHTTPRequestTimeout()); - + httpClientPolicy.setConnectionTimeout(this.config.getHTTPRequestTimeout()); + httpClientPolicy.setAllowChunking(false); + httpClientPolicy.setReceiveTimeout(32000); + http.setClient(httpClientPolicy); + // check for ssl if (uspURL.toLowerCase().startsWith("https")) { log.trace("Using ssl for SZR client request."); @@ -133,13 +142,15 @@ public class USPClient { if (sslContext == null) { throw new EgovUtilException("SSL context from configuration is empty. Please configure an SSL context in the configuration first."); } - requestContext.put(JAXWSProperties.SSL_SOCKET_FACTORY, sslContext.getSocketFactory()); - - // check for lax hostname - if (this.config.getURsslConfiguration().useLaxHostNameVerifier()) { - log.trace("LaxHostnameVerifier enabled. This setting is not recommended to use."); - requestContext.put(JAXWSProperties.HOSTNAME_VERIFIER, new LaxHostNameVerifier()); - } + TLSClientParameters tlsParams = new TLSClientParameters(); + tlsParams.setSSLSocketFactory(sslContext.getSocketFactory()); + + // check for lax hostname + if (this.config.getUSPsslConfiguration().useLaxHostNameVerifier()) { + log.trace("LaxHostnameVerifier enabled. This setting is not recommended to use."); + tlsParams.setHostnameVerifier(new LaxHostNameVerifier()); + } + http.setTlsClientParameters(tlsParams ); } } |