OK, dug into the coloc stuff and discovered a nasty bug in the
ColocFeature that really only allows it to be used for a single client
in the VM. :-( You can get around that by creating the coloc in/out
interceptors directly and adding them to the client.
For the coloc stuff to work, the ServiceName and EndpointName have to
EXACTLY match on both sides. When using the factories, it's best to
specify those:
factory.setEndpointName(epname);
factory.setServiceName(epname);
If you don't explicitely set them, it computes default values which
may not match. For example, something like "FooImpl" on the server
and just "Foo" on the client.
Back to the "local" stuff.... What you have there should work
fine. When you create the client, you would use the "local" address.
Dan
On Jun 18, 2008, at 5:02 PM, Dan Dubinsky wrote:
The stuff with the DestinationFactory and Conduits I took from from
the docs
at http://cwiki.apache.org/CXF20DOC/local-transport.html (the
section on
simple front end). It does seem to enable local:\\ access, but at the
expense of http:\\ access.
I'm using the simple front end. Maybe this is the problem? Should
you be
able to access the same service as both local and http with the
simple front
end?
Also I'm initializing my services in code, not with configuration
files. I
tried the coloc feature but it didn't seem to work. I tried adding
the coloc
feature by doing :
ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
factory.getClientFactoryBean().getFeatures().add(new ColocFeature());
but I'm not 100% sure it was the right way to do it because it
didn't seem
to have any effect.
This is how I'm creating the http:// reference
DestinationFactoryManager dfm =
getBus().getExtension(DestinationFactoryManager.class);
ServerFactoryBean sf = new ServerFactoryBean();
sf.setDestinationFactory( dfm.getDestinationFactoryForUri("http://" +
name));
sf.setServiceClass(def.serviceInterface);
sf.setServiceBean(def.serviceImplementation);
sf.setAddress("/" + name);
sf.getServiceFactory().setDataBinding(new AegisDatabinding());
sf.create();
This is what I'm using to create the local:// reference
ServerFactoryBean sf = new ServerFactoryBean();
sf.setServiceClass(serviceInterface);
sf.setServiceBean(serviceBean);
sf.setAddress("local://local" + serviceName);
sf.getServiceFactory().setDataBinding(new AegisDatabinding());
sf.create();
The client looks like this:
ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
factory.getClientFactoryBean().getFeatures().add(new ColocFeature());
factory.setServiceClass(serviceInterface);
factory.setAddress(serviceURL);
factory.setDataBinding(new AegisDatabinding());
service = factory.create();
Do you have any other thoughts? This is the one last thing I have
left to
work out before I am able to switch from XFire to CXF.
Thanks a lot.
dkulp wrote:
Two thoughts:
1) I don't think you should need to mess with the DestinationFactory
and conduits and such. The default setup may be fine depending on
how you create your services/clients. If you use two separate
<jaxws:server> or <jaxws:endpoint> in your config, you can have one
that specifies the bindingUri="http://cxf.apache.org/transports/
local"
to force that one on the local destination. Likewise, if you use
the
client factories, you can specify which binding to use. (make sure
you use the correct address as well)
2) THAT all said, look at the in_jvm_transport sample in our
release. Basically, if you enable a "coloc" feature, it will pretty
much be automatic. The runtime will automatically detect if the
client/server are using the same bus, it will just work. I think
the coloc also bypasses all marshalling (pass by reference symantics)
which makes it faster as well.
Dan
On Jun 17, 2008, at 11:42 AM, Dan Dubinsky wrote:
I have a web app with some services in the same war file that I want
to call
using local://servicename. These same services I would like to be
able to
call remotely using http://server/webapp/services/servicename from
external
applications. This worked out of the box in XFire, but I'm having
trouble
getting it to work is CFX.
If I add the following to my servlet serving up the services then
local
works, but http doesn't. If I take it out http works, but not local.
DestinationFactoryManager dfm =
bus.getExtension(DestinationFactoryManager.class);
LocalTransportFactory localTransport = new LocalTransportFactory();
dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/
http",
localTransport);
dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/http
",
localTransport);
dfm.registerDestinationFactory("http://cxf.apache.org/bindings/
xformat",
localTransport);
dfm.registerDestinationFactory("http://cxf.apache.org/transports/
local",
localTransport);
ConduitInitiatorManager extension =
bus.getExtension(ConduitInitiatorManager.class);
extension.registerConduitInitiator("http://cxf.apache.org/transports/local
",
localTransport);
extension.registerConduitInitiator("http://schemas.xmlsoap.org/wsdl/soap/http
",
localTransport);
extension.registerConduitInitiator("http://schemas.xmlsoap.org/soap/http
",
localTransport);
extension.registerConduitInitiator("http://cxf.apache.org/bindings/xformat
",
localTransport);
The error I get if I take this out and try an http call is:
java.lang.IllegalStateException: Local destination does not have a
MessageObserver on address http://server/webapp/services/servicename
--
View this message in context:
http://www.nabble.com/Can-local%3A---and-http%3A---addresses-coexist-on-the-same-server-tp17916451p17916451.html
Sent from the cxf-user mailing list archive at Nabble.com.
---
Daniel Kulp
[EMAIL PROTECTED]
http://www.dankulp.com/blog
--
View this message in context:
http://www.nabble.com/Can-local%3A---and-http%3A---addresses-coexist-on-the-same-server-tp17916451p17991805.html
Sent from the cxf-user mailing list archive at Nabble.com.
---
Daniel Kulp
[EMAIL PROTECTED]
http://www.dankulp.com/blog