Apache Authors: Pat Romanski, Jnan Dash, Lacey Thoms, Sandi Mappic, Michael Bushong

Related Topics: Java, SOA & WOA, Websphere, AJAX & REA, Apache

Java: Article

Enterprise Framework Service for WebSphere Datapower

Minimize the exposure of ports and their configuration on firewall

Create Enterprise Framework Service:
Perform the following steps to create an Enterprise Framework Service, called EnterpriseFrameworkServiceMPGW, in Datapower.
1-    Create two loopback Services using XML Firewall:
1.a.    ServiceA
1.b.    serviceB

2-    Create the following 3 files
2.a.    Create EnvironmentConfig.xml. This file contains the environment value, so the incoming request is assign to right backend.

2.b.    Create EnvironmentConfig.xslt. This XSLT file read value from the EnvironmentConfig.xml and set the environment variable.

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"




exclude-result-prefixes="xalan dp"


<xsl:template match="/">

<xsl:variable name="masterConfig" select="document('local:///EnvironmentConfig.xml')"/>

<dp:set-variable name="'var://context/wp/environment'" value="normalize-space($masterConfig/config/environment/text())"/>




2.c.    Create EnterpriseFrameworkRouter.xslt. This XSLT file constructs the backend URL by preserving the incoming URI and reading the target host
information from the config.xml of that service.

<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"


extension-element-prefixes="dp" exclude-result-prefixes="dp">

<xsl:template match="/">

<xsl:copy-of select="."/>

<xsl:variable name="incomingURI">

<xsl:value-of select="dp:variable('var://service/URI')"/>


<xsl:variable name="tempVar">

<xsl:value-of select="substring-after($incomingURI,'/')"/>


<xsl:variable name="serviceName">

<xsl:if test="contains($tempVar,'/')">

<xsl:value-of select="substring-before($tempVar,'/')"/>


<xsl:if test="not(contains($tempVar,'/'))">

<xsl:value-of select="$tempVar"/>



<xsl:param name="hostAddr" select="'local:///'"/>

<xsl:variable name="remoteURL" select="concat($hostAddr,'/xml/',$serviceName,'/config.xml')"/>

<xsl:variable name="environment" select="dp:variable('var://context/wp/environment')"/>

<xsl:variable name="config" select="document($remoteURL)" />

<xsl:variable name="serviceDestination">

<xsl:copy-of select="$config/EnterpriseFrameworkDestinationList/serviceDestination[@environment=$environment]"/>


<dp:set-variable name="'var://service/routing-url'" value="concat($serviceDestination,$incomingURI)"/>





3-    Upload these files to Datapower
3.a.    Create “xslt” folder and upload both xslt files there
3.b.    Upload “EnvironmentConfig.xml” to “local:///


4-    Create a Multi-Protocol Gateway (MPGW) named,  EnterpriseFrameworkMPGW with:
4.a.    Dynamic backend
4.b.    Request and Response type to Non-xml


5-    Create a front side handler, name it EnterpriseFrameworkFSH and assign port number to “81


6-    Create a new policy, EnterpriseFrameworkPolicy, and add following rules:
6.a.    Create a new rule for “Client to Server” and with two Transform actions
6.a.i.    Assign EnvironmentConfig.xslt to the first Transform action, make sure the Output set to NULL


6.a.ii.    Assign EnterpriseFrameworkRouter.xslt to the second Transform action, make sure Output set to NULL


6.b.    Create a new rule for “Server to Client” without any actions
6.c.    Overall EnterpriseFrameworkPolicy should look like this:

6.d.    Apply the Policy and close the window

7-    The EnterpriseFrameworkMPGW should look like this:  Save the configuration.


Integrate the Existing or New Services to the Enterprise Framework:

In order to incorporate the existing or new service in to the Enterprise Framework
1-    Create folder with the name of the service as a folder name under local:///xml/


2-    Create the following config.xml for serviceA
2.a.    The config.xml file for serviceA, which contains the IP address or hostname for each environment and  the port where serviceA is running

<?xml version="1.0" encoding="UTF-8"?>


<serviceDestination environment="DEV"></serviceDestination>

<serviceDestination environment="QA"></serviceDestination>

<serviceDestination environment="PROD"></serviceDestination>




3-    Upload the config.xml file at “local:///xml/serviceA” folder


4-    Create the similar config.xml for serviceB with serviceB’s hosts for each environment and assigned port

<?xml version="1.0" encoding="UTF-8"?>


<serviceDestination environment="DEV"></serviceDestination>

<serviceDestination environment="QA"></serviceDestination>

<serviceDestination environment="PROD"></serviceDestination>



5-    Upload the config.xml file at local:///xml/serviceB folder

6-    Every time a new service need to be integrated to Enterprise Framework, a config file need to be created for that service with values
of hostname/IP address and the port number where the service is installed. Nothing needs to be done on the EnterpriseFrameworkMPGW at all.

7-    For every incoming request EnterpriseFrameworkRouter.xslt (installed in the EnterpriseFrameworkMPGW) parse the URI and look for the
config.xml file for that service. If the service is not installed then there will be no xml/config file for that service.

Testing / Verification:

1-    Enabled the probes on serviceAFW and serviceBFW
2-    From the SOAP UI send the following test message for serviceA (http://<hostname>:81/serviceA)

3-    You should see the response back

4-    From the serviceA probe.  Notice the values of inbound-url and outbound-url.

5-    Now, send the request for serviceB  (http://<hostname>:81/serviceB)

6-    From the serviceB probe.  Notice the values of inbound-url and outbound-url.

7-    From the EnterpriseFrameworkMPGW Probe, you can see the requests are directed to their respective services. Notice the values of inbound-url and outbound-url.

By implementing the Enterprise Framework Service to any WebSphere Datapower environment, it helps to streamline the development of
new services inside Datapower.  Datapower administrators do not need to deal with firewall and network configuration whenever a new
service is implemented on its appliances.  The framework also does not allow exposing any additional ports outside the network.

More Stories By Asim Saddal

Asim Saddal works in the Middleware (WebSphere Application Server, WebSphere Datapower, WebSphere Process Server, WebSphere VE) practice of IBM Software Services for WebSphere.