All Projects → santoshjoshi → camel-cxfrs-example

santoshjoshi / camel-cxfrs-example

Licence: Apache-2.0 license
Camel CXF Rest Example with JSON

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to camel-cxfrs-example

modules
Java & REST API's for creating and running integrations
Stars: ✭ 16 (-48.39%)
Mutual labels:  camel
pascalcase
Convert a string to pascal case (upper camel case). Used by more than 8.7 million projects on GitHub! Please follow this library's author: https://github.com/jonschlinkert
Stars: ✭ 35 (+12.9%)
Mutual labels:  camel
camel-lsp-client-vscode
This is a client implementation of the Apache Camel Language Server Protocol for Visual Studio Code
Stars: ✭ 24 (-22.58%)
Mutual labels:  camel
Camel
Apache Camel is an open source integration framework that empowers you to quickly and easily integrate various systems consuming or producing data.
Stars: ✭ 4,034 (+12912.9%)
Mutual labels:  camel
event-driven-microservices
No description or website provided.
Stars: ✭ 15 (-51.61%)
Mutual labels:  camel
camel-language-server
The Apache Camel LSP server implementation
Stars: ✭ 31 (+0%)
Mutual labels:  camel
camel-karavan
Karavan the Camel Integration Designer
Stars: ✭ 77 (+148.39%)
Mutual labels:  camel
camel-quarkus-examples
Apache Camel Quarkus Examples
Stars: ✭ 37 (+19.35%)
Mutual labels:  camel
camel-bindy-example
camel Bindy Example
Stars: ✭ 13 (-58.06%)
Mutual labels:  camel
kamel
Kotlin DSL for Apache Camel
Stars: ✭ 15 (-51.61%)
Mutual labels:  camel
camel-extra
Additional components for the Apache Camel integration framework
Stars: ✭ 32 (+3.23%)
Mutual labels:  camel
clj-camel
The library adds a thin idiomatic layer on top of Java Apache Camel
Stars: ✭ 38 (+22.58%)
Mutual labels:  camel
hawtio-integration
Core integration plugins for Hawtio: Apache ActiveMQ, Camel, Karaf, OSGi, and Spring Boot
Stars: ✭ 26 (-16.13%)
Mutual labels:  camel
akka-microservice
Example of a microservice with Scala, Akka, Spray and Camel/ActiveMQ
Stars: ✭ 45 (+45.16%)
Mutual labels:  camel
further-cdi
🔊 Going further with CDI presentation
Stars: ✭ 28 (-9.68%)
Mutual labels:  camel
camel-k-examples
Apache Camel K Examples
Stars: ✭ 48 (+54.84%)
Mutual labels:  camel
camel-kafka-connector-examples
Apache Camel Kafka Connector Examples
Stars: ✭ 45 (+45.16%)
Mutual labels:  camel
springboot-examples
SpringBoot、SpringCloud整合使用示例
Stars: ✭ 29 (-6.45%)
Mutual labels:  cxf
cxf-spring-boot-starter
Enterprise & production ready SOAP webservices powered by Spring Boot & Apache CXF
Stars: ✭ 129 (+316.13%)
Mutual labels:  cxf

Camel CXF Rest Example with JSON

#####Version Used:

  1. camel : 2.16.0
  2. CXF Version 3.1.3

Thie example demonstrates the use of apache camel to invoke a CXFRS service which returns JSON data.
The Client consumes this JSON data and then stores it into a file in json format

About The Example

The Example contains 3 modules

  1. CXFRS Service Module
  2. CXFRS Common Module
  3. CXFRS Client Module

#####CXFRS Service Module

This exposes a CXF REST service where a client hits the
http://localhost:8080/cxf-rest/services/country/{countrycode}
url with some country code to get country details in JSON Format

The CountryService creates a rest interface as shown below.

 public interface CountryService {  
 
   @GET  			
   @Path(value = "/country/{countryCode}")
   @Produces(MediaType.APPLICATION_JSON)  
   public Response getCountry(@PathParam("countryCode") String countryCode);
 
}  

#####CXFRS Common Module

This module contains POJOs that are shared by both client and service module.

  1. Country.java
  2. CountryResponse.java

service module populates it and client for consumes it.

#####CXFRS Client Module

This module calls a REST service hosted by service module with a country code like IN, CH, GE etc to get country information in JSON format, the JSON obtained is then marshalled to a country POJO and then save to a text file.

This module contains below java class

  1. Main.java
  2. CountryResource.java

CountyResource.java exposes an interface to the client for communication with the CXF REST Service defined by CXFRS service Module.

Main.java is basically for executing application.

A CXF Rest client has been created that hits the service hosted at
http://localhost:8080/cxf-rest/services
to fetch country details corrosponding to the passed country code.

A Camel route is written that executes as below

  1. Calls the cxf service by passing country code and obtains a country in JSON format
  2. unmarshals the JSON obtained to POJO and identifies whether the response is correct
  3. marshals the correct response to POJO
  4. saves the pojo to File.

#####Setting up the Example

  1. check out the example

  2. Go to cxf client module and adjust
    < jaxrs:client id="restClient" address="http://localhost:8080/cxf-rest/services"
    in cxf-services.xml

the service url to url where you want to deploy you rest application
3. execute mvn clean install

  1. deploy the cxf-rest war available in cxf-rest-service module to your favrioute web container

  2. Hit http://localhost:8080/cxf-rest/services/country/in
    in your favrioute browser. This will tell whether web context is up or not.

  3. execute mvn exec:exec from client module

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].