Return-Path: Delivered-To: apmail-incubator-cxf-user-archive@locus.apache.org Received: (qmail 63888 invoked from network); 31 May 2007 05:35:22 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 31 May 2007 05:35:22 -0000 Received: (qmail 55932 invoked by uid 500); 31 May 2007 05:35:26 -0000 Delivered-To: apmail-incubator-cxf-user-archive@incubator.apache.org Received: (qmail 55751 invoked by uid 500); 31 May 2007 05:35:25 -0000 Mailing-List: contact cxf-user-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: cxf-user@incubator.apache.org Delivered-To: mailing list cxf-user@incubator.apache.org Received: (qmail 55742 invoked by uid 99); 31 May 2007 05:35:25 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 May 2007 22:35:25 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of ning.jiang@iona.com designates 65.223.216.181 as permitted sender) Received: from [65.223.216.181] (HELO amereast-smg1.iona.com) (65.223.216.181) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 May 2007 22:35:16 -0700 Received: from amer-ems1.IONAGLOBAL.COM ([10.65.6.25]) by amereast-smg1.iona.com (Switch-3.1.7/Switch-3.1.7) with ESMTP id l4V5XElp018956 for ; Thu, 31 May 2007 01:33:17 -0400 (EDT) Received: from [127.0.0.1] ([10.129.9.181]) by amer-ems1.IONAGLOBAL.COM with Microsoft SMTPSVC(6.0.3790.1830); Thu, 31 May 2007 01:34:46 -0400 Message-ID: <465E5E54.7090300@iona.com> Date: Thu, 31 May 2007 13:34:12 +0800 From: Willem Jiang User-Agent: Thunderbird 1.5.0.10 (Windows/20070221) MIME-Version: 1.0 To: cxf-user@incubator.apache.org Subject: Re: Use CXFServlet programmatically (moving from XFire to CXF) References: <465D77D4.3080409@christina-reysen.com> In-Reply-To: <465D77D4.3080409@christina-reysen.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 31 May 2007 05:34:47.0837 (UTC) FILETIME=[66EF2CD0:01C7A345] X-Virus-Checked: Checked by ClamAV on apache.org Hi Fabian, There is a Jetty transport factory which responsible is to handle the http transport with the embedded Jetty in CXF, we call the service which is published by that way, a standalone server. We also support to publish the service with CXFServlet transport. It is much like the Xfire Servlet dose. You definitely can start a Jetty HTTPServer and register the CXFServlet to it then publish the service with JAXWS API or JaxWsServerFactoryBean. But most important thing you need to take care is the bus instance, it is newer to Xfire user. You can find more information about the CXF bus from [1]. I also found there some error in the document [2], I will fix soon. I just changed some of you below codes and ran with latest CXF trunk, it works. You can access the service with http://localhost:9000/services/GreeterImpl You also can get the services list form http://localhost:9000/services Server httpServer = new Server(9000); ContextHandlerCollection contexts = new ContextHandlerCollection(); httpServer.setHandler(contexts); Context root = new Context(contexts,"/services",Context.SESSIONS); CXFServlet servlet = new CXFServlet(); root.addServlet(new ServletHolder(servlet), "/*"); httpServer.start(); // set the default bus which is initiated for CXFServlet for jaxws API or JaxWsServerFactoryBean to use Bus bus = servlet.getBus(); // there is no bus definition in the JAXWS API, so we need to set the default bus. BusFactory.setDefaultBus(bus); // register service, the address should start with "/" String uri = "/" + GreeterImpl.class.getSimpleName(); Endpoint endpoint = Endpoint.create(new GreeterImpl()); endpoint.publish(uri); [1] http://cwiki.apache.org/CXF20DOC/cxf-architecture.html [2] http://cwiki.apache.org/CXF20DOC/servlet-transport.html Cheers, Willem. Fabian 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); > > >