White Papers
Abstract
IBM DataPower Gateway performs a WSDL conversion when it exposes the WSDL to their clients. However, some Java clients cannot retrieve more schemas, which DataPower creates for optimization purposes. In this article, you learn how to override this optimization by using XSL transformations and XSL dynamic routing.
Content
IBM DataPower Gateway Appliances (after called DataPower) help you to virtualize your web services to act as a gateway. This pattern gives you many advantages, such as: For this reason, it is common to see this pattern in the network infrastructure of the customers. This article is written for IBM DataPower Gateway administrators and developers who have interoperability issues with web services consumers that require the schema to be embedded in the WSDL, instead of a reference to the XSD schema file. To build and execute the example in this article, you need: You can import the export package, provided with this article, from the Import configuration option of your DataPower Control Panel. You also need to modify the One of the typical scenarios where DataPower fits is shown in Figure 1. The web service itself is located in WebSphere Application Server (after called Application Server) and DataPower sits between Application Server and clients (typically the Demilitarized Zone - DMZ). When a client wants to consume a web service, it invokes to DataPower, which checks for security threats and URL rewrites, checks the scheme of the incoming message, and performs all the operations specified on its processing policy before it invokes the service in the local intranet. The most flexible way to expose web services when you work with DataPower is by using a Web Service Proxy. When you expose a web service by using the Web Service Proxy object, DataPower requires the Web Services Description Language (WSDL) file. Once the service is deployed in the Web Service Proxy, DataPower internally optimizes the WSDL file for its consumption. If a client invokes the address of the service deployed in DataPower (plus the WSDL), it serves an optimized version of the WSDL, as shown in the following Sometimes, a legacy web service client might request the WSDL to the device. As mentioned before, DataPower serves the WSDL with internal references to XML schemas (also known as XSD), and the client cannot retrieve the XSD file. It needs a single WSDL file with every artifact embedded in it. Therefore, if the client cannot retrieve the schemas, you can configure a Multi-Protocol Gateway in DataPower to retrieve the internal references, compose a single WSDL file, and serve it to the client. This pattern is reflected in Figure 2. In this section, you create a policy with three rules in it: The policy looks similar to Figure 5. This rule is triggered when the consumer requests the WSDL (see Figure 6). It is detected by the presence of the "?WSDL" pattern ending the URL. This stylesheet gets the WSDL file from the backend. Since the Multi-Protocol Gateway you are creating in this sample can be used to modify the WSDLs of several Web Service Proxy services, the stylesheet loads a routing file, whose format is: URL of the service (deployed in the Multi-Protocol Gateway) and host of the service (where the service is located, typically the Web Service Proxy). An entry for this file would be: After you get the host where the service is deployed and building a valid URL for the WSDL, the stylesheet performs a The WSDL is the output of the stylesheet. The This rule handles the client SOAP requests and forwards it to the backend (see Figure 7). This rule handles the SOAP response and serves it back to the consumer (see Figure 8). Create a server-to-client rule just to get the SOAP responses back to the client. The .zip file provided with this article contains the sample files you previously selected in the configuration of the Multi-Protocol Gateway. Extract them by using your favorite .zip file extraction tool. An export of the Multi-Protocol Gateway is also provided ( In this article, you learned how to change services in IBM DataPower Gateway to modify the content of the WSDL files served by the Web Service Proxy object, or any other server that splits the WSDL file in several files. Splitting the files is good practice, but some clients are not able to get those files. You also learned how to route requests by using a routing file and the Introduction
Prerequisites and system requirements
Sample files
mappings.xml file to make the sample work properly with your services. No further downloads are required to complete the instructions in this article. Understanding the architecture

xsd:import:
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" ...> ... <wsdl:types xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:schema> <xsd:import schemaLocation="TemperatureConverter.xsd1.xsd" namespace="http://converter.com"/> </xsd:schema> </wsdl:types> ... </wsdl:definitions>
Creating the Multi-Protocol Gateway in DataPower

Rewrite_XSD_Imports". Configure it as a dynamic-backend gateway and set both the request and response type as XML.
Creating the Multi-Protocol Gateway Policy

Rule 1: Both directions

(.*)[w|W][s|S][d|D][l|L]. Check the "Match with PCRE" toggle to on under the Main tab of the Matching Rule.
<mapping source="http://9.172.176.70:5321/services/TemperatureConverter" target="http://127.0.0.1:567"/>
dp:url-open() call to obtain the WSDL. The code for the stylesheet is shown in Listing 1.
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dp="http://www.datapower.com/extensions" xmlns:regexp="http://exslt.org/regular-expressions" xmlns:dpconfig="http://www.datapower.com/param/config" extension-element-prefixes="dp dpconfig regexp" version="1.0"> <xsl:param name="dpconfig:mapping-file" select="'off'"/> <dp:param name="dpconfig:mapping-file" type="'dmFileToggle'" xmlns=""> <tab-override>basic</tab-override> <display>Mapping file</display> <description>Select the mapping file to convert the URL's The default is local:///mappings.xml.</description> <default>local:///mappings.xml</default> </dp:param> <xsl:template match="/"> <xsl:variable name="mappings" select="document($dpconfig:mapping-file)"/> <xsl:variable name="host_to_find" select="regexp:replace( dp:variable('var://service/URL-in'), '(.*)\?wsdl','i','$1')"/> <xsl:variable name="host" select="$mappings/mappings/mapping[@source=$host_to_find]/@target"/> <dp:set-variable name="'var://context/wsdl-fetch/host_to_find'" value="$host_to_find"/> <dp:set-variable name="'var://context/wsdl-fetch/host'" value="$host"/> <dp:set-variable name="'var://context/wsdl-fetch/wsdl-location'" value="concat($host,dp:variable('var://service/URI'))"/> <dp:url-open target="{ dp:variable('var://context/wsdl-fetch/wsdl-location')}"/> </xsl:template> </xsl:stylesheet> schema-fetch.xsl stylesheet finds all the imports in the previously downloaded WSDL and replaces all of them with the document, which it is pointing to. To replace the import tags, the stylesheet builds, again, the URL of each schema and uses the dp:url-open() extension again to fetch them and place it into the WSDL file. The code for the schema-fetch.xsl stylesheet is shown in Listing 2.
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dp="http://www.datapower.com/extensions" xmlns:regexp="http://exslt.org/regular-expressions" extension-element-prefixes="dp regexp" version="1.0"> <xsl:template match="/"> <xsl:apply-templates/> </xsl:template> <xsl:template match="/*[local-name()='definitions'] /*[local-name()='types']/*[local-name()='schema']"> <xsl:for-each select="*[local-name()='import']"> <xsl:variable name="myURI" select="regexp:replace( dp:variable('var://service/URI'), '(.*)/(.*)?wsdl','i','$1/')"/> <xsl:variable name="location" select="concat( dp:variable('var://context/wsdl-fetch/host'), $myURI,@schemaLocation)"/> <dp:url-open target="{$location}"/> </xsl:for-each> </xsl:template> <!-- Copy everything else --> <xsl:template match="@*"> <xsl:copy/> </xsl:template> <xsl:template match="*"> <xsl:copy> <xsl:copy-of select="@*"/> <xsl:apply-templates select="node()"/> </xsl:copy> </xsl:template> </xsl:stylesheet>var://service/mpgw/skip-backside variable to "1". This action avoids the backside processing phase. Rule 2: Client-to-server direction

wsdl-post.xsl stylesheet is shown in Listing 3.
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dp="http://www.datapower.com/extensions" extension-element-prefixes="dp" version="1.0"> <xsl:template match="/"> <xsl:variable name="mappings" select="document('local:///mappings.xml')"/> <xsl:variable name="host" select="$mappings/mappings/mapping[@source= dp:variable('var://service/URL-in')]/@target"/> <dp:set-variable name="'var://service/routing-url'" value="concat( $host,dp:variable('var://service/URI'))"/> </xsl:template> </xsl:stylesheet> Rule 3: Server-to-client direction

Rewrite_XSD_Imports.zip), so you can import it by using the Import Configuration option in the DataPower Control Panel. The .zip file includes the following files:
Conclusion
var://service/routing-url variable.
Was this topic helpful?
Document Information
Modified date:
08 June 2021
UID
ibm11109505