Module in this article: Toolbox
SAP CPI Payload Tools: Compare, Convert and Generate Test Data in the Browser
Compare two payloads, convert XML, JSON, YAML and CSV with SAP's converter rules, generate test payloads with faults, and insert Groovy snippets, offline next to the iFlow designer.
Half of the work on an SAP Cloud Integration (SAP CPI) iFlow happens around the payload: two messages that should be the same and are not, a JSON body the receiver wants as XML, a set of test messages for the error handling, a Groovy line you write every week and never remember. These jobs usually end in a text editor, an online converter and a script of your own.
Kitegra's Toolbox puts them in the browser, next to the iFlow designer: payload compare, a format converter, a test payload generator, Groovy snippets with a cheat sheet, and an HTTP Runner. Except for the requests you send with the HTTP Runner, they work offline. What you paste stays in the page and is never stored or sent.
Where to find the Toolbox
Open the extension's popup and choose Tools. The Toolbox list opens each tool in a tab of its own: Payload compare, Format converter, Test payload generator, Snippets and cheat sheet, HTTP Runner and iFlow Docs. On an iFlow, the menu of the Kitegra box in the diagram toolbar also opens Snippets and Notes as panels on the page.
Every control has a small (i) next to it that says what it does. The Toolbox counts no iFlows against your plan.
Payload compare
Paste two payloads, load them from files or drop them on the page, and the differences are marked line by line. Previous and Next move from one difference to the other, with a count of how many there are.
- Ignore whitespace: lines that differ only in spaces, tabs or indentation count as equal.
- Normalise XML: sorts attributes, ignores namespace prefixes and indents both sides, so only real changes are left.
- Normalise JSON: sorts keys and indents.
- Differences only: hides the lines that are the same, with a count of the hidden lines in their place.
- Swap A and B: what showed as added shows as removed.
A payload that is not well-formed XML or valid JSON is still compared, as text. In the Message Monitor, the payload viewer of a traced step has Compare with the next step, which opens this page with the body before and after that step. See tracing a message step by step.
Format converter
Paste XML, JSON, YAML, CSV or any text, or load a file. The format is detected from the content, and only the conversions that fit it are offered:
- XML to JSON and JSON to XML, following the rules of SAP's own converters:
@namemembers are attributes,$is an element's text, and an array repeats its element. The options are the ones you set in the iFlow: Add XML Root Element, Suppress JSON Root Element and the elements always written as arrays. - CSV to JSON or XML and back, with the separator detected or chosen, a header row, and the name of the row element.
- YAML to JSON and JSON to YAML.
- XML to an inferred XSD, and an XSD to a sample XML.
- Pretty print and minify for XML and JSON.
- Base64 and URL encode and decode; escape and unescape for XML, JSON and Groovy strings.
Use as input puts the result back in the input box, so you can convert it again. Three more tabs sit next to Convert:
- Validate checks that the input is well-formed and lists each problem with its line and column. Give it an XSD and the XML's elements, their order and count, attributes and simple types are checked too. This is a light check: namespaces, imports, includes, substitution groups and keys are not checked.
- Find and replace, with JavaScript regular expressions and their groups.
- Batch converts several files the same way and downloads the results in one ZIP. A file that fails is left out and listed.
Test payload generator
Error handling is the part of an iFlow that is tested least, because nobody has the broken messages. The generator makes them from one real sample.
- Paste or upload one real message: XML, JSON, or CSV with a header row.
- Check the table of fields. Each field's type is guessed from its value: text, integer, decimal, boolean, date, date and time, e-mail, currency, country, UUID or null.
- Choose a rule for each field: Keep the sample's value, Random of the same type, a Sequence, or Pick from a list of values.
- Set how many payloads to make (up to 1,000) and the share that gets a fault.
- Choose the kinds of fault and click Generate.
The faults are the ones receivers reject: a missing mandatory field, an empty field, a wrong type, an invalid date, e-mail, currency or country, a negative quantity, a wrong namespace, broken XML, JSON or CSV, a duplicate ID, an extra field and a null value. Each faulty payload gets one fault.
The same sample, rules and seed always give the same payloads, so a test can be run again with the same data. Download ZIP gives one file per payload plus a manifest.json that lists each file's fault and the field it changed. Download as one file writes JSON Lines, or XML and CSV separated by a blank line. Save as data set for the Runner hands the set to the HTTP Runner, which can send each payload to your iFlow and show which answers came back as expected.
Groovy snippets and the cheat sheet
The Snippets tab holds 32 Groovy patterns for Cloud Integration scripts. Each is written to go inside processData(Message message), with class names in full so no import is needed. They cover reading and setting the body, headers and exchange properties, streaming a large body, XmlSlurper, XmlParser and MarkupBuilder, safe XML parsing against XXE, JsonSlurper and JsonBuilder, values searchable in monitoring, attachments in the message log, failing with a clear error, the HTTP error in an exception subprocess, Secure Store credentials, Value Mapping and Partner Directory lookups.
Search them by name or tag. With a script open in edit mode in the designer, Insert types the snippet at the cursor; otherwise copy it. Add your own keeps up to 20 snippets of yours, synced with your Kitegra account when you are signed in. Do not put passwords or keys in them.
The Cheat sheet tab lists what you look up every week: the Simple operators, Java date patterns with examples, XPath 1.0 functions run on a sample XML, and links to SAP's and Apache Camel's documentation. Click any example to copy it. The expressions themselves are explained in Camel Simple expressions in SAP CPI.
To read the scripts an iFlow already has, use Explain scripts in iFlow Docs. For each script it lists its purpose, what it reads, what it sets or changes, its main logic, the SAP APIs it uses, and its risks.
HTTP Runner
The HTTP Runner calls your iFlow's HTTPS endpoints with OAuth from a Process Integration Runtime service key, keeps requests in collections, and checks the answers. In iFlow info, each endpoint copies as cURL or opens in the Runner. The whole walk-through is in testing an HTTPS iFlow with a service key.
What it keeps, and what your plan includes
Compare, the converter, the generator and the cheat sheet run in the page and keep nothing. Your own snippets, and the HTTP Runner's collections without auth values or secret variables, sync with your Kitegra account when you are signed in.
The offline tools are on every plan. The HTTP Runner has limited use on Free and Starter, and all of it on Pro and the team plans. While Kitegra launches, every tool is open to everyone signed in, on the Free plan too. Compare the plans.
Try it in your next iFlow
Read what Kitegra adds around the SAP Integration Suite designer, or see everything the Toolbox does.
Frequently asked questions
Are my payloads sent anywhere?
No. Compare, the converter, the generator and the cheat sheet run in the browser page. What you paste or load is not stored or sent.
Does the converter give the same result as SAP's converters?
It follows the same rules and options as SAP's JSON to XML and XML to JSON converters: attributes, element text, arrays, the added root element and the suppressed JSON root. Run the iFlow when the result has to be exact.
Can I repeat a generated test set?
Yes. The same sample, rules and seed always give the same payloads. Changing the faults leaves the values as they were.
How do I insert a snippet into a Groovy script?
Open the script in edit mode in the designer, put the cursor where it goes, and click Insert on the snippet. Then save the iFlow yourself.
Does the Toolbox count iFlows?
No. Only the Helper, Message Monitor, iFlow Inspector and iFlow Docs count iFlows.