Change HttpTransportFactory cxf 2.7.3

♀尐吖头ヾ 提交于 2021-02-11 15:40:57

问题


I'm trying to change the HttpURLConnection that the cxf HTTPTransportFactoryuses.

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?


回答1:


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.



来源:https://stackoverflow.com/questions/17573490/change-httptransportfactory-cxf-2-7-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!