| Apache CXF Documentation > Index > XFire Migration Guide |
| XFire Feature | CXF Analogue |
|---|---|
| Aegis Binding | Ported. |
| Configurable Servlet | See the Servlet Transport page. |
| Eclipse Plugin |
Eclipse tooling supported via the SOA Tools project. |
| HTTP Transport | Ported. |
| JMS Transport | Ported. |
| JAX-WS/JSR-181 Annotation Support | Ported and CXF passes the JAX-WS/JWS TCKs. |
| JAXB | Ported. |
| MTOM |
Ported |
| services.xml | Spring 2 XML will be supported for easy configuration. See the Configuration section. |
| Spring: XFireClientFactoryBean | See the ClientProxyFactoryBean and JaxWsProxyFactoryBean. |
| Spring: XFireExporter | Not ported as the *ServerFactoryBeans already enable this functionality. See below. |
| Spring: ServiceBean | Completed. See ServerFactoryBean and JaxWsServerFactoryBean. |
| WS-Addressing |
CXF has much better WS-Addressing support and its easier to use as well. |
| WS-Security | Ported. |
| XMLBeans | Not ported. Will be supported in CXF 2.1 |
For more details on how to migrate:
XFire users should consider migrating to CXF. Anyone looking to start a new web services project should seriously consider CXF. The main barrier is liable to be documentation at this moment. We will be adding LOTS more documentation though over the next couple weeks as we move toward the 2.0 final release.
CXF includes many new features for XFire users:
There a couple small areas where we haven't replicated all of the XFire functionality yet. Namely the JiBX and XMLBeans databindings. These will be ported for CXF 2.1. The only other reason not to migrate to CXF that we see is a requirement for Java 1.4. Although, we would encourage users to take a look at using CXF on Java 1.4 via Retrotranslator
(but be sure to read this thread
first).
XFire included serveral service factories for building services. CXF also includes service factories, but the concept has been improved somewhat to make them easier to use. CXF now includes the concept of ServerFactoryBeans which produce Servers, ClientFactoryBeans which produce Clients, and ClientProxyFactoryBeans which produce Client proxies.
CXF now includes the following classes:
Its important to keep in mind a few differences in how CXF works compared to XFire:
|
Here is an example of using the ObjectServiceFactory in XFire: ObjectServiceFactory osf = new ObjectServiceFactory(); Service service = osf.create(MyServiceInterface.class); service.setInvoker(new BeanInvoker(new MyServiceImpl()); |
This would be the CXF equivalent: ServerFactoryBean sf = new ServerFactoryBean(); sf.getServiceFactory().setDataBinding(new AegisDatabinding(); sf.setServiceBean(new MyServiceImpl()); sf.setServiceClass(MyServiceInterface.class); sf.setAddress("http://localhost:8080/myservice"); sf.create(); |
|
Here is an example of using the AnnotationServiceFactory in XFire: AnnotationServiceFactory osf = new AnnotationServiceFactory(); Service service = osf.create(MyServiceInterface.class); service.setInvoker(new BeanInvoker(new MyServiceImpl()); |
This would be the CXF equivalent: JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean (); sf.getServiceFactory().setDataBinding(new AegisDatabinding()); sf.setServiceClass(MyServiceImpl.class); sf.setAddress("http://localhost:8080/myservice"); sf.create(); |
|
Here is an example of using the JAXWSServiceFactory in XFire: JAXWSServiceFactory sf = new JAXWSServiceFactory(); Service service = sf.create(MyServiceImpl.class); service.setInvoker(new BeanInvoker(new MyServiceImpl()); |
This would be the CXF equivalent: JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean(); sf.setServiceClass(MyServiceImpl.class); sf.setAddress("http://localhost:8080/myservice"); sf.create(); |
CXF supports a much wider range of options for deploying your service over HTTP. XFire created a static mapping between the HTTP URL and the service name - i.e. a service named "HelloService" was accessible at http://localhost/services/HelloService
. CXF on the other hand allows you to control the URL which your service is published on. This address is provided to CXF either through the setAddress() call on the ServerFactoryBeans or via your XML configuration.
Another improvement over XFire is that CXF will now transparently detect whether the CXFServlet is being used. If it is, your service will be available on that location. If it is not, CXF will automatically start an embedded Jetty instance (provided the cxf-rt-transports-http-jetty module is on your classpath). No more calls to XFireHttpServer are needed!
To set up the CXF servlet, please read the how-to on the Servlet Transport page.
To use the embedded Jetty instance, no extra work is needed. Simply follow the above ServiceFactory examples.
XFire included support for deploying your services via a services.xml file. In CXF this file is named cxf.xml and will be loaded by the CXFServlet
|
XFire services.xml example: <beans xmlns="http://xfire.codehaus.org/config/1.0"> <service xmlns:t="urn:my:namespace"> <name>testservice</name> <serviceClass>org.example.TestService </serviceClass> <implementationClass>org.codehaus.xfire.spring.TestServiceImpl</implementationClass> <namespace>urn:my:namespace</namespace> <serviceFactory>org.codehaus.xfire.jaxws.JAXWSServiceFactory</serviceFactory> <properties> <property key="myKey">value</property> </properties> <inHandlers> <handler handlerClass="org.codehaus.xfire.spring.TestHandler"/> </inHandlers> </service> </beans> |
CXF example: <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"> <import resource="classpath:META-INF/cxf/cxf.xml" /> <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/> <import resource="classpath:META-INF/cxf/cxf-servlet.xml" /> <jaxws:endpoint address="http://localhost/testService" serviceName="t:testService" xmlns:t="urn:my:namespace"> <jaxws:implementor> <bean class="org.example.TestServiceImpl"/> </jaxws:implementor> <jaxws:properties> <entry key="foo" value="bar"/> </jaxws:properties> <jaxws:inInterceptors> <bean class="org.example.ExampleInterceptor"/> </jaxws:inInterceptors> </jaxws:endpoint> </beans> |
There are a few important things to note here on the differences:
The above sample is for JAX-WS/JSR181 services. For those developing services without annotations, here's an example for the Simple Frontend"
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:simple="http://cxf.apache.org/simple" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/simple http://cxf.apache.org/schemas/simple.xsd"> <simple:server address="http://localhost/testService" serviceClass="org.example.TestService"> <simple:serviceBean> <bean class="org.example.TestServiceImpl"/> </simple:serviceBean> <simple:properties> <entry key="foo" value="bar"/> </jaxws:properties> <simple:inInterceptors> <bean class="org.example.ExampleInterceptor"/> </simple:inInterceptors> </simple:server> </beans>