Chapter 12. Web Services

In this chapter, we will cover the following recipes:

  • Generating the service stubs from a WSDL
  • Invoking a remote web service from Camel
  • Implementing a web service with a Camel route
  • Providing multiple web service operations within a single route
  • Handling web service faults
  • Web service proxying

Introduction

In this chapter, we will explore Camel's capabilities for interacting with SOAP web services, which are commonly used in integration technology. Camel strongly supports the Apache CXF project (http://cxf.apache.org/) as a web services framework. As such it is very easy to use CXF to create Camel routes that can both call external web services and act as web service listeners. This chapter's recipes will show you some of the common scenarios for web service integration with Camel that will provide a starting point for your continued exploration of these capabilities.

Note

The CXF library supports both SOAP through the Java API for XML Web Services (JAX-WS), and REST through the Java API for RESTful Web Services (JAX-RS). This chapter will focus on SOAP web services based on service contracts defined using the Web Service Definition Language (WSDL).

CXF is a very rich library with extensive support for the WS-* set of standards. For details on how to make use of these, you should refer to the CXF website.

There are generally two approaches for building SOAP web services:

  1. Define a contract for the service through a WSDL file, and then generate JAX-WS and JAXB (Java Architecture for XML Binding) annotated Java classes and interfaces from that WSDL. This will provide you with a foundation upon which the service implementation will be built. This is known as contract-first development. In system integration, this style of development tends to be the most common way to develop services, as both the service provider and its clients agree on the service interface up front.
  2. Build a regular Java service, then annotate it and its supporting data transfer objects with JAX-WS and JAXB annotations. This is known as service-first development. Service-first development tends to be more tactical in nature, allowing you to expose classes that were developed with another interface in mind over SOAP.

This chapter will focus on contract-first web service development.

A number of Camel architectural concepts are used throughout this chapter. There is a broader overview of Camel concepts in the Preface. Full details can be found at the Apache Camel website at http://camel.apache.org.

The code for this chapter is contained within the camel-cookbook-web-services module of the examples.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.116.62.168