问题
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:
Creating class that extends
HTTPTransportFactory
:CustomHTTPTransportFactory
(Right now this class is empty):public class CustomTransportFactory extends HTTPTransportFactory{ }
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