Red Hat JBoss Fuse 6.0

Similar documents
Red Hat JBoss Fuse 6.1

Red Hat JBoss Fuse 6.1

Red Hat JBoss A-MQ 6.0

Red Hat Developer Studio 12.0

Red Hat CloudForms 4.0

Red Hat JBoss A-MQ 6.3

Red Hat Fuse 7.0 Installing on Apache Karaf

Red Hat JBoss Developer Studio 11.1

Red Hat 3Scale 2.0 Terminology

Red Hat JBoss Fuse 6.3

Red Hat JBoss Fuse 6.3

Red Hat CloudForms 4.5 Integration with AWS CloudFormation and OpenStack Heat

.NET Core 2.0 Release Notes for Containers

Red Hat Fuse 7.0 Installing on JBoss EAP

Red Hat JBoss Fuse 6.1

Red Hat Process Automation Manager 7.0 Planning a Red Hat Process Automation Manager installation

Red Hat OpenStack Platform 13

Red Hat Fuse 7.1 Installing on JBoss EAP

Red Hat Developer Studio 12.0

Red Hat Satellite 6.3

Red Hat Mobile Application Platform Hosted 3

Red Hat OpenStack Platform 9 Introduction to the OpenStack Dashboard

Red Hat JBoss Enterprise Application Platform 7.1

Red Hat JBoss Enterprise Application Platform 7.2

Red Hat OpenStack Platform 13

Red Hat JBoss Data Grid 7.1 Feature Support Document

Red Hat Application Migration Toolkit 4.0

Red Hat JBoss Enterprise Application Platform 7.0

Red Hat JBoss Enterprise Application Platform 7.2

Red Hat JBoss Data Virtualization 6.2 Using the Dashboard Builder. David Sage

Red Hat CloudForms 4.1

Red Hat CloudForms 4.0

Red Hat JBoss BRMS 6.0

Red Hat Virtualization 4.1 Hardware Considerations for Implementing SR-IOV

Red Hat JBoss Developer Studio Integration Stack 10.0 Installation Guide

Red Hat Developer Studio 12.9

Red Hat OpenStack Platform 13

Red Hat OpenStack Platform 8 Configure firewall rules for Red Hat OpenStack Platform director

Red Hat Enterprise Linux OpenStack Platform 7 Fujitsu ETERNUS Back End Guide

Red Hat Enterprise Virtualization 3.6

Red Hat Application Migration Toolkit 4.2

Red Hat OpenStack Platform 13

Red Hat JBoss Developer Studio Integration Stack 9.0 Installation Guide

Red Hat JBoss Fuse 6.3

Red Hat 3scale 2.3 Accounts

Red Hat JBoss Data Virtualization 6.3 Getting Started Guide

Red Hat JBoss Fuse 6.0

Red Hat Process Automation Manager 7.0 Migrating from Red Hat JBoss BPM Suite 6.4 to Red Hat Process Automation Manager 7.0

Red Hat Virtualization 4.2

Red Hat AMQ 7.2 Introducing Red Hat AMQ 7

Red Hat Process Automation Manager 7.0 Executing a business process in Business Central

Red Hat JBoss Fuse 6.2

Red Hat CloudForms 4.6

Red Hat CloudForms 4.5

Red Hat Virtualization 4.0

Red Hat Decision Manager 7.0

Red Hat Cloud Infrastructure 1.1

Red Hat Single Sign-On 7.1 Getting Started Guide

Red Hat Development Suite 2.2

Red Hat Ceph Storage 3

Red Hat JBoss Data Virtualization 6.3 Glossary Guide

Red Hat Decision Manager 7.0 Migrating from Red Hat JBoss BRMS 6.4 to Red Hat Decision Manager 7.0

Red Hat Ceph Storage 2 Using Keystone to Authenticate Ceph Object Gateway Users

Red Hat JBoss Developer Studio 11.3

Red Hat JBoss Web Server 3.1

Red Hat JBoss Data Grid 6.4

Red Hat OpenStack Platform 12

Red Hat JBoss Middleware for OpenShift 3

Red Hat Cloud Suite 1.1

Red Hat Single Sign-On 7.2

Red Hat OpenStack Platform 10 CephFS Back End Guide for the Shared File System Service

Red Hat JBoss Developer Studio 9.1

Red Hat Development Suite 1.1 Installation Guide

Red Hat JBoss Fuse 6.2.1

Red Hat Process Automation Manager 7.0 Managing and monitoring business processes in Business Central

Red Hat OpenShift Application Runtimes 1

Red Hat Enterprise Virtualization 3.6

Red Hat JBoss Enterprise Application Platform 6.4

Red Hat Virtualization 4.1 Product Guide

Red Hat Development Suite 2.1

Red Hat CloudForms 4.5 Introduction to the Self Service User Interface

Red Hat Decision Manager 7.0 Migrating from Red Hat JBoss BRMS 6.4 to Red Hat Decision Manager 7.0

Red Hat JBoss Developer Studio 9.0

Red Hat Ceph Storage 3

Red Hat JBoss BRMS 6.4

Red Hat OpenStack Platform 13

Red Hat OpenStack Platform 10

OpenShift Dedicated 3 Release Notes

Red Hat JBoss BRMS 6.1

Red Hat Developer Tools

Red Hat CloudForms 4.0

Red Hat JBoss Fuse 7.0-TP

Red Hat Fuse 7.2 Fuse Online Sample Integration Tutorials

Red Hat JBoss Developer Studio Integration Stack 8.0

Red Hat CloudForms 4.6

Red Hat JBoss Developer Studio 11.0

Red Hat Security Data API 1.0

Red Hat Enterprise Virtualization 3.6

Red Hat Enterprise Virtualization 3.6 Introduction to the User Portal

Red Hat Fuse 7.1 Fuse Online Sample Integration Tutorials

Transcription:

Red Hat JBoss Fuse 6.0 Tutorials Example integration applications Last Updated: 2017-10-13

Red Hat JBoss Fuse 6.0 Tutorials Example integration applications JBoss A-MQ Docs Team Content Services fuse-docs-support@redhat.com

Legal Notice Copyright 2013 Red Hat. The text of and illustrations in this document are licensed by Red Hat under a Creative Commons Attribution Share Alike 3.0 Unported license ("CC-BY-SA"). An explanation of CC-BY-SA is available at http://creativecommons.org/licenses/by-sa/3.0/. In accordance with CC-BY-SA, if you distribute this document or an adaptation of it, you must provide the URL for the original version. Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent permitted by applicable law. Red Hat, Red Hat Enterprise Linux, the Shadowman logo, JBoss, OpenShift, Fedora, the Infinity logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries. Linux is the registered trademark of Linus Torvalds in the United States and other countries. Java is a registered trademark of Oracle and/or its affiliates. XFS is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/or other countries. MySQL is a registered trademark of MySQL AB in the United States, the European Union and other countries. Node.js is an official trademark of Joyent. Red Hat Software Collections is not formally related to or endorsed by the official Joyent Node.js open source or commercial project. The OpenStack Word Mark and OpenStack logo are either registered trademarks/service marks or trademarks/service marks of the OpenStack Foundation, in the United States and other countries and are used with the OpenStack Foundation's permission. We are not affiliated with, endorsed or sponsored by the OpenStack Foundation, or the OpenStack community. All other trademarks are the property of their respective owners. Abstract This guide contains examples of implementing several different types of applications in Red Hat JBoss Fuse.

Table of Contents Table of Contents. CHAPTER......... 1... DEPLOYING........... A.. WEB.... SERVICE......... INTO..... RED.... HAT.... JBOSS....... FUSE................................... 3. 1.1. DEPLOYING THE EXAMPLE 3 1.2. RUNNING A CLIENT 5 1.3. UNDERSTANDING THE EXAMPLE 6. INDEX............................................................................................ 9. 1

Red Hat JBoss Fuse 6.0 Tutorials 2

CHAPTER 1. DEPLOYING A WEB SERVICE INTO RED HAT JBOSS FUSE CHAPTER 1. DEPLOYING A WEB SERVICE INTO RED HAT JBOSS FUSE Abstract Here we will take an in depth look at the CXF OSGi example, a JAX-WS web service packaged as an OSGi bundle. You are going to build and deploy a simple service that is based on a WSDL document. The source for this example can be found in the InstallDir/examples/cxf-osgi folder of your Red Hat JBoss Fuse installation. The example uses the JBoss Fuse Maven tooling to build a bundle that contains the service implementation and all of the metadata needed to deploy it into the JBoss Fuse container. The sample code includes a web page, client.html, that will allow you to access the service once it is exposed. 1.1. DEPLOYING THE EXAMPLE Before you run the example, start Red Hat JBoss Fuse. Installing a prebuilt version of the example To install and run a prebuilt version of this example, enter the following command in the Red Hat JBoss Fuse console: features:install examples-cxf-osgi Building and deploying the example yourself To build and deploy the example do the following: 1. If you installed the examples-cxf-osgi feature, first uninstall it by running the following from the Red Hat JBoss Fuse console: features:uninstall examples-cxf-osgi 2. In a separate command window or terminal, change to the root folder of the example. cd InstallDir/examples/cxf-osgi 3. Enter the following command: mvn install This command will build a bundle called cxf-osgi-6.0.0.redhat-024.jar and place it into the target folder of the example. 4. Copy the bundle to InstallDir/deploy to deploy it to the container. Testing the example 3

Red Hat JBoss Fuse 6.0 Tutorials To see if the example is running you can visit http://localhost:8181/cxf/helloworld?wsdl in your Web browser. You should see the WSDL shown in Example 1.1, CXF OSGi Example WSDL. Example 1.1. CXF OSGi Example WSDL <wsdl:definitions name="helloworldimplservice" targetnamespace="http://cxf.examples.servicemix.apache.org/"> <wsdl:types> <xs:schema attributeformdefault="unqualified" elementformdefault="unqualified" targetnamespace="http://cxf.examples.servicemix.apache.org/"> <xs:complextype name="sayhi"> <xs:sequence> <xs:element minoccurs="0" name="arg0" type="xs:string"/> </xs:sequence> </xs:complextype> <xs:complextype name="sayhiresponse"> <xs:sequence> <xs:element minoccurs="0" name="return" type="xs:string"/> </xs:sequence> </xs:complextype> <xs:element name="sayhi" nillable="true" type="sayhi"/> <xs:element name="sayhiresponse" nillable="true" type="sayhiresponse"/> </xs:schema> </wsdl:types> <wsdl:message name="sayhiresponse"> <wsdl:part element="tns:sayhiresponse" name="parameters"> </wsdl:part> </wsdl:message> <wsdl:message name="sayhi"> <wsdl:part element="tns:sayhi" name="parameters"> </wsdl:part> </wsdl:message> <wsdl:porttype name="helloworld"> <wsdl:operation name="sayhi"> <wsdl:input message="tns:sayhi" name="sayhi"> </wsdl:input> <wsdl:output message="tns:sayhiresponse" name="sayhiresponse"> </wsdl:output> </wsdl:operation> </wsdl:porttype> <wsdl:binding name="helloworldimplservicesoapbinding" type="tns:helloworld"> <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> <wsdl:operation name="sayhi"> <soap:operation soapaction="" style="document"/> <wsdl:input name="sayhi"> <soap:body use="literal"/> </wsdl:input> <wsdl:output name="sayhiresponse"> <soap:body use="literal"/> </wsdl:output> 4

CHAPTER 1. DEPLOYING A WEB SERVICE INTO RED HAT JBOSS FUSE </wsdl:operation> </wsdl:binding> <wsdl:service name="helloworldimplservice"> <wsdl:port binding="tns:helloworldimplservicesoapbinding" name="helloworldimplport"> <soap:address location="http://localhost:8181/cxf/helloworld"/> </wsdl:port> </wsdl:service> </wsdl:definitions> 1.2. RUNNING A CLIENT You can run either a web client or a Java client against the deployed web service. Running the web client To run the web client: 1. Open the client.html, which is located at the root of the cxf-osgi example folder. 2. Click the Send button to send a request. Figure 1.1. Example Client HTML Screen Once the request has been successfully sent, a response message appears in the right-hand panel of the web page Running the Java client 5

Red Hat JBoss Fuse 6.0 Tutorials To run the Java client: 1. In a command prompt or terminal, change to the InstallDir/examples/cxf-osgi directory. 2. Run the following command: mvn compile exec:java If the client request is successful, a response similar to the following is returned to the command window: the response is =====> <soap:envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:body> <ns2:sayhiresponse xmlns:ns2="http://cxf.examples.servicemix.apache.org/"> <return>hello John Doe</return></ns2:sayHiResponse></soap:Body> </soap:envelope> 1.3. UNDERSTANDING THE EXAMPLE Overview The example builds a simple HelloWorld service and packages it for deployment into Red Hat JBoss Fuse. The service is written using standard JAX-WS APIs. It implements a single operation sayhi(). Once deployed, the service is exposed as a SOAP/HTTP endpoint. The most interesting parts of the example are the Spring configuration used to configure the endpoint and the Maven POM used to build the bundle. The Spring configuration provides the details needed to expose the service using SOAP/HTTP. It can also contain details used to configure advanced Apache CXF functionality. The Maven POM, in addition to compiling the code, uses the bundle generation plug-in to package the resulting classes into an OSGi bundle. It contains all of the details needed by the Red Hat JBoss Fuse container to activate the bundle and deploy the packaged service. Using the Maven tools The Red Hat JBoss Fuse Maven tooling automates a number of the steps in packaging functionality for deployment into JBoss Fuse. In order to use the Maven OSGi tooling, you add the elements shown in Example 1.2, POM Elements for Using Red Hat JBoss Fuse OSGi Tooling to your POM file. Example 1.2. POM Elements for Using Red Hat JBoss Fuse OSGi Tooling... <pluginrepositories> <pluginrepository> <id>fusesource.m2</id> <name>open Source Community Release Repository</name> <url>http://repo.fusesource.com/maven2</url> <snapshots> <enabled>false</enabled> </snapshots> <releases> 6

CHAPTER 1. DEPLOYING A WEB SERVICE INTO RED HAT JBOSS FUSE <enabled>true</enabled> </releases> </pluginrepository> </pluginrepositories>... <build> <plugins> <plugin> <groupid>org.apache.felix</groupid> <artifactid>maven-bundle-plugin</artifactid>... </plugin> </plugins> </build>... These elements point Maven to the correct repositories to download the Red Hat JBoss Fuse Maven tooling and load the plug-in that implements the OSGi tooling. The Spring configuration The Red Hat JBoss Fuse container needs some details about a service before it can instantiate and endpoint for it. Apache CXF uses Spring based configuration to define endpoints for services. The configuration shown in Example 1.3, OSGi Example Spring Configuration is stored in the example's \src\main\resources\meta-inf\spring\beans.xml file. Example 1.3. OSGi Example Spring Configuration <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws" xsi:schemalocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"> 1 <import resource="classpath:meta-inf/cxf/cxf.xml" /> <import resource="classpath:meta-inf/cxf/cxf-extension-soap.xml" /> <import resource="classpath:meta-inf/cxf/cxf-extension-http.xml" /> <import resource="classpath:meta-inf/cxf/osgi/cxf-extensionosgi.xml" /> 2 <jaxws:endpoint id="helloworld" implementor="org.apache.servicemix.examples.cxf.helloworldimpl" address="/helloworld"/> </beans> The configuration shown in Example 1.3, OSGi Example Spring Configuration does the following: 7

Red Hat JBoss Fuse 6.0 Tutorials 1 2 Imports the required configuration to load the required parts of the Apache CXF runtime. Configures the endpoint that exposes the service using the jaxws:endpoint element and its attributes. id is an identifier used by the configuration mechanism. implementor specifies the class that implements the service. It must be on the classpath. address specifies the address at which the service will be exposed. This address is relative to the containers HTTP address with cxf appended to it. The POM Example 1.4. OSGi POM <project xmlns="http://maven.apache.org/pom/4.0.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelversion>4.0.0</modelversion> <parent> <groupid>org.apache.servicemix.examples</groupid> <artifactid>examples</artifactid> <version>6.0.0.redhat-024</version> </parent> <groupid>org.apache.servicemix.examples</groupid> <artifactid>cxf-osgi</artifactid> <packaging>bundle</packaging> <version>6.0.0.redhat-024</version> <name>apache ServiceMix Example :: CXF OSGi</name> <!-- Add ServiceMix repositories for snaphots and releases -->... <dependencies> <dependency> <groupid>org.apache.geronimo.specs</groupid> <artifactid>geronimo-ws-metadata_2.0_spec</artifactid> <version>${geronimo.wsmetadata.version}</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupid>org.apache.felix</groupid> <artifactid>maven-bundle-plugin</artifactid> <configuration> <instructions> <Bundle-SymbolicName>${pom.artifactId}</Bundle- 8

INDEX SymbolicName> <Import-Package> javax.jws, javax.wsdl, META-INF.cxf, META-INF.cxf.osgi, org.apache.cxf.bus, org.apache.cxf.bus.spring, org.apache.cxf.bus.resource, org.apache.cxf.configuration.spring, org.apache.cxf.resource, org.apache.servicemix.cxf.transport.http_osgi, org.springframework.beans.factory.config </Import-Package> <Private- Package>org.apache.servicemix.examples.cxf</Private-Package> <Require-Bundle>org.apache.cxf.cxfbundle</Require-Bundle> </instructions> </configuration> </plugin> </plugins> </build> </project> M INDEX Maven tooling, Using the Maven tools 9