Hi,
If you want to your customer transport to override cxf http transport,
you should register those transport ids with your customer transport
http://cxf.apache.org/transports/http
http://cxf.apache.org/transports/http/configuration
http://schemas.xmlsoap.org/wsdl/http
http://schemas.xmlsoap.org/wsdl/http/
which already defined in bus-extensions.xml for both rt/transports/
http and rt/transports/http-jetty,
the register transport part is incorrect, it should be
Bus bus = BusFactory.getDefaultBus()
DestinationFactoryManagerImpl dfm = new
DestinationFactoryManagerImpl(bus);
SBBTransportFactory sbbTransport = new
SBBTransportFactory();
dfm.registerDestinationFactory("http://cxf.apache.org/transports/sbb
", sbbTransport);
dfm.registerDestinationFactory("http://cxf.apache.org/transports/http
", sbbTransport);
dfm.registerDestinationFactory("http://cxf.apache.org/transports/http/configuration
", sbbTransport);
dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/http
", sbbTransport);
dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/http/
", sbbTransport);
ConduitInitiatorManager extension =
bus.getExtension(ConduitInitiatorManager.class);
extension.registerConduitInitiator("http://cxf.apache.org/transports/sbb
", sbbTransport);
extension.registerConduitInitiator("http://cxf.apache.org/transports/http
", sbbTransport);
extension.registerConduitInitiator("http://cxf.apache.org/transports/http/configuration
", sbbTransport);
extension.registerConduitInitiator("http://schemas.xmlsoap.org/wsdl/http
", sbbTransport);
extension.registerConduitInitiator("http://schemas.xmlsoap.org/wsdl/http/
", sbbTransport);
with this change, all your testcase pass.
Freeman
On 2011-1-17, at 下午8:30, Andrei Shakirin wrote:
Hi folks,
By developing of custom CXF transport factory I faced one strange
behavior looks like a bug.
Scenario:
1. I register my factory using
Bus bus = BusFactory.getDefaultBus();
DestinationFactoryManagerImpl dfm = new
DestinationFactoryManagerImpl(bus);
SBBTransportFactory sbbTransport = new
SBBTransportFactory();
dfm.registerDestinationFactory("http://cxf.apache.org/transports/sbb
", sbbTransport);
dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/http
", sbbTransport);
dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/http
", sbbTransport);
ConduitInitiatorManager extension =
bus.getExtension(ConduitInitiatorManager.class);
extension.registerConduitInitiator("http://cxf.apache.org/transports/sbb
", sbbTransport);
extension.registerConduitInitiator("http://schemas.xmlsoap.org/soap/http
", sbbTransport);
extension.registerConduitInitiator("http://schemas.xmlsoap.org/wsdl/soap/http
", sbbTransport);
2. If I call consumer via ClientProxyFactoryBean or via Service
without WSDL URL:
Service service = Service.create(SERVICE_NAME);
HelloWorld hw = service.getPort(HelloWorld.class);
hw.write(TEST_REQUEST);
my factory is activated as expected -ok.
3. If I try to call consumer via Service, but additionally pass WSDL
URL:
URL wsdlURL = this.getClass().getResource("/HelloWorld.wsdl");
Service service = Service.create(wsdlURL, SERVICE_NAME);
HelloWorld hw = service.getPort(HelloWorld.class);
String result = hw.sayHi(TEST_REQUEST);
my factory is not activated.
But if I make the same registration again after getPort() call - it
works.
It seems that registration in this case is somehow overwritten and
should be actualized.
I attach the small project illustrated this effect.
consumerRequestResponseOK - use service without WSDL URL
consumerRequestResponseFailed - iluustrates the problem
consumerRequestResponseFixed - shows the fix.
Another workaround is just to read DestinationFactory and
ConduitInitor before registration (call printRegistration() in
setup()).
Do you have any ideas regarding this effect?
For me it looks like a bug.
Regards,
Andrei.
<cxf-transport-registration.zip>
--
Freeman Fang
------------------------
FuseSource: http://fusesource.com
blog: http://freemanfang.blogspot.com
twitter: http://twitter.com/freemanfang
Apache Servicemix:http://servicemix.apache.org
Apache Cxf: http://cxf.apache.org
Apache Karaf: http://karaf.apache.org
Apache Felix: http://felix.apache.org