We checked IBM’s endpoint pages against the behaviour of Manage in the MAS 9.2 series, and we checked the methods of IBM’s examples on our test system. Where the pages and Manage disagree, this page follows Manage.
An endpoint that is a script#
IBM’s steps work: add a handler with the class com.ibm.tivoli.maximo.script.ScriptRouterHandler,
create an endpoint for it, and set its SCRIPT property to the script name. One detail is missing:
write the script name in upper case. The handler looks the name up twice, once upper-cased and
once as typed. With IBM’s lower-case example name, the second lookup finds nothing, and the call
fails with a NullPointerException.
The script gets the message and the endpoint’s settings as variables:
| Variable | Holds |
|---|---|
requestData | the message as bytes |
requestDataS | the message as text, decoded as UTF-8; None only when there is no data |
| every endpoint property | its value, under its own name |
metaData | all endpoint properties as one map |
responseData | set by the script: text or bytes, returned to the caller |
For a publish channel endpoint, the properties include JMS or Kafka headers, and destination is the
external system.
IBM’s example sends the message by mail with variables called to, from and subject. In Python,
from is a reserved word, so the script does not compile. Name the variable something else:
from psdi.server import MXServer
MXServer.getMXServer().sendEMail(to, sender, subject, requestDataS)to, sender and subject are literal variables of the script.
Handler exits#
The HTTP, SOAP and JMS handlers each accept an exit. Set the handler’s exit property to
script:<NAME>:
| Handler | Exit property |
|---|---|
| HTTP | HTTPEXIT |
| SOAP (JAX-WS) | WSEXIT |
| JMS | JMSEXIT |
IBM’s pages never name JMSEXIT. An exit works through named functions, so the script needs the
Interface flag. Manage does not set it for these names, so set it yourself. Without it, the source
runs once from top to bottom, and no function is called. Each function receives a request or response
object. The request objects also offer every method of service.
The HTTP exit#
| Function | What the script does there |
|---|---|
getUrl(req) | changes the target with req.setURL(url) |
urlProps(req) | adds query parameters with req.addUrlProp(name, value) |
headerProps(req) | adds headers with req.addHeader(name, value) |
formData(req) | adds form fields with req.addFormProp(name, value) |
processResponse(resp) | reads resp.getResponseCode() and resp.getData(), and can call resp.setError(...) |
The traps:
- The method is
setURL. IBM writessetUrl, which was missing on our test system. - Your parameters and headers replace the configured ones. When
urlPropsruns, its parameters replace the query parameters from the endpoint, including those an invoke channel passed in. The same holds forheaderPropsand the configured headers. formDataexists. Neither IBM page names this function.processResponsetakes over the status check. With this function defined, the handler skips its own check, and a 4xx or 5xx answer counts as success unless the script callssetError.- The response body cannot be replaced. The handler returns the original body.
- An error inside a function is caught and printed. The call goes on.
So a processResponse should always check the status:
from java.lang import Exception as JavaException
def processResponse(resp):
if resp.getResponseCode() >= 400:
resp.setError(JavaException("HTTP status " + str(resp.getResponseCode())))setError takes a java.lang.Exception. IBM’s page writes java.util.Exception, a class that does
not exist. The status text comes from resp.geResponseMsg(), with the spelling Manage uses. IBM Docs
writes getResponseMsg, which was missing on our test system.
A common use of headerProps is a token. The function fetches it, for example with
req.httpgetasjson(...), and sends it with req.addHeader. The IBM Docs copy of that example stops
before the addHeader line, so it fetches the token and never sends it.
The SOAP exit#
| Function | What it does |
|---|---|
setupHeaders(req) | adds SOAP headers with req.addHeader(namespace, name, value) |
responseOk(resp) | sees the answer; resp.setError(...) turns it into a failure |
responseError(resp) | sees the fault in resp.getError(); the fault is raised again unless the script calls resp.setError(None) |
Three details:
- The headers that the script adds replace the headers passed in. A second header with the same name replaces the first.
req.setURLhas no effect. The method exists, and nothing reads its value.- The SOAP response headers are available.
req.fetchResponseHeaders()asks for them, andresp.getResponseHeaders()returns them. Neither IBM page names the pair.
IBM’s WS-Security example builds its header with org.jdom. Manage 9.2 has org.jdom2, and the
helper that turns the element into text takes a JDOM 2 element.
The JMS exit#
| Function | What it does |
|---|---|
msgProps(req) | sets JMS message properties with req.addProperty(name, value) |
responseOk(resp) | runs after the commit; its result is ignored |
responseError(resp) | never runs in the 9.2 series |
An error from the JMS provider never reaches the script. The handler raises it again without calling
responseError, so resp.getError() is always None. After msgProps, the handler sets its own
properties, such as INTERFACE, SENDER and destination, and overwrites script values with the
same names. The JMS request has no setURL or getURL, as our test system confirmed.
What IBM’s pages get wrong here#
| Topic | IBM’s pages | What Manage does |
|---|---|---|
The SCRIPT property | a lower-case name | must be upper case, or the call fails |
| The mail example | a variable from | a reserved word; the script does not compile |
HTTP setUrl | sets the URL | missing; the method is setURL |
| HTTP error type | java.util.Exception | java.lang.Exception |
| HTTP status text | getResponseMsg (IBM Docs) | missing; the method is geResponseMsg |
SOAP setURL | overrides the URL | has no effect |
JMS responseError | handles an error | never called |
JMS setURL, getURL | exist | missing |
Article 33 of this series collects the corrections that matter most.
What comes next#
Article 21 covers publish channels, event filters, workflow and message-driven bean scripts.
IBM’s own pages are the reference to keep next to this series:
- Automation scripts in the IBM Maximo Manage documentation.
- All about Maximo scripting, IBM’s scripting guide on GitHub.
The complete list of corrections, with the evidence for each one, is in our member area. Members get access on request, so get in touch if you want it. If you want help with the scripts in your own Manage, our services page shows how we work.
IBM and Maximo are trademarks of International Business Machines Corporation, registered in many jurisdictions worldwide.
