mardi 2 septembre 2014

Personnaliser la couche transport http avec Apache CXF 2.7.11

Cxf permet de personnaliser le transpoport http. Quel intérêt ?
En relation avec l'utilisation de Apache HttpClient pour l'authentification NTLM par exemple.

Dans un contexte Spring, rien de plus facile, il faut dans la configuration Spring :
<bean class="org.test.cxf.transport.MyHttpTransportFactory" lazy-init="false">
  <property name="transportIds">
    <list>
      <value>http://cxf.apache.org/transports/http</value>
      <value>http://cxf.apache.org/transports/http/configuration</value>
      <value>http://cxf.apache.org/transports/https</value>
      <value>http://cxf.apache.org/transports/https/configuration</value>
      <value>http://schemas.xmlsoap.org/wsdl/http</value>
      <value>http://schemas.xmlsoap.org/wsdl/http/</value>
      <value>http://schemas.xmlsoap.org/soap/http</value>
    </list>
  </property>
</bean>

Attention, redéfinir le HttpTransportFactory pour toutes les valeurs sans quoi sous aurez des surprises.