Endpoint scripts

You can write Maximo® Integration Framework (MIF) endpoint handlers by using automation scripts. For example, you can write a handler for sending emails.

To write a handler for sending emails, complete the following steps.
  • Click Add/Modify Handlers in the End Points application.
  • Click New Row to add a new handler.
  • Name the handler SCRIPT and set the handler class name to com.ibm.tivoli.maximo.script.ScriptRouterHandler.
  • Create a new endpoint for the handler you created.
  • Set the handler to SCRIPT.
  • Set the script property to the name of the script that you are going to write. For example, you can name the script emailme.
The following table shows the implicit variables specific to endpoint scripts.
Table 1. Implicit variables specific to endpoint scripts
Variable Purpose
requestData Byte[] data for endpoints.
requestDataS String data for endpoints. If the byte[] cannot be converted to string, this variable is not set.
responseData This is an OUT implicit variable. The endpoint script code can set it to store the response from the actual endpoint call. This can be set as a string or a byte[].

All endpoint metaData content is set as variables to the script. This means that in case of Publish Channel endpoints, all JMS and Kafka message headers are set as variables in the script. Variables like destination are available and set to the external system name for that endpoint script.

The following code is a simple example.
from psdi.server import MXServer
from java.lang import String

MXServer.getMXServer().sendEMail( to,from,subject, String(requestData))

You can define the from and to as literal variables in the script and then set the email addresses there. You can also define another literal variable called subject to define a static subject for the email like “Email from Maximo.” You can make it more dynamic by getting the to email from the data, and set other properties.

The following example shows how to write a custom web service handler that uses WS-Security UserNameToken, which is not supported in MIF WebService Handler. The following script code uses the JAXWSClient utility to set WS-Security UserNameToken.
from org.jdom import Element
from org.jdom import Namespace
from psdi.iface.webservices import JAXWSClient
from java.util import HashMap
from java.util import ArrayList
from psdi.iface.util import XMLUtils
from javax.xml.namespace import QName

ns = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"

The code uses the JDOM library that ships with IBM® Maximo Manage to create the security header. The script code hard codes the username and password, but they can be set as script literal variables. This is also applicable with the URLs to invoke, in this case, /meaweb/services/SYSTEM, and other input parameters to the cl.invoke(..) call. The code shows how to add the SOAP headers as well as HTTP headers as an example.