You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Dominik Derwiński (JIRA)" <ji...@apache.org> on 2017/01/23 15:06:26 UTC
[jira] [Created] (CXF-7223) Honor
com.sun.xml.internal.ws.developer.JAXWSProperties
Dominik Derwiński created CXF-7223:
--------------------------------------
Summary: Honor com.sun.xml.internal.ws.developer.JAXWSProperties
Key: CXF-7223
URL: https://issues.apache.org/jira/browse/CXF-7223
Project: CXF
Issue Type: Improvement
Components: JAX-WS Runtime
Reporter: Dominik Derwiński
Is it possible for CXF to honor properties described in com.sun.xml.internal.ws.developer.JAXWSProperties? Especially adding reflection-based workarounds for com.sun.xml.internal.ws.transport.https.client.SSLSocketFactory is not so simple.
WildFly application server forces CXF upon user, disables access to default JAX-WS implementation and prevents easy injection of said factory for specific connections. Workaround requires opening the internals of the application server to the application (of which org.apache.cxf.impl module causes a warning to be shown when deploying the application), and looking for CXF using reflection (in order not to have a real dependency forced by the compiler):
{code}
public static void setConnectTimeout(BindingProvider port, int timeout) {
Map<String, Object> env = port.getRequestContext();
// https://java.net/jira/browse/JAX_WS-1166
// com.sun.xml.internal.ws.developer.JAXWSProperties.CONNECT_TIMEOUT
env.put("com.sun.xml.ws.connect.timeout", timeout);
env.put("com.sun.xml.internal.ws.connect.timeout", timeout);
env.put("javax.xml.ws.client.connectionTimeout", timeout);
}
public static void setRequestTimeout(BindingProvider port, int timeout) {
Map<String, Object> env = port.getRequestContext();
// https://java.net/jira/browse/JAX_WS-1166
// com.sun.xml.internal.ws.developer.JAXWSProperties.REQUEST_TIMEOUT
env.put("com.sun.xml.ws.request.timeout", timeout);
env.put("com.sun.xml.internal.ws.request.timeout", timeout);
env.put("javax.xml.ws.client.receiveTimeout", timeout);
}
public static void setSSLSocketFactory(BindingProvider port, SSLSocketFactory factory) {
Map<String, Object> env = port.getRequestContext();
// com.sun.xml.internal.ws.developer.JAXWSProperties.SSL_SOCKET_FACTORY
env.put("com.sun.xml.ws.transport.https.client.SSLSocketFactory", factory);
env.put("com.sun.xml.internal.ws.transport.https.client.SSLSocketFactory", factory);
try {
Class<?> tlsParamsClass = Class.forName("org.apache.cxf.configuration.jsse.TLSClientParameters");
Object tlsParams = tlsParamsClass.newInstance();
tlsParamsClass.getMethod("setSSLSocketFactory", SSLSocketFactory.class).invoke(tlsParams, factory);
Class<?> clientProxyClass = Class.forName("org.apache.cxf.frontend.ClientProxy");
Class<?> clientClass = Class.forName("org.apache.cxf.endpoint.Client");
Class<?> conduitClass = Class.forName("org.apache.cxf.transport.http.HTTPConduit");
Object client = clientProxyClass.getMethod("getClient", Object.class).invoke(null, port);
Object conduit = clientClass.getMethod("getConduit").invoke(client);
conduitClass.getMethod("setTlsClientParameters", tlsParamsClass).invoke(conduit, tlsParams);
} catch (ClassNotFoundException ex) {
// silent
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
{code}
If CXF would read the standard properties that would be much easier.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)