It is often the case that a DataPower developer will have work to do, but does not yet have a backend Service Provider to point the DataPower service at. In general, anything beyond trivial examples will need to point at something that returns a valid response. In order to satisfy this requirement, an XML Firewall can be setup in loopback mode that uses a custom stylesheet to generate a valid response. This tutorial will demonstrate how to create this XML Firewall.
For our example, we are going to return a valid SOAP response for thisWSDL.
- Log into the DataPower appliance and navigate to the Control Panel screen if not already there.
- Click on the XML Firewall icon.
- Click the “Add Wizard” button.
- Chose “Pass Thru (Testing Only) radio button.
- Click the Next button.
- Type a name for this XML Firewall in the text field. For this tutorial, we will use MathWS.
- Click the Next button.
- Chose “loopback-proxy” from the drop-down menu.
- Click the Next button.
- In the Device Address field, either a valid IP address or Host Alias must be added. For this example, a Host Alias called PublicInterface, which maps to the public IP address used by one of the ethernet interfaces on this appliance.
- The Device Port field should have a valid TCP port. For this example, we are using 10002.
- For now, SSL will not be used in this example. So, keep the “off” radio button checked for the last parameter.
- Click the Next button.
- This screen lets us review the settings we have chosen in this wizard.
- Click the Commit button.
- Click the Done button.
- Click the save link in the upper, right-hand corner.
- Click on the XML Firewall icon again.
- Click on the MathWS link.
- In the right-hand column, at the bottom, choose “XML” from the Request Type dropdown menu.
- Click the Apply button.
- Click the Advanced tab link.
- In the left-hand column, click the off radio button under “Disallow GET (and HEAD)”.
- In the right-hand column, click the on radio button under “Process Messages Whose Body IS Empty”.
- Click Apply.
- Click the save config link.
- Next, we need to create an XSLT stylesheet that will return a static response to SOAP queries. As a starting point, copy the contents of the stylesheet given in this tutorial into your favorite XML editor.
- So, you should now have the following in your XML editor:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:dp="http://www.datapower.com/extensions"
xmlns:dpfunc="http://www.datapower.com/extensions/functions"
xmlns:dpconfig="http://www.datapower.com/param/config"
xmlns:func="http://exslt.org/functions"
extension-element-prefixes="dp func"
exclude-result-prefixes="dp dpfunc dpconfig func">
<xsl:template match="/">
</xsl:template>
</xsl:stylesheet>
Next, we need to generate a valid SOAP response. This can be done with SOAPUI.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:dp="http://www.datapower.com/extensions"
xmlns:dpfunc="http://www.datapower.com/extensions/functions"
xmlns:dpconfig="http://www.datapower.com/param/config"
xmlns:func="http://exslt.org/functions"
extension-element-prefixes="dp func"
exclude-result-prefixes="dp dpfunc dpconfig func">
<xsl:template match="/">
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"xmlns:ws="http://ws.rcbj.com/">
<soapenv:Header/>
<soapenv:Body>
<ws:sumResponse>
<return>6</return>
</ws:sumResponse>
</soapenv:Body>
</soapenv:Envelope>
</xsl:template>
</xsl:stylesheet>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"xmlns:ws="http://ws.rcbj.com/">
<soapenv:Header/>
<soapenv:Body>
<ws:sum>
<arg0>2</arg0>
<arg1>4</arg1>
</ws:sum>
</soapenv:Body>
</soapenv:Envelope>
<soapenv:Envelope xmlns:ws="http://ws.rcbj.com/"xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<ws:sumResponse>
<return>6</return>
</ws:sumResponse>
</soapenv:Body>
</soapenv:Envelope>
You have successfully constructed a “dummy service” that can be used in the absence of a legitimate Service Provider implementation.
Great tutorial. Thanks a lot. It help us a lot.
ReplyDelete