From e2150f22562b4bc06307f4ac7b842687390e4856 Mon Sep 17 00:00:00 2001 From: Thomas Lenz Date: Thu, 16 Oct 2014 13:42:04 +0200 Subject: change webservice implementation to Apache CXF --- .../java/at/gv/util/client/ur_V2/URClient.java | 37 +++++++++++++++------- 1 file changed, 25 insertions(+), 12 deletions(-) (limited to 'src/main/java/at/gv/util/client/ur_V2') diff --git a/src/main/java/at/gv/util/client/ur_V2/URClient.java b/src/main/java/at/gv/util/client/ur_V2/URClient.java index edf68c8..134f7f5 100644 --- a/src/main/java/at/gv/util/client/ur_V2/URClient.java +++ b/src/main/java/at/gv/util/client/ur_V2/URClient.java @@ -18,9 +18,15 @@ import javax.xml.datatype.XMLGregorianCalendar; import javax.xml.namespace.QName; import javax.xml.ws.BindingProvider; import javax.xml.ws.WebServiceContext; +import javax.xml.ws.WebServiceException; 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; @@ -52,8 +58,6 @@ import at.gv.util.xsd.ur_V2.search.SucheUnternehmenRequest; import at.gv.util.xsd.ur_V2.search.SucheUnternehmensdaten; import at.gv.util.xsd.ur_V2.simpletypes.EvbStatusTyp; -import com.sun.xml.ws.developer.JAXWSProperties; - public class URClient { @Resource @@ -335,7 +339,7 @@ public class URClient { switchTOSecondarySystem(e); srt = this.urSuche.searchByExample(body); - } catch (com.sun.xml.ws.client.ClientTransportException e) { + } catch (WebServiceException e) { //request secondary service switchTOSecondarySystem(e); srt = this.urSuche.searchByExample(body); @@ -383,8 +387,15 @@ public class URClient { requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, urURL); //set HTTP Client Timeout (Default Timeout 60sec) - //requestContext.put(JAXWSProperties.CONNECT_TIMEOUT, this.config.getHTTPRequestTimeout()); - requestContext.put(JAXWSProperties.CONNECT_TIMEOUT, 15000); + Client client = ClientProxy.getClient(urSuche); + HTTPConduit http = (HTTPConduit) client.getConduit(); + HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy(); + + //set HTTP Client Timeout (Default Timeout 60sec) + httpClientPolicy.setConnectionTimeout(15000); + httpClientPolicy.setAllowChunking(false); + httpClientPolicy.setReceiveTimeout(32000); + http.setClient(httpClientPolicy); //check for ssl if (urURL.toLowerCase().startsWith("https")) { @@ -393,13 +404,15 @@ public class URClient { 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.getURsslConfiguration().useLaxHostNameVerifier()) { + log.trace("LaxHostnameVerifier enabled. This setting is not recommended to use."); + tlsParams.setHostnameVerifier(new LaxHostNameVerifier()); + } + http.setTlsClientParameters(tlsParams ); } } -- cgit v1.2.3