Hi
Please see the comments in lines.
Dan Diephouse wrote:
Hi Fabian,
What version of CXF are you using? I know there was a slight bug with
this
at some point (i.e. Endpoint.publish() doesn't find the correct CXF
instance
which is associated with the CXFServlet), so that may be part of the
problem.
Yes, when CXFServlet initiated the bus, it will set the BusFactory's
defaultBus to be null to avoid the other side effects.
If we want to use Endpoint.publish API , we need set the defaultBus with
the CXFServlet's bus.
But more likely is that you're registering the service with
http://localhost:8080/ and the servlet may expect you to register
http://localhost/ - since there is no way to query the port of the
servlet
from the servlet apis, we just assume that http://localhost/ maps to the
servlet whenever the CXFServlet is registered. Whats *really*
recommend is
just seting the address to "/services/fooEndpoint" though and leaving the
host out of it all together:
I just did a quick test by setting the address with the perfix of
"http://localhost/", it is not work with lastest CXF.
The key issue is now we update the endpoint Address on fly according to
the request url, and the endpoint point address
would not be updated if the address start with "http://localhost/***" .
Because it is hard to filter the http://localhost/{contextpath} when CXF
creates the endpointInfo.
So the high recommend is to use the related PATH as the service address.
Endpoint.publish("/services/fooEndpoint", new MyServiceImpl());
CXF assumes HTTP by default if no host is present.
Let me know if any of those suggestions work!
- Dan
On 5/30/07, Fabian <[EMAIL PROTECTED]> wrote:
Hi!
I started to have a look at CXF today. In XFire I was able to start a
Jetty HTTPServer, register the XFireServlet and later make services
available via the XFire ServiceRegistry.So I was able to use a Jetty
HTTPServer I created myself. I would like to do the same with CXF.
Using the JaxWsServerFactoryBean as suggested in the Migration Guide
does not work because I want to reuse the HTTPServer I already have and
don't want to start a new one (under another port). So I thought the
CXFServlet should be the proper replacement. But I am not sure what I
need to do to register a new service. Calling Endpoint.create() as
explained in http://cwiki.apache.org/CXF20DOC/servlet-transport.html
does not work. (I can request the service list at
http://localhost:8080/services but the list is empty). So I guess I have
to do something with my Endpoint but what?
// jetty
Server httpServer = new Server(8080);
Context xfireContext = new Context(httpServer, "/services");
xfireContext.addServlet(CXFServlet.class.getName(), "/*");
httpServer.start();
// register service
String uri = "http://localhost:8080/services/" +
ServiceImplementation.class.getSimpleName();
Endpoint.create(uri, new ServiceImplementation());
Maybe one of you can give me a tip which way to go here.
Thanks!
Fabian
P.S. In XFire it worked like this
Server httpServer = new Server(8080);
Context xfireContext = new Context(httpServer, "/services");
xfireContext.addServlet(XFireServlet.class.getName(), "/*");
httpServer.start();
[....]
XFire xfire = XFireFactory.newInstance().getXFire();
// create service
AnnotationServiceFactory factory = new
AnnotationServiceFactory(xfire.getTransportManager())
Service service = factory.create(serviceImplementation.getClass());
service.setInvoker(new BeanInvoker(serviceImplementation));
// register
ServiceRegistry serviceRegistry = xfire.getServiceRegistry()
serviceRegistry.register(service);
Cheers,
Willem.