<commit_before># RESTful web services with CXF

## Overview
This example demonstrates how to create a RESTful (JAX-RS) Web service using CXF and expose it with the OSGi HTTP Service.

## What You Will Learn
In studying this example you will learn:

* how to configure the JAX-RS Web services by using the blueprint configuration file.
* how to use JAX-RS annotations to map methods and classes to URIs
* how to use JAXB annotations to define beans and output XML responses
* how to use the JAX-RS API to create HTTP responses

## Prerequisites
Before building and running this example you need:

* Maven 3.0.3 or higher
* JDK 1.6 or 1.7
* Fuse ESB Enterprise 7

## Files in the Example
* `pom.xml` - the Maven POM file for building the example
* `src/main/java/org/fusesource/examples/cxf/jaxrs/security/Customer.java` - a Java class defining the JAXB representation of the Customer element processed by the example
* `src/main/java/org/fusesource/examples/cxf/jaxrs/security/CustomerService.java` - a Java class implementing the service that handles customer requests using JAXRS
* `src/main/java/org/fusesource/examples/cxf/jaxrs/security/Order.java` - a Java class defining the JAXB representation of the Order element processed by the example. It also defines a JAXRS sub-resource that processes orders.
* `src/main/java/org/fusesource/examples/cxf/jaxrs/security/Prooduct.java` - a Java class defining the JAXB representation of the Product element used in the orders
* `src/main/java/org/fusesource/examples/cxf/jaxrs/security/client/Client.java` - a Java class implementing an HTTP client that can be used to test the service
* `src/main/resources/org/fusesource/examples/cxf/jaxrs/security/client/*.xml` - data files used by the client to test the service
* `src/main/resources/OSGI-INF/blueprint/blueprint.xml` - the OSGI Blueprint file that defines the services

## Building the Example
To build the example:

1. Change your working directory to the `examples/secure-rest` directory.
2. Run `mvn clean install` to build the example.

## Running the Example
To run the example:

1. Start Fuse ESB Enterprise 7 by running `bin/fuseesb` (on Linux) or `bin\fuseesb.bat` (on Windows).
2. In the Fuse ESB console, enter the following command:
        osgi:install -s fab:mvn:org.fusesource.examples/secure-rest/${project.version}

There are several ways you can interact with the running RESTful Web services:
* browse the Web service metadata
* access the service in a Web browser
* use a Java client
* use a command-line utility


### Browsing Web service metadata

A full listing of all CXF Web services is available at

    http://localhost:8181/cxf

After you deployed this example, you will see the following endpoint address appear in the 'Available RESTful services' section:

    http://localhost:8181/cxf/securecrm

Just below it, you'll find a link to the WADL describing all the root resources:

    http://localhost:8181/cxf/securecrm?_wadl

You can also look at the more specific WADL, the only that only lists information about 'customerservice' itself:

	http://localhost:8181/cxf/securecrm/customerservice?_wadl&_type=xml
<commit_msg>[ENTESB-431]revise the README.md to clearly mention we need have<commit_after># RESTful web services with CXF

## Overview
This example demonstrates how to create a RESTful (JAX-RS) Web service using CXF and expose it with the OSGi HTTP Service.

## What You Will Learn
In studying this example you will learn:

* how to configure the JAX-RS Web services by using the blueprint configuration file.
* how to use JAX-RS annotations to map methods and classes to URIs
* how to use JAXB annotations to define beans and output XML responses
* how to use the JAX-RS API to create HTTP responses

## Prerequisites
Before building and running this example you need:

* Maven 3.0.3 or higher
* JDK 1.6 or 1.7
* Fuse ESB Enterprise 7

## Files in the Example
* `pom.xml` - the Maven POM file for building the example
* `src/main/java/org/fusesource/examples/cxf/jaxrs/security/Customer.java` - a Java class defining the JAXB representation of the Customer element processed by the example
* `src/main/java/org/fusesource/examples/cxf/jaxrs/security/CustomerService.java` - a Java class implementing the service that handles customer requests using JAXRS
* `src/main/java/org/fusesource/examples/cxf/jaxrs/security/Order.java` - a Java class defining the JAXB representation of the Order element processed by the example. It also defines a JAXRS sub-resource that processes orders.
* `src/main/java/org/fusesource/examples/cxf/jaxrs/security/Prooduct.java` - a Java class defining the JAXB representation of the Product element used in the orders
* `src/main/java/org/fusesource/examples/cxf/jaxrs/security/client/Client.java` - a Java class implementing an HTTP client that can be used to test the service
* `src/main/resources/org/fusesource/examples/cxf/jaxrs/security/client/*.xml` - data files used by the client to test the service
* `src/main/resources/OSGI-INF/blueprint/blueprint.xml` - the OSGI Blueprint file that defines the services

## Building the Example
To build the example:

1. Change your working directory to the `examples/secure-rest` directory.
2. Run `mvn clean install` to build the example.

## Running the Example
To run the example:

1. Start Fuse ESB Enterprise 7 by running `bin/fuseesb` (on Linux) or `bin\fuseesb.bat` (on Windows).
2. In the Fuse ESB console, enter the following command:
        osgi:install -s fab:mvn:org.fusesource.examples/secure-rest/${project.version}
3. Verify etc/users.properties from the Fuse ESB installation contains the following 'smx' user configured:
smx=smx

There are several ways you can interact with the running RESTful Web services:
* browse the Web service metadata
* access the service in a Web browser
* use a Java client
* use a command-line utility


### Browsing Web service metadata

A full listing of all CXF Web services is available at

    http://localhost:8181/cxf

After you deployed this example, you will see the following endpoint address appear in the 'Available RESTful services' section:

    http://localhost:8181/cxf/securecrm

Just below it, you'll find a link to the WADL describing all the root resources:

    http://localhost:8181/cxf/securecrm?_wadl

You can also look at the more specific WADL, the only that only lists information about 'customerservice' itself:

	http://localhost:8181/cxf/securecrm/customerservice?_wadl&_type=xml

{'fraction_non_alphanumeric': 0.07333642118264629, 'fraction_numerical': 0.009572332870155936, 'mean_word_length': 4.3316872427983535, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1758762', 'n_tokens_mistral': 1938, 'n_tokens_neox': 1845, 'n_words': 803}