JAX-WS with Custom SSLSocketFactory

How to configure custom SSLSocketFactory for JAX-WS web-service in Spring Framework

Dec 1, 2014

It’s very easy to configure custom SSLSocketFactory for JAX-WS web-service: just specify custom property referring to SSLSocketFactory bean. But there is a nuance…

In SpringFramework you may setup web service port with following XML configuration:

<bean id="myPort" class="org.springframework.remoting.jaxws.JaxWsPortProxyFactoryBean">
    <property name="serviceInterface" value="com.example.ServicePortInterface"/>
    <property name="wsdlDocumentResource" value="classpath:wsdl/MyService.wsdl"/>
    <property name="namespaceUri" value="urn:MyServer"/>
    <property name="serviceName" value="MyServerService"/>
    <property name="endpointAddress" value="${my.service.url}"/>
    <property name="customProperties">
        <map key-type="java.lang.String">
            <entry key="com.sun.xml.ws.transport.https.client.SSLSocketFactory"

<!--  My bean implements javax.net.ssl.SSLSocketFactory -->
<bean id="mySslSocketFactoryBean" .../>

The code above will work if you are using JAX-WS reference implementation but will not work with JAX-WS bundled in Oracle JDK. For that case you need to set a custom property named "com.sun.xml.internal.ws.transport.https.client.SSLSocketFactory".

That’s confusing, but you should use a property name defined in the JAXWSProperties class of JAX-WS implementation of your choice. For example:

  • com.sun.xml.ws.developer.JAXWSProperties.SSL_SOCKET_FACTORY – if you’re using JAXWS-RI implementation;
  • com.sun.xml.internal.ws.developer.JAXWSProperties.SSL_SOCKET_FACTORY – for Oracle JDK implementation;
  • weblogic.wsee.jaxws.JAXWSProperties.SSL_SOCKET_FACTORY – for WebLogic server’s implementation. …

So find a JAXWSProperties and use a value of constant SSL_SOCKET_FACTORY in JAX-WS binding custom properties.

See Also

Webapp Inter-Communication in Tomcat

Sometimes you need to access services deployed in one web application from another web application within same application server. For Tomcat there is not so many options to do it. In this article we’ll discuss you how to use JMX for communication between web applications.

How to Use Spring from EJB3

This is a short instruction how to inject a spring-managed bean into EJB3 component

How To Export Spring Managed Bean To JNDI

Sometimes it is necessary to export a spring managed bean to JNDI context. Here I want to show how do it.

In spring, there is a bean that provides a similar functionality for exporting to MBean server: MBeanExporter. Unfortunately, there is no standard JNDI bean exporter implementation in Spring Framework (current version is 2.5.6) - (Why?). But it’s easy to write it yourself

logo   Never miss a story, subscribe to our newsletter