Apache CXF framework helps you to develop a standards-based programming model and also provides a flexible deployment model for deploying web services. Developing SOAP and RESTful applications can be made easy by using Apache CXF framework. However, getting started with developing web services using the Apache CXF framework is not easy.
This is the first book that gives details on how to use the Apache CXF framework for developing SOAP and REST web services. It is a hands-on practical guide that simplifies working with CXF framework as it covers all major aspects with real-world examples. The chapters cover the various CXF features in detail and each has systematic steps with practical, simple examples to implement these features on your web services.
The instructions in this book will help developers to build their application according their requirements by using any of the frontends supported by Apache CXF framework. The various CXF frontend APIs covered in this book provide a wide variety of options in developing and deploying your application.
The book introduces some advanced concepts such as Interceptors and features that will add extra capability to your service component. It will help you take advantage of different transport features offered by the CXF runtime such as HTTP, HTTP(S), and JMS protocols.
Finally, the book mentions various tools that help developers creating web services as well as creating Java and JavaScript-based web services clients which invoke a real-world .NET web service. These tools are standard batch files that can be easily executed from the Windows command shell by following the instructions in the book.
A practical hands-on guide to show you how to develop and deploy SOAP and RESTful services using Apache CXF framework
What you will learn from this book:- Become familiar with the different features of Apache CXF architecture and set up the CXF environment
- Develop a simple web service using CXF-based Spring configuration
- Build a web service using contract-first and code-first approaches in simple frontend APIs such as JAX-WS
- Create dynamic web service clients by using various CXF frontend APIs
- Develop web services with different transports by configuring various CXF transports such as HTTP, HTTP(S), JMS, and CXF Local
- Create RESTful services that support JSON and XML as the message formats
- Develop services with features such as Interceptors by implementing advanced CXF features
- Attain configuration and dependency management by integrating web services with the de facto Spring framework
- Unit test POJO services in a stand-alone environment as well as promote applications to the Tomcat container for production ready deployments
- Speed-start developing web services by using CXF tools effectively
- Basics of Spring framework and IOC container for readers who are not acquainted with Spring framework
Who this book is written for This book is for developers who want to design and develop SOAP and RESTful services using Apache CXF framework and leverage various CXF features for service development. It is ideal for developers who have some experience in Java application development as well as some basic knowledge of web services, but it covers some of the basic fundamentals of web services and REST to get you acquainted with these technologies before using these concepts to develop services using the CXF framework.
About the Authors
Naveen Balani works as a Software Architect with WebSphere Business Services Fabric (WBSF) Product out of IBM India Software Labs, Mumbai. He has over 9 years of industrial experience and has architected and implemented large scale BPM solutions. He started working with Web Services way back in 2001 and proposed the first MVC web services-based pattern (http://www.ibm.com/developerworks/library/ws-mvc/) in 2002. He is a Master Author with IBM developer works having published over 60 publications. He has co-authored books on Spring framework (published by Wrox) and Multiple IBM Redbooks on WebSphere Business Services Fabric and BPM 6.2 Product deployments.
Rajeev Hathi is a senior technology consultant specializing in J2EE architecture and design. He has more that 10 years of industry experience in the area of design and development of J2EE-based projects. He has attained various professional certifications in Java that include SCJP, SCWCD, SCBCD, and SCEA – Part 1. He has written several articles on Java and DB2 for IBM developerWorks portal. His hobbies are music and sports.
|
Preface
Chapter 1: Getting Familiar with CXF - Web service technology standards
- XML
- SOAP (Simple Object Access Protocol)
- WSDL (Web Services Description language)
- REST (Representational State Transfer)
- Service Registry
- Introducing web services
- Approaches for web service development
- Web service SOAP communication styles
- Apache CXF
- History of CXF
- Why CXF?
- Support for web service standards
- Support for POJO (Plain Old Java Object)
- Frontend programming APIs
- Tools support
- Support for RESTful services
- Support for different transports and bindings
- Support for non-XML binding
- Ease of use
- Flexible deployment
- Setting up the environment
- For ANT users
- For Maven users
- Summary
Chapter 2: Developing a Web Service with CXF - The Order Processing Application
- Developing a service
- Creating a Service Endpoint Interface (SEI)
- Developing a service implementation class
- Spring-based server bean
- Developing a client
- Developing a Spring-based client bean
- Developing web service client code
- Running the program
- Building the code
- Deploying the code
- Executing the code
- CXF architecture
- Bus
- Frontend
- JAX-WS
- Simple frontend
- Messaging and Interceptors
- Service model
- Data binding
- Protocol binding
- Transports
- Summary
Chapter 3: Working with CXF Frontends - JAX-WS frontend
- Code-first development
- Creating Service Endpoint Interface (SEI)
- Adding Java annotations
- Publishing the service
- Developing a consumer
- Running the Code-first example
- Contract-first development
- Generating service components
- Implementing the service method
- Publishing the web service
- Invoking the web service
- Using dynamic client
- Creating a simple dynamic client
- Running the dynamic client
- Using the CXF service model for building dynamic client
- Running the dynamic client which uses Service Model API
- Provider and Dispatch services
- Understanding messaging modes
- Message mode
- Payload mode
- Understanding types of message objects
- javax.xml.transform.Source
- Implementing Provider service
- Publishing the Provider service
- Implementing the Dispatch service
- Running the provider dispatch example
- Web service context
- Implementing Context in service
- Running the web service context example
- Simple frontend
- Developing a simple frontend
- Creating service implementation class and interface
- Creating server implementation
- Creating client
- Running the simple frontend example
- Summary
Chapter 4: Learning about Service Transports - Transport protocols in CXF
- HTTP transport
- SOAP over HTTP
- HTTP only
- HTTP Conduit
- HTTP destination
- HTTPs transport
- Developing the service and implementation class
- Generating crypto key
- Creating client and server bean configuration
- Configuring the server to support SSL
- Developing the client component
- Building and deploying
- Configuring SSL for Jetty runtime
- JMS transport
- Developing the service and implementation class
- Developing an embedded broker
- Creating a server and client bean configuration
- Developing a client component
- Performing build and deployment
- Local transport
- Developing SEI and an implementation class
- Developing a server
- Creating client bean configuration
- Developing a Client
- Building and executing
- Summary
Chapter 5: Implementing Advanced Features - Understanding CXF interceptors
- Understanding interceptor phase and chain
- Overview of the interceptor API
- Interceptor interface
- The PhaseInterceptor interface
- The AbstractPhaseInterceptor class
- Developing the custom interceptor
- Developing the server side interceptor
- Adding a server side interceptor to the Order Process service
- Developing the client side interceptor
- Adding a client side interceptor to the client code
- Developing the standalone server for publishing the Order Process web service
- Building and running the Order Process web service and interceptor
- Building the code
- Executing the code
- Testing the custom interceptor for negative condition
- Understanding CXF features
- Applying the GZIP feature to the Order Process web service
- Developing service and implementation class
- Developing a server component
- Creating the client bean configuration file
- Creating a client component to consume the service
- Building and executing the code
- Understanding CXF Invoker
- Overview of Invoker API
- The Invoker interface
- The AbstractInvoker class
- Developing custom invoker
- Summary
Chapter 6: Developing RESTful Services with CXF - Overview of REST and RESTful services
- Java API for RESTful services
- CXF JAX-RS implementation
- Developing end-to-end RESTful services using CXF JAX-RS implementation
- Developing the RESTful service
- Creating Java data objects for Request and Response
- Providing binding for the Request and Response data objects
- Developing the implementation class
- Creating the client
- Running the program
- Building the code
- Deploying the code
- Executing the code
- Adding exception handling to RESTful service
- Summary
Chapter 7: Deploying RESTful Services with CXF - Packaging the Book Shop application
- Configuring CategoryService RESTful bean using Spring
- Integrating Spring using web.xml
- Building and deploying the WAR file
- Building the code
- Deploying the code
- Invoking operations on the Book Shop RESTful application
- Installing POSTER client
- Invoking the Book Shop application using the the POSTER tool
- Invoking the Get Category operation
- Invoking the Add Category operation
- Invoking the Update Category operation
- Invoking the Add Books operation
- Invoking the Get Books operation
- Invoking the Update Category operation with invalid request
- Invoking the Get Category operation with invalid request
- Invoking the Delete Category operation
- Invoking the Book Shop application using CXF APIs
- Configuring JSON support for the Book Shop application
- Incorporating JSON message format for the Book Shop application
- Invoking the Get Category operation with JSON as the message format
- Invoking the Add Category operation with JSON as the message format
- Invoking the Book Shop application with JSON as the message format using CXF APIs
- Intercepting messages for the Book Shop application
- Deploying the Book Shop application in the application servers
- Summary
Chapter 8: Working with CXF Tools - Invoking a web service using the Java client
- Analyzing the service WSDL definition
- Building and running the Java web service clients
- Generate the web service clients
- Analyzing the JAX-WS and client generated artifacts
- Modifying the generated client
- Building the client
- Running the client
- Invoking the web service using JavaScript
- Building and running the Java web service clients
- Generating the JavaScript client
- Analyzing the generated artifacts
- Creating the client
- Running the client
- Creating Service Implementation from the WSDL file
- Generating and deploying the Service Implementation from the WSDL file
- Generating the web Service Implementation
- Analyzing the Service Implementation generated artifacts
- Modifying the generated Service Implementation
- Building the web service project
- Deploying and publishing the web service
- Invoking the web service
- Validating WSDL files
- Summary
Appendix A: Getting Ready with Code Examples - Downloading the source code
- Downloading the software required for the book
- Setting up the environment
- Using Maven for Build management
- Building chapter source code using Maven
Appendix B: Getting Started with Spring - Concept of POJO-based development
- Understanding Inversion of Control
- Overview of aspect-oriented
- programming
- Introduction to Spring framework
- The Spring IoC container
- Creating a Spring IoC application
- Creating the entity model
- Creating services
- Creating the application and wiring POJO
- Creating the standalone client
- Running the program
- Building the code
- Executing the code
- Summary
Index
|