The title of this article is quite scaring right?
Let’s describe the scenario…
You have an external application that needs to query or update data in Maximo using a Web Service call. In the real world the outbound XML schema of the caller is different from the Maximo inbound interface.
How can you transform the incoming request to the standard Maximo Web Service interface?
This article describes how to use XSLT (EXtensible Stylesheet Language Transformation) to transform the inbound XML structure to a MIF-compliant one.
This diagram describes what we need to achieve.
Setup test tool (SoapUI)
Testing the XSL Transformation in Maximo can be really tedious. You absolutely need a tool to test the XSLT code before putting it into Maximo.
There are many tools around. I suggest to use WmHelp XmlPad for Windows or XTrans.
In this tutorial I will focus on a sample inbound request to create or update an asset into Maximo. This is the sample XML.
<Import> <Equipment> <Equipment>001</Equipment> <Description>My desc</Description> </Equipment> </Import>
We want this incoming XML to be transformed to the following MIF WebService call.
<max:SyncMXD-ASSET> <max:MXASSETSet> <max:ASSET> <max:SITEID>BEDFORD</max:SITEID> <max:ASSETNUM>001</max:ASSETNUM> <max:DESCRIPTION>My desc</max:DESCRIPTION> </max:ASSET> </max:MXASSETSet> </max:SyncMXD-ASSET>
Develop XSL Transformation
Now the interesting part…
XSLT is a powerful tool to transform XML structures. I think it is the best technical option to integrate two different systems using Web Services.
I use XMLPad to develop XSLT and test itbut you can use any other tool of your choice.
Now test the following XSL on the sample inbound XML and you will see the magic.
<?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:max="http://www.ibm.com/maximo"> <xsl:output method="xml" encoding="UTF-8" indent="yes"/> <xsl:template match="Import"> <xsl:apply-templates select="Equipment"/> </xsl:template> <xsl:template match="Equipment"> <max:SyncMXD-ASSET> <max:MXASSETSet> <max:ASSET> <max:SITEID>BEDFORD</max:SITEID> <max:ASSETNUM><xsl:value-of select="Equipment"/></max:ASSETNUM> <max:DESCRIPTION><xsl:value-of select="Description"/></max:DESCRIPTION> </max:ASSET> </max:MXASSETSet> </max:SyncMXD-ASSET> </xsl:template> </xsl:stylesheet>
Deploy XSL file
When everything is working fine in your local test tool you are ready to set the XSL transformation in the Web Service configuration.
There are two methods to provide the XSL file to Maximo: on the filesystem or in the maximo.ear file.
The first one is simpler. First of all you have to copy the XSL file on the Maximo server. For example D:\MIF\MXD-ASSETES.xsl.
Open the Web Services application (Go To > Integration > Web Services) and select the MXD-ASSETES service created in the first tutorial. Set the full path of the XSL file in the ‘XSL Map’ field.
If you have a cluster of application servers it may be convenient to store the XSD file in the EAR file. Copy the XSL file in a subdirectory of the businessobjects folder in the SMP dir. For example D:\IBM\SMP\maximo\applications\maximo\businessobjects\classes\maximodev\xsl.
After having rebuilt and redeployed the maximo.ear file you can reference the XSL file setting maximodev.xsl.MXD-ASSETES in the ‘XSL Map’ field (without the .xsl file extension).
Test the Web Service
Now launch SoapUI application and create a new project specifying the WSDL link in the ‘Initial WSDL’ field. Replace the entire content of the sample request with this (setting the correct SITEID).
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:max="http://www.ibm.com/maximo"> <soapenv:Header/> <soapenv:Body> <Import> <Equipment> <Equipment>001</Equipment> <Description>My desc</Description> </Equipment> </Import> </soapenv:Body> </soapenv:Envelope>
You can see that this is just the sample XML wrapped in a SOAP envelope.