Overview
We won't go into great detail on describing Camel other than it is the open source integration framework based on Enterprise Integration Patterns. Apache Camel uses URIs to work directly with any kind of Transport or messaging model such as HTTP, ActiveMQ, JMS, JBI, SCA, MINA or CXF, as well as pluggable Components and Data Format options. One of these components is the sap-netweaver component which is available in Fuse 6.1. Part 1 focuses on this component while Part 2 focuses on the JCo component which is available in Fuse 6.1 but not in Camel. For more detailed information on Camel and Enterprise Integration Patterns you can read the Primer at http://jbossevangelist.slides.com/kpeeples-jte/enterprise-integration-patterns-primer#/.
The sap-netweaver component, available in Camel 2.12, integrates with the SAP NetWeaver Gateway using HTTP transports. This camel component supports only producer endpoints. Maven users will need to add the following dependency to their pom.xml for this component:
The sap-netweaver component, available in Camel 2.12, integrates with the SAP NetWeaver Gateway using HTTP transports. This camel component supports only producer endpoints. Maven users will need to add the following dependency to their pom.xml for this component:
< dependency > < groupId >org.apache.camel</ groupId > < artifactId >camel-sap-netweaver</ artifactId > < version >x.x.x</ version > <!-- use the same version as your Camel core version --> </ dependency > |
Component and endpoint options
Name
|
Default Value
|
Description
|
---|---|---|
username |
Username for account. This is mandatory.
| |
password |
Password for account. This is mandatory.
| |
json | true |
Whether to return data in JSON format. If this option is false, then XML is returned in Atom format.
|
jsonAsMap | true |
To transform the JSON from a String to a Map in the message body.
|
flatternMap | true |
If the JSON Map contains only a single entry, then flattern by storing that single entry value as the message body.
|
Message Headers
The following headers can be used by the producer.
Name
|
Type
|
Description
|
---|---|---|
CamelNetWeaverCommand | String |
Mandatory: The command to execute in MS ADO.Net Data Service format.
|
Setup a SAP Developer Account
In order to run the project a SAP Developer account should be setup. Visit the SAP Netweaver Gateway Developer Page at http://scn.sap.com/docs/DOC-31221 Also visit the Red Hat JBoss Enterprise Middleware for SAP page on SCN at http://scn.sap.com/docs/DOC-39134Running a test of the component
Step 1 - Download the Project from JBoss Demo Central - https://github.com/jbossdemocentral/fuse-components-sap-netweaverStep 2 - Import the Project into JBDS and take a look at the camel-context.xml which is the Spring DSL that contains the Camel Route for the project. We used this command to get specific flight information which is put into the CamelNetWeaverCommand: FlightCollection(carrid='AZ',connid='0555',fldate=datetime'2014-07-09T00%3A00%3A00')
<camelContext xmlns="http://camel.apache.org/schema/spring">
<route>
<description>here is a sample which processes the input files then performs content based routing on the message using XPath</description>
<from uri="file:src/sap-netweaver?fileName=command.txt&noop=true"/>
<setHeader headerName="CamelNetWeaverCommand">
<simple>in.body</simple>
</setHeader>
<to uri="sap-netweaver:https://sapes1.sapdevcenter.com/sap/opu/odata/IWFND/RMTSAMPLEFLIGHT/?username=USERNAME&password=PASSWORD&json=false"/>
<to uri="log:response"/>
</route>
</camelContext>
I used the following software to view and run the Camel Context:
-JBDS 7.1.1 - https://www.jboss.org/products/jbds.html
-Integration Stack 4.1.6.Final - http://download.jboss.org/jbosstools/updates/stable/kepler/integration-stack
Step 3 - Update the Username and Password in the camel-context.xml
-Integration Stack 4.1.6.Final - http://download.jboss.org/jbosstools/updates/stable/kepler/integration-stack
Step 3 - Update the Username and Password in the camel-context.xml
Step 4 - Right click on camel-context.xml and run as 'Local Camel Context'
Step 5 - The output will look like the below in the console. Notice the Response Flight Information from SAP.