Chapter 9. Getting Started with Camel on JBoss EAP

9.1. Camel CXF Example

This tutorial takes a standard Camel CXF example and shows you how to deploy it into a Web server, by packaging the application as a WAR. In this example, the Web service is implemented by binding the service to a Camel route using the Camel CXF component.
Prerequisites

Maven 3.0.x must be installed and configured.

  1. Open a terminal and navigate to the EAP_HOME/quickstarts/camel/camel-example-cxf-tomcat directory.
  2. Run the following command to build and package the example:
    mvn clean install
    If this command executes successfully, the application will be packaged in EAP_HOME/quickstarts/camel/camel-example-cxf-tomcat/target/camel-example-cxf-tomcat.war.
  3. If your application server is not running. Start it now. You can check if your server is running by opening a browser and navigating to http://localhost:8080. If you can login successfully to the management console, the server is running.
  4. Deploy the camel-example-cxf-tomcat example to the running server by copying the camel-example-cxf-tomcat.war file to the server's deployment directory, EAP_HOME/MODE/deployments.
  5. You can use a Web browser to query the WSDL contract from the newly deployed Web service. Navigate to the following URL:
  6. Run the test client against the deployed Web service. From the quickstart directory, enter the following command:
    mvn exec:java
    If the client runs successfully, you should see some output like the following in your command window:
    			...
    [INFO] --- exec-maven-plugin:1.1.1:java (default-cli) @ camel-example-cxf-tomcat ---
    2013-07-24 13:59:16,829 [teClient.main()] INFO  ReflectionServiceFactoryBean
    - Creating Service {http://incident.cxf.example.camel.apache.org/}IncidentService
    from class org.apache.camel.example.cxf.incident.IncidentService
    OK;123
    IN PROGRESS
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 7.445s
    [INFO] Finished at: Wed Jul 24 13:59:17 CEST 2013
    [INFO] Final Memory: 10M/81M
    [INFO] ------------------------------------------------------------------------
    			
  7. If you have an interface such as soapUI installed, you can test the service using requests such as the following sample SOAP requests:
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
        <soap:Body>
            <ns1:reportIncident xmlns:ns1="http://incident.cxf.example.camel.apache.org/">
                <arg0>
                    <details>blah blah</details>
                    <email>davsclaus@apache.org</email>
                    <familyName>Smith</familyName>
                    <givenName>Bob</givenName>
                    <incidentDate>2011-11-25</incidentDate>
                    <incidentId>123</incidentId>
                    <phone>123-456-7890</phone>
                    <summary>blah blah summary</summary>
                </arg0>
            </ns1:reportIncident>
        </soap:Body>
    </soap:Envelope>
    			
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
        <soap:Body>
            <ns1:statusIncident xmlns:ns1="http://incident.cxf.example.camel.apache.org/">
                <arg0>
                    <incidentId>456</incidentId>
                </arg0>
            </ns1:statusIncident>
        </soap:Body>
    </soap:Envelope>
    			

Note

Detailed instructions to run each quickstart are documented in the README.txt file located in that quickstart's directory.

9.2. Camel Servlet Example

This tutorial takes a standard Apache Camel example and shows you how to deploy it into a Web server, by packaging the application as a WAR.
Prerequisites

Maven 3.0.x must be installed and configured.

  1. Open a terminal and navigate to the EAP_HOME/quickstarts/camel/camel-example-servlet-tomcat directory.
  2. Run the following command to build and package the example:
    mvn clean install
    If this command executes successfully, the application will be packaged in EAP_HOME/quickstarts/camel/camel-example-servlet-tomcat/target/camel-example-servlet-tomcat-VERSION.war.
  3. If your application server is not running. Start it now. You can check if your server is running by opening a browser and navigating to http://localhost:8080. If you can login successfully to the management console, the server is running.
  4. Deploy the camel-example-servlet-tomcat example to the running server by copying the camel-example-servlet-tomcat-VERSION.war file to the server's deployment directory, EAP_HOME/MODE/deployments.
  5. Navigate to the following URL in your browser (assuming VERSION is 2.10.0.redhat-60024):
  6. You can test the servlet by following the link in the text: "To get started click this link."

Note

Detailed instructions to run each quickstart are documented in the README.txt file located in that quickstart's directory.