webMethods Integration Server: Create non-printable characters

It is a common requirement (e.g. for search-replace operations on strings) to create characters that are non-printable, which also means there is no obvious way to type them in. In my case the situation was that I had to convert end-of-line characters  created on a Windows system (CR+LF) to Linux (LF only) for some unit tests to pass.

On webMethods Integration Server you have two options to do this. The first is to create a small Java service, which has the down-side that some people shy away from it. (I have even seen organizations that pretty much forbid them, which is probably a bit extreme.) The second way is to have a Flow service (Integration Server’s graphical programming language), which is what I demonstrate here.

So how do I create a LF character? For this you can use the pub.string:URLDecode service with “%0a” (without double-quotes) as input, which is simply the character with ASCII number 10 (0x0a).

And then you simply perform a replace operation using the pub.string:replace service and tell it to replace all CR+LF occurrences with LF. The search part is done best with a regular expression, in this case “\r\n” (again without the double-quotes). And don’t forget to set useRegex to true.

That’s it.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.