Skip to Content

Web Service (SOAP) Input Output Adapter Example

Running the Web Service (SOAP) Input/Output Adapter Examples

This document will provide a walkthrough for running the Web Service (SOAP) Input/Output Adapter for SAP HANA Smart Data Streaming. For more documentation these adapters, click here. Please note that the instructions in this document are slightly different than the ones found on the Help Portal.


The Web Service (SOAP) Input/Output Adapter should not be confused with the Streaming SOAP Provider, which is a different adapter entirely.

Prerequisites

  • Have access to SAP HANA SP11 with Smart Data Streaming installed and configured for use.
  • Have SAP HANA Studio 2 installed with the streaming plug-in installed and configured
  • It is assumed that you are familiar with the HANA Studio and SDS environment
  • The environment variable $STREAMING_HOME must be defined as the installation folder for Smart Data Streaming
  • In this tutorial, the HANA user is SYSTEM, and our <sid> is PM2.
  • In this tutorial, our SDS host is called dewdflhana2429.emea.global.corp.sap, and has the port number 30026.

Part A: Web Service (SOAP) Input Adapter Example

Download JDK

1. To start off, we will need to download the Java Development Kit (JDK). In this tutorial we will be installing version 7, for Linux x64. You can get the tar package here.


2. Move the package into the $STREAMING_HOME/lib directory on your SDS host (using software such as WinSCP), and unpack it by running the following in PuTTY:

tar xvfz <filename.tar.gz>


3. Rename the folder as “jdk”.


4. You may need to change folder permissions, to make sure it is accessible by your user.


5. We will now need to set the environment variables JAVA_HOME and JRE_HOME. Run the following 2 commands to do so.           

JAVA_HOME=$STREAMING_HOME/lib/jdk

JRE_HOME=$STREAMING_HOME/lib/jdk/jre

Note: For every PuTTY session you open, you will need to set these variables. Remember to run these commands every time you open a new console.

Creating the Sample Project

1. Create a new streaming project inside SAP HANA Studio, under the “default” workspace. We will name it “stocktrader”. Delete the auto-generated CCL, and replace the project CCL with the following:

CREATE SCHEMA tradesSchema (

      buyerId INTEGER,

      sellerId INTEGER,

      supervisorId INTEGER,

      tradeTime LONG,

      amount INTEGER,

      price FLOAT,

      symbol STRING

);

CREATE INPUT STREAM tradesIn SCHEMA tradesSchema ;

CREATE OUTPUT STREAM tradesOut

AS    SELECT * FROM tradesIn ;


2. Compile, and deploy the project.

3. Open up the Stream View for tradesIn. We will be using this Streaming View to test if the Web Service (SOAP) Input Adapter is working later on.

Download Axis2

Axis2 is a web services / SOAP / WSDL engine from Apache, and will be used to generate the web service our adapters are connecting to.

1. Download the latest binary distribution of Axis2 version 1.6 here. *Make sure you download version 1.6, and not 1.7 as the newer version does not support this adapter example.

2. Unzip it and move it somewhere inside your $STREAMING_HOME directory on your host machine. We will be moving it to $STREAMING_HOME/adapters/webservices.

3. Rename the folder to “axis2”


4. You may need to change folder permissions, to ensure it is accessible by your user.

Start Axis2

Axis2 can create a web service using an “Axis Archive” file with the extension .aar. (This is not to be confused with the Google Android library project file, which has the same extension.) Normally, you will need to generate this file for your own streaming project. However, we will be provided a pre-made .aar file for the purpose of this example.

1. Using a FTP software (like WinSCP), navigate to the $STREAMING_HOME/adapters/webservices/examples/service directory of your SDS host. You will see a file named “StockTraderService_noSec.aar”.

2. We will now move this .aar file into the services folder of Axis2. Copy over StockTraderService_noSec.aar to the directory $STREAMING_HOME/adapters/webservices/axis2/repository/services

3. To start Axis and deploy our web service, navigate to the $STREAMING_HOME/adapters/webservices/axis2/bin directory and run

sh axis2server.sh

4. To ensure the server is running, we can check the XML by opening a web browser to the following URL:

http://<host>:8080/axis2/services/StockTraderService?wsdl

You will need to replace <host> with the host you installed Axis2 on. In this case, it is our SDS host (recommended). Additionally, Axis2 is configured to run on port 8080 by default. If Axis2 is up and running, you will see this in the browser:

Configure Input Adapter Files

The web service adapters require a configuration and a mapping file. In this case, they are called “adapter_config.xml” and “stockTraderMappings.xml”. We need to edit the adapter_config.xml file, as well as a 3rd file called “set_example_env.sh”. All 3 are located inside the $STREAMING_HOME/adapters/webservices/examples/input folder.

1. Open up “adapter_config.xml”. The file has tags containing details about the Axis web service to connect to (notice the <wsdlURL> on line 21). It also specifies details about the streaming project to connect to. This part will need editing. Modify the <Uri>, <User>, and <Password> tags to match our streaming project. Ensure that the Uri starts with esps://.

<EspProjects>

     <EspProject>   

          <Name>StockTraderProject</Name>

          <Uri>esps://<host>:<port>/<workspace>/<projectname></Uri>

          <Security>

               <User>user</User>

               <Password>password</Password>

               <AuthType>user_password</AuthType>

For example, our host is dewdflhana2429.emea.global.corp.sap, our port is 30026, the workspace is default, the project name is stocktrader, and we are using authentication for the SYSTEM user.


2. Save and close the file.

3. Open up “set_example_env.sh”, and change the variables below. You will need to modify them according to your streaming project. Make sure that the ADAPTER_EXAMPLE_CLUSTER_NODE_PROTOCOL is set as esps.

ADAPTER_EXAMPLE_USERNAME = SYSTEM

ADAPTER_EXAMPLE_PASSWORD = <password>

ADAPTER_EXAMPLE_WORKSPACE_NAME = default

ADAPTER_EXAMPLE_PROJECT_NAME = stocktrader

ADAPTER_EXAMPLE_CLUSTER_NODE_PROTOCOL = esps

ADAPTER_EXAMPLE_CLUSTER_NODE_HOST = dewdflhana2429.emea.global.corp.sap

ADAPTER_EXAMPLE_CLUSTER_NODE_PORT = 30026


4. We will also need to set the JDK_HOME variable, which points to the JDK we installed earlier. Add the following line to the file:

export JDK_HOME=$STREAMING_HOME/lib/jdk

5. Save and close the file

The mapping file maps the columns of our streaming project to the columns provided by our Axis server. While the mapping file is given in this example, you would normally need to generate the mapping file yourself. This can be done in HANA Studio, after you create your project. For detailed instructions on creating a mapping file in studio, see “Discovering Schema and Creating a Mapping File for the Web Services (SOAP) Adapter” in the “SAP HANA Smart Data Streaming: Developer Guide”.



Running the Web Service (SOAP) Input Adapter

You currently have a PuTTY window with the Axis2 server process running, and a HANA Studio window open to the Stream View of your input stream. We will now open another PuTTY window, run the input adapter, and see the records appear in our HANA Studio Stream View.

1. Open another PuTTY window. Remember to set JAVA_HOME and JRE_HOME again.

2. Go to the directory $STREAMING_HOME/adapters/webservices/examples/input, and run the start_adapter.sh script to start the adapter

sh start_adapter.sh

3. If successful, you will now see the rows inside of HANA Studio:

Part B: Web Service (SOAP) Output Adapter Example

In Part A, we set up and tested the example Web Service (SOAP) Input Adapter. We will now test the Output Adapter example. To prevent us from retracing our steps, leave all windows open. We will first configure the required files for the Output Adapter just like we did for the Input Adapter. Then, we will run the Output Adapter and manually send a row into our input stream using HANA Studio. If the Output Adapter is working correctly, the record should be logged and displayed in our Axis2 web service process PuTTY window.

Configure Output Adapter Files

Just like how the Input Adapter has the “adapter_config.xml”, “stockTraderMappings.xml”, and “set_example_env.sh” files, the Output Adapter does as well. All 3 are located inside the $STREAMING_HOME/adapters/webservices/examples/output folder. Once again, we will be editing “adapter_config.xml” and “set_example_env.sh”.

1. Open up “adapter_config.xml”, located in the output folder mentioned above. Just like last time, modify the <Uri>, <User>, and <Password> tags to match our streaming project. Ensure that the Uri starts with esps://.

<EspProjects>

     <EspProject>   

          <Name>StockTraderProject</Name>

          <Uri>esps://<host>:<port>/<workspace>/<projectname></Uri>

          <Security>

               <User>user</User>

               <Password>password</Password>

               <AuthType>user_password</AuthType>

For example, our host is dewdflhana2429.emea.global.corp.sap, our port is 30026, the workspace is default, the project name is stocktrader, and we are using authentication for the SYSTEM user.


2. Save and close the file.


3. Open up “set_example_env.sh”, and change the same variables as before. You will need to modify them according to your streaming project. Make sure that the ADAPTER_EXAMPLE_CLUSTER_NODE_PROTOCOL is set as esps.

ADAPTER_EXAMPLE_USERNAME = SYSTEM

ADAPTER_EXAMPLE_PASSWORD = <password>

ADAPTER_EXAMPLE_WORKSPACE_NAME = default

ADAPTER_EXAMPLE_PROJECT_NAME = stocktrader

ADAPTER_EXAMPLE_CLUSTER_NODE_PROTOCOL = esps

ADAPTER_EXAMPLE_CLUSTER_NODE_HOST = dewdflhana2429.emea.global.corp.sap

ADAPTER_EXAMPLE_CLUSTER_NODE_PORT = 30026


4. Like before, we will need to export JAVA_HOME by add the following line to the file:

export JDK_HOME=$STREAMING_HOME/lib/jdk

5. Save and close the file


The Output adapter requires the same mapping file as the Input Adapter. (Mapping files simply help connect the streaming project and web service, regardless of which adapter is used)



Running the Web Service (SOAP) Output Adapter

We will now start the Output Adapter, manually input a single row into our streaming project, and see the record appear in our Axis2 web service process PuTTY window.

1. Stop the Input Adapter process if it is still running (ctrl+c will kill it). You may use the same window to run the Output Adapter. If you choose to open a new window, remember to set the JAVA_HOME and JRE_HOME variables again.

2. Go to the directory $STREAMING_HOME/adapters/webservices/examples/output, and run the start_adapter.sh script to start the adapter

sh start_adapter.sh

3. Go to your HANA Studio Stream View. Clear the contents.


4. Under the Manual Input window, click “Select Stream” to select our tradesIn input stream, and enter some values. Click “Publish” to publish the row to the stream. You will see it in the Streaming View perspective

5. If the Output Adapter is working, you will see that record logged in your Axis web service process PuTTY window.

Note: Axis logging is configurable, and different implementations are possible. By default, it is handled by the log4j api.

Tags:
Former Member

No comments