BridgeGate™


Tutorial 6: HTTP / Using the BridgeGate Portal's Dynamic Translation Functionality

Table of Contents

Using BridgeGate Portal's Dynamic Translation Functionality

Introduction

This Tutorial walks you through creating Inbound and Outbound Templates that will read data from a sample table in BridgeGate's internal MySql Database, and converts it into a simple delimited format (with only a single field). The Tutorial will not cover much of the actual creating of the Templates, as these steps should already be understood prior to covering this Tutorial. Only relevant parts of the Templates will be covered.

No portion of any of the Templates used in this Tutorial is required for dynamic translation through the BridgeGate Portal. The Templates are only provided to demonstrate additional functionality that can be used in using this feature that other Tutorials did not include. Any Workflow can be run through this feature.

Keep in mind, however, the entire Workflow will run just as if it was triggered by a Schedule. The templates created for this Tutorial use BridgeGate's MySql database for this sample Workflow to ensure that the data needed for the Workflow will always be available to test. This is similar to Sample1's Purchase Order Workflow, which uses a static web page for data to guarantee there will always be data available to test.

Because of this, you can enter the following URL into your browser to see Sample1 in action, ensuring the 'bridgegate_server' portion maps properly to your actual BridgeGate Server as well. NOTE: replace <bridgegate_server> in the following URL with YOUR BridgeGate server name:

http://<bridgegate_server>/portal/translate?accountName=samples&wfGroupName=sample1&wfName=purchaseorders&type=wf

For example:

http://qa.oidev.com/portal/translate?accountName=samples&wfGroupName=sample1&wfName=purchaseorders&type=wf

We will now focus on the Templates provided in this Tutorial, and links to the URL for each sample in this Tutorial are provided throughout the Tutorial.

Getting Started

Remember, the completed Samples for this Tutorial are located in the Samples account, in the Samples6 Workflow Group.

Start this Tutorial by starting your BridgeGate Client, by clicking on Start | Program | BridgeGate | BridgeGate Template Builder. Login, using the proper credentials.

While other Tutorials may have directed you to create the Sample from scratch, this Tutorial will not. After reviewing this Tutorial, feel free to create your own sample, using this Tutorial as a reference. Select Sample6 from the Inbound Templates screen. Select the only Inbound Template available for this Sample6 Workflow Group [read_data_from_database]:

Review of the Inbound Template

When the Inbound Template opens, notice the Database selected for the Inbound Template to read data from:

This is a predefined connection that is established from Repository menu.

The JDBC URL reads jdbc:mysql://192.168.10.11/samples. Be sure to change the 192.168.10.11 portion to the actual IP Address of your BridgeGate Server. Click the 'Test Connection' button to test that your modified JDBC URL is pointing properly.

After successful connection, you may Click the 'Connect To Selected Database' button to connect your template to the database for access while building/modifying the template.

When you no longer need to be connected, you may Click the 'Disconnect From Database' button to disconnect from the database.

Select the 'Records' tab on the right side of the Inbound Template screen. After opening, select the Record named 'Select Statement' as shown below:

This Inbound Template creates the following SQL Statement:

Select ORDER_NUMBER,ITEM_NUMBER,ITEM_NAME,QUANTITY from BG_SAMPLE_TABLE where vendor_id='789' order by id

This query will return 4 records, and when translated into the Outbound Template created for this Sample6 Tutorial, will look like the following:

"1006","a00001","8 oz cup, 100 count","3"
"1007","a00006","16 oz cup, 100 count","5"
"1008","a00192","24 oz cup, 100 count","5"
"1009","a00017","36 oz cup, 100 count","2"

Keep in mind this data is being retrieved from BridgeGate's internal MySql database, and was loaded when BridgeGate Server was installed. After reviewing the Outbound Templates and the Workflow for this Sample, we will come back to this Inbound Template and change the query to select records for a vendor by passing in a value through the URL that is called to translate, instead of having it hard-coded in the Inbound Template.

Review of the Outbound Templates

The first Outbound Template contains 4 Fields as CSV.

The second Outbound Template has the same 4 Fields, but is type XML.

Review of the Workflow

The Workflow for this example is named 'type1' and demonstrates the default way a Workflow is run through the dynamic translation feature of the BridgeGate Portal.

Type1 reads from a database and translates (using the translation servlet) the data to a CSV and an XML outbound. The type to use is set in the URL query string using one of the following:

type=wf - This parameter tells BridgeGate to look for a workflow. You specify the Workflow to execute with wfName. If multiple Send Data's are found for the Workflow, the first Send Data found will be used as the return data. If you have more than one Send Data and would like to specify the one to return data from, use the following parameter: sendDataName=(name) where (name) is the exact name of the Send Data.

This Workflow has a Data Source which points to the BridgeGate Server MySql Database, and a single Inbound Condition that has been set to be the default. Set the predefined connection below to include the proper IP Address, as you did previously for the Inbound Template:

The Data Destination creates a file locally on the computer the Workflow is run on (in this case the BridgeGate Server), under the location C:/Translation_Servlet_Sample_Directory/ Sample_Data_From_Translation.txt. This file is only created because a Data Destination is required for a Workflow to work.

Passing Database Query Values Through an URL

To pass a value, such as a Vendor Id through the URL requesting the data, add any value you wish to the end of the URL:

http://<bridgegate_serve:port>/portal/translate?accountName=samples&wfGroupName=sample6&wfName=type1&username=admin&password=admin&type=wf&vendor_id=789

Any values passed into the URL in this manner will be added to the Workflow Session as variables, and can be used in the same way as they are currently used throughout BridgeGate. For this example, we will add the vendor_id to the SQL Query in the Inbound Template, as below:

To use Workflow Session variables in the SQL Query, declare them in the section 'Clause Values' in the same manner as you would for a Custom DB Field, then use the Arg Name wrapped in % % to express the use of them, as in the example above: vendor_id='%arg%'

This use of appending values to the end of the URL and using these values from the Workflow Session can be used more than once. Many values can be passed in and used.

Running the Workflow

To run the workflow, enter the following URL into your browser:

http://<bridgegate_server:port>/portal/translate?accountName=samples&wfGroupName=sample6&wfName=type1&username=admin&password=admin&type=wf&vendor_id=789

Be sure the change <bridgegate_server:port> with the proper server name and port for your server. To see different data returned for this example, use the following Vendor Ids:

123
456
789

http://<bridgegate_server:port>/portal/translate?accountName=samples&wfGroupName=sample6&wfName=type1&username=admin&password=admin&type=wf&vendor_id=123 http://<bridgegate_server:port>/portal/translate?accountName=samples&wfGroupName=sample6&wfName=type1&username=admin&password=admin&type=wf&vendor_id=456 http://<bridgegate_server:port>/portal/translate?accountName=samples&wfGroupName=sample6&wfName=type1&username=admin&password=admin&type=wf&vendor_id=789

Troubleshooting

Case Sensitivity

Values added to the URL for Account Name, Workflow Group, Workflow, and all extra values (which are added to the Workflow Session) must be CaSe SeNSiTiVe.

Do Not Quote Values

In addition, do not wrap any of these values with single or double quotes, as the quotes themselves will be added to the values, such as below:

http://<bridgegate_server:port>/portal/translate?accountName='samples'&wfGroupName='sample6'&wfName='type1'&username='admin'&password='admin'&type='wf'&vendor_id='789'

OR

http://<bridgegate_server:port>/portal/translate?accountName="samples"&wfGroupName="sample6"&wfName="type1"&username="admin"&password="admin"&type="wf"&vendor_id="789"

Base 64 URL Encoding, which is automatic in most browsers, is acceptable. URL's are decoded before the values are sent to BridgeGate. URL Encoded turns many ASCII values into hex values through the used of a %, such as %20 for spaces.