170 likes | 526 Views
Apache CXF. Francisco Gonzalez Mario Rincon. CXF. Apache CXF is an open source services framework. CXF helps you build and develop services using frontend programming APIs, like JAX-WS and JAX-RS.
E N D
Apache CXF Francisco Gonzalez Mario Rincon
CXF • Apache CXF is an open source services framework. • CXF helps you build and develop services using frontend programming APIs, like JAX-WS and JAX-RS. • These services can speak a variety of protocols such as SOAP, XML/HTTP, RESTful HTTP, or CORBA and work over a variety of transports such as HTTP, JMS or JBI.
Why CXF? • JAX-WS Support • Spring Integration • Aegis Databinding • RESTful services • WS-* Support • Apache Licensed
Services CXF support three major types of services: • SOAP • REST-ful • CORBA
Front-ends Programming model for application interactions with CXF Three main variations: • JAX-RS (configured with annotations and/or XML) • JAX-WS (configured with annotations and optionally XML) • Simple (limited compared to JAX-WS, but no annotations required)
Transport • HTTP Transport: There is a Servlet transport for those who are deploying into a Servlet container. There is also a standalone HTTP server based on Jetty. • JMS: CXF's JMS transport plug-in uses the Java Naming and Directory Interface (JNDI) to locate and obtain references to the JMS provider that brokers for the JMS destinations. • Local Transport
Transport • CXF includes a "local" transport. This transport allows you to send messages more efficiently inside a JVM. The messages will serialized and piped from one endpoint to another. • The local transport supports URIs of the structure "local://{endpoint_name}" To use the local transport you simply need to set your address to a local URI.
Data Bindings • CXF uses JAXB 2.x as its default databinding. • XMLBeans. • Aegis data binding will turn nearly any Java object into something that can be represented using schema, including Maps, Lists, and unannotated java types. • SourceDataBinding for Source objects.
RESTful Services There are different ways to build RESTful services with CXF. • JAX-RS: CXF has an implementation of JAX-RS. This provides a more standard way to build RESTful services in JAVA. • JAX-WS Provider and Dispatch: It is possible to create RESTful services with the JAX-WS Provider and Dispatch APIs. • HTTP Binding: The HTTP binding provides a flexible way of creating resources and mapping them to operations in your service. Note : HTTP Binding has been deprecated and is likely to be removed from CXF in one of its future releases.
JAX-WS Annotated Services from Java JAX-WS includes many more annotations such as: • @WebMethod - customize the operation name, exclude the operation from inclusion in the service, etc • @WebParam - customize a parameter's name, namespace, direction, etc • @WebResult - customize the return value of the web service call
JAX-WS Annotated Services from WSDL • If you have existing WSDLs for your service or wish to write your WSDL first and then generate classes, CXF has many tools to help you do this. • The WSDL2Java tool will generate a JAX-WS annotated service and server stub from your WSDL. You can run it one of three ways: • The command line • The Maven Plugin • With the WSDL2Java API
Simple Frontend • Sometimes you don't want to annotate classes or use the JAX-WS APIs. • CXF includes a Simple Frontend which allows you to take nearly any class and make a service out of it with absolutely no extra work.
Most Applications Should Use JAX-WS The JAX-WS frontend is far more flexible than the Simple frontend. There are only two reasons to select Simple over JAX-WS: • You must avoid the use of Java annotations. JAX-WS requires them, Simple does not. • You want to have the absolutely smallest possible collection of additional dependencies. JAX-WS has more dependencies than Simple.
WS-* Support • WS-Addressingadds message identification and routing information • WS-Policyadds XML encryption and signing • WS-ReliableMessagingadds message acknowledgement and retransmission • WS-SecureConversation enterprise authentication and ongoing exchanges • WS-Security • WS-SecurityPolicyto configure • WS-Trust enterprise authentication and ongoing exchanges
CXF Summary • Very flexible Java web services stack • Most complete REST support • SOAP WS-* support close to the best • Different configuration options adapt to widest range of application scenarios • OSGisupport adding even more flexibility • Also the best supported • Great approach for building web services