Contact

Custom message process in MEC

What is a message process?

A message process in MEC is one of the steps in a process flow. Technically speaking, it is a Java class that reads a stream of bytes as an input, does some processing on it, and writes a stream of bytes as an output, for example transform a flat file to XML, apply XSLT to an XML, remove an envelope, archive the message, or make a SOAP request. Message processes are chained together in a partner agreement in the Partner Admin Tool.

Documentation

The Partner Admin Tool User Guide has some information about message processes:

Java classes

Each message process is a Java class in package com.intentia.ec.server.process:

Each message process may have a configuration dialog box in package com.intentia.ec.partneradmin.swt.agreement:

Database

The message processes are declared in the MEC database in table PR_Process:

Java code

To create your own message process follow these steps:

Use the following skeleton Java code, fill with your code, set the file extension for the output message (in my example it is .something), use the in input and out output streams to process the message as you need, and eventually use the cat logger to write debug info in the log file:

In the Infor Grid, restart the MECSRV application to pick up the new Java class:

In the Partner Admin Tool, create a partner agreement and add the message process:

Reload the MEC server to pick up the new agreement:

Run the partner agreement, for example I have a channel detection with a HTTPIn receive channel listening on port 8084, and I make an HTTP request to that port number to trigger the partner agreement.

Check the message received (.rcv) and the message produced (in my case it was extension .something); for that, you will need one Archive process in your partner agreement, before and after your custom process:

You can also open the files directly in the folder specified:

And if you used the logger, you can check your logs in the Event tab:

Real-world example

In my case, I needed a custom message process for the following real-world scenario. My current customer does Procurement PunchOut with its partners using cXML, an old protocol from 1999. In that protocol, there is a step (PunchOutOrderMessage) that sends an XML document in a hidden field cxml-urlencoded of an HTML form. That results in a POST HTTP request (to MEC) with Content-Type: application/x-www-form-urlencoded, with the XML document that is URL-encoded as a value of parameter cxml-urlencoded in the request body. Unfortunately, MEC does not have a message process to extract a specific parameter value of a message, and URL-decode it. So I developed my custom message process as explained above, to take the request body, extract the desired parameter value, URL-decode it, and output the resulting XML. I may write a detailed post about it some day, maybe not.

Conclusion

That was a guide on how to create a custom message process in MEC, doing Java development, to take an input message in a partner agreement, do some custom processing on it, and produce an output message. This is an unofficial solution that I figured out by de-compiling and hacking MEC. There may be a simpler solution, I do not know.

That’s it! Thank you for supporting this blog, please like, subscribe, share around you, and come author the next blog post with us.

UPDATE: The string returned by getState() does not get SQL escaped, so it’s subject to SQL injection, e.g. “Thibaud’s process” with an ampersand. It’s not really a security vulnerability as only MEC admins/developers have access to this.