GithubHelp home page GithubHelp logo

santoshjoshi / camel-cxfrs-example Goto Github PK

View Code? Open in Web Editor NEW
30.0 8.0 30.0 89 KB

Camel CXF Rest Example with JSON

License: Apache License 2.0

Java 100.00%
cxf java cxf-service cxfrs-service camel camel-cxf-rest

camel-cxfrs-example's Introduction

Camel CXF Rest Example with JSON

This example demonstrates the use of Apache Camel to invoke a CXF Restful web service that returns JSON data. The client consumes this JSON data and stores it into a file in JSON format.

Version Used

  • camel: 2.16.0
  • CXF Version: 3.1.3

Modules

The example consists of three modules:

  1. CXFRS Service Module:

    • This module exposes a CXF REST service where a client can hit the endpoint http://localhost:8080/cxf-rest/services/country/{countrycode} with a country code to retrieve country details in JSON format.

    • The CountryService interface defines the REST interface:

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

    • This module contains the POJOs shared by both the client and service modules.
    • It includes Country.java and CountryResponse.java classes which are populated by the service module and consumed by the client module.
  3. CXFRS Client Module:

    • This module calls the REST service hosted by the service module, providing a country code (e.g., IN, CH, GE) to retrieve country information in JSON format.
    • The JSON response is then unmarshalled to a POJO and saved to a file.

Getting Started

To run this example:

  1. Check out the project from GitHub.
  2. Adjust the service URL in cxf-services.xml file in the CXF client module to the URL where you want to deploy your REST application.
  3. Build the project using Maven:

mvn clean install

  1. Deploy the cxf-rest WAR available in the cxf-rest-service module to your favorite web container.
  2. Verify that the web context is up by hitting http://localhost:8080/cxf-rest/services/country/in in your favorite browser.
  3. Execute mvn exec:exec from the client module to run the client application.

camel-cxfrs-example's People

Contributors

dependabot[bot] avatar jwhite78 avatar santoshjoshi avatar scuilion avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

camel-cxfrs-example's Issues

client module run problem

The client module gives me below exception:
Exception in thread "main" org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from relative location [cxf-services.xml]
Offending resource: class path resource [camel-context.xml]; nested exception is org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 24 in XML document from class path resource [cxf-services.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 24; columnNumber: 73; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'jaxrs:client'.
at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:70)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:76)
...

Unable to build as-is

Hi,

I tried to download this example and build it but it fails. I am not sure whether this example is dependent on the Camel examples and if I have to download and build the examples first...

The POM files of the modules seems to point to the "examples":

<parent>
    <artifactId>examples</artifactId>
    <groupId>org.apache.camel</groupId>
    <version>0.0.1-SNAPSHOT</version>
    <relativePath>../pom.xml</relativePath>
</parent>

Any tips would be helpful...

Cheers

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.