cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Fabian <maillingli...@christina-reysen.com>
Subject Use CXFServlet programmatically (moving from XFire to CXF)
Date Wed, 30 May 2007 13:10:44 GMT
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);


Mime
View raw message