简体   繁体   中英

Change HttpTransportFactory cxf 2.7.3

I'm trying to change the HttpURLConnection that the cxf HTTPTransportFactory uses.

Cxf (version 2.7.3) uses HTTPTransportFactory for http/https request. The HTTPTransportFactory uses Conduit of type URLConnectionHTTPConduit . URLConnectionHTTPConduit has method: createConnection which returns HttpURLConnection . I need to replace HttpURLConnection with my own custom one, lets call it CustomHttpURLConnection .

I managed to change the TransportFactory that cxf uses by:

  1. Creating class that extends HTTPTransportFactory : CustomHTTPTransportFactory (Right now this class is empty):

     public class CustomTransportFactory extends HTTPTransportFactory{ } 
  2. Register CustomTransportFactory to the right Transport Id: in this case http://schemas.xmlsoap.org/soap/http

Here is my XML:

<beans:bean id="tranpo" class="CustomTransportFactory" lazy-init="false">    
    <beans:property name="transportIds">
                  <beans:list>
                 <beans:value>"http://schemas.xmlsoap.org/soap/http"</beans:value>
          </beans:list>
    </beans:property>
</beans:bean>

However, I need to be able to register my CustomHttpURLConnection to the cxf transport HTTPTransportFactory .

Does anyone has any idea how to solve this problem?

Create a HTTPConduitFactory and register that in the context. The HTTPTransportFactory will then use that to create the conduit instead of creating the default URLConnection based one. This is how the HTTP Commons Async based conduit gets created and used.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM