Wednesday, December 17, 2014

Connecting to SAP from Fuse 6.1 Part 1 - Netweaver Gateway Component


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

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:

    <!-- use the same version as your Camel core version -->
You would need to have an account to the SAP NetWeaver system to be able to leverage this component. Also, this component uses the basic authentication scheme for logging into SAP NetWeaver.

Component and endpoint options
Default Value

Username for account. This is mandatory.

Password for account. This is mandatory.
Whether to return data in JSON format. If this option is false, then XML is returned in Atom format.
To transform the JSON from a String to a Map in the message body.
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.
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  Also visit the Red Hat JBoss Enterprise Middleware for SAP page on SCN at

Running a test of the component

Step 1 - Download the Project from JBoss Demo Central -

Step 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="">
        <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&amp;noop=true"/>
        <setHeader headerName="CamelNetWeaverCommand">
        <to uri="sap-netweaver:;password=PASSWORD&amp;json=false"/>
        <to uri="log:response"/>

I used the following software to view and run the Camel Context:
-JBDS 7.1.1 -
-Integration Stack 4.1.6.Final -

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.