SOAP Web Service Mockup tutorial on DataPower

Robert Broeckelmann

DataPowerSOAPToolsWeb ServicesNetworking

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 this WSDL.

  1. Log into the DataPower appliance and navigate to the Control Panel screen if not already there.

  2. Click on the XML Firewall icon.

image

  1. Click the “Add Wizard” button.

image

  1. Chose “Pass Thru (Testing Only) radio button.
  2. Click the Next button.

image

  1. Type a name for this XML Firewall in the text field.  For this tutorial, we will use MathWS.
  2. Click the Next button.

image

  1. Chose “loopback-proxy” from the drop-down menu.
  2. Click the Next  button.

image

  1. 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.
  2. The Device Port field should have a valid TCP port.  For this example, we are using 10002.
  3. For now, SSL will not be used in this example.  So, keep the “off” radio button checked for the last parameter.
  4. Click the Next button.

image

  1. This screen lets us review the settings we have chosen in this wizard.
  2. Click the Commit button.

image

  1. Click the Done button.

image

  1. Click the save link in the upper, right-hand corner.

image

  1. Click on the XML Firewall icon again.

image

  1. Click on the MathWS link.

image

  1. In the right-hand column, at the bottom, choose “XML” from the Request Type dropdown menu.
  2. Click the Apply button.
  3. Click the Advanced tab link.

image

  1. In the left-hand column, click the off radio button under “Disallow GET (and HEAD)”. 
  2. In the right-hand column, click the on radio button under “Process Messages Whose Body IS Empty”.
  3. Click Apply.
  4. Click the save config link.

image

  1. 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.
  2. So, you should now have the following in your XML editor:

<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.

  • Download the WSDL to your local file system.
  • Download SOAPUI or a similar tool.
  • Launch SOAPUI.

 image

  • Click File->New SOAPUI Project.

image

  • Enter “MathWS” in the Project Name field.
  • Click the browse button.
  • Choose the MathWS.wsdl file that was selected earlier.
  • Click Ok.
  • After some processing, a project will be created.
  • Expand the MathWS->MathWSSoapBinding->sum->Request 1 tree.
  • Double-click on the Request 1 node.

image

  • You will see a request message with ‘?’s in place of values.
  • Click  the SOAP icon (third icon from the left) on the Request 1 window.

image

  • The following pop up box will appear.

image

  • Click the Yes button.
  • Enter a name for the Mock Service.
  • Click the Ok button.
  • When prompted for “Open MockResponse editor?”, click the Yes button.

image

  • We now have a valid SOAP response that can be added to our new stylesheet.
  • Copy the text in the Response1 window into the