Custom CXF TransportPage edited by Andrei ShakirinChanges (1)
Full ContentThis page tries to summarize experience of implementing new CXF transport. Use CasesNormally implementation of custom transport is required to provide new physical protocol not yet supported by CXF(for instance udp, ftp). New CXF transport can be also a solution to support legacy ESB participants that have to be interoperable with JAX-WS services and clients. Architecture and DesignThe transport functionality is based on two fundamental definitions: Conduit and Destination. Conduit is responsible to send a message to recipient and Destination – to receive a message from the sender. In order to send a response, Destination needs own back-channel Conduit (in case of request-response communication). Conduit and Destination are created by TransportFactory. CXF selects a correct TransportFactory based on transport URL. SOAP is also considered as high level transport and has own Conduit and Destination in CXF. Class diagram of TransportFactory, Conduit, Destination and OutputStream is shown bellow: How it WorksInteraction between JAX-WS client and service using CXF transport is represented on following figure: Simplified Client Workflow:
Registration of Transport FactoryThere are two ways to register transport factory: programmatic and via spring configuration.
Bus bus = BusFactory.getThreadDefaultBus();
DestinationFactoryManagerImpl dfm = bus.getExtension(DestinationFactoryManagerImpl.class);
CustomTransportFactory customTransport = new CustomTransportFactory();
dfm.registerDestinationFactory("http://cxf.apache.org/transports/TRANSPORT_PREFIX", customTransport);
dfm.registerDestinationFactory("http://cxf.apache.org/transports/ TRANSPORT_PREFIX/configuration", customTransport);
ConduitInitiatorManager extension = bus.getExtension(ConduitInitiatorManager.class);
extension.registerConduitInitiator("http://cxf.apache.org/transports/ TRANSPORT_PREFIX", sbbTransport);
extension.registerConduitInitiator("http://cxf.apache.org/transports/ TRANSPORT_PREFIX/configuration", customTransport);
Where TRANSPORT_PREFIX is protocol of new transport (http, https, jms, udp). Alternatively it is also possible to register transport factory using spring configuration: <bean class="org.company.cxf.transport.CustomTransportFactory" lazy-init="false"> <property name="transportIds"> <list> <value>http http://cxf.apache.org/transports/ TRANSPORT_PREFIX</value> <value>http://cxf.apache.org/transports/ TRANSPORT_PREFIX/configuration</value> </list> </property> </bean> To define new transport endpoint in WSDL document it is necessary: Sample:
<wsdl:definitions
xmlns:transport="http://cxf.apache.org/transports/TRANSPORT_PREFIX" …> …
…
<wsdl:binding name="GreeterPortBinding" type="tns: GreeterPortType">
<soap:binding style="document" transport=" http://cxf.apache.org/transports/TRANSPORT_PREFIX"/>
…
<wsdl:service name="GreeterService">
<wsdl:port binding="tns:GreeterPortBinding" name="GreeterPort">
<transport:address
…
Conduit and Destination LifecycleConduit and Destination lifecycle is requested from TransportFactory by every client or service creation. TransportFactory can either create Conduit and Destination for each request or cache them based on service endpoint information Concurrency AspectsConduit and Destination objects can by concurrently accessed by multiple threads. Implementations should care about concurrent correlations maps and/or synchronization primitives. References
Change Notification Preferences
View Online
|
View Changes
|
Add Comment
|
- [CONF] Apache CXF > Custom CXF Transport confluence
- [CONF] Apache CXF > Custom CXF Transport confluence
- [CONF] Apache CXF > Custom CXF Transport confluence
- [CONF] Apache CXF > Custom CXF Transport confluence
- [CONF] Apache CXF > Custom CXF Transport confluence
- [CONF] Apache CXF > Custom CXF Transport confluence
- [CONF] Apache CXF > Custom CXF Transport confluence
- [CONF] Apache CXF > Custom CXF Transport confluence
