What product/components do you use and which version/fix level?
webMethods - IS 10.5
Are you using a free trial or a product with a customer license?
A customer license.
What are trying to achieve? Please describe in detail.
Good afternoon.
I’m getting a payload from an endpoint and converting it using jsonStreamToDocument but sometimes that payload arrives empty, which is a normal behavior.
There’s a way to find if an input or an output from the buit-in-service jsonStreamToDocument is null or empty?
What I want to do is put some kind of validation to see if I’m getting an empty IData object or right after the HTTP request check if the JSON Body is empty or with null values so I can stop the flow immediately and stop the iteration over an empty ArrayList.
I would like to have Something like this, but for the empty payload.
It is possible?
Thank you.
Do you get any error messages? Please provide a full error message screenshot and log file.
Branch does have two modes of operation distinguished by the “Evaluate Labels” property:
When “Evaluate Labels” is set to false you can branch over a specified field with fixed values as a label for each option (as shown above in the screenshot.
When “Evaluate Labels” is set to true there is no dedicated field specified at the branch step itself, but you can write complex conditions at the labels of each step. It is possible to use logical operators here to combine several conditions for one step.
In your case this would result in a condition like this:
data != $null && data != ""
Or you can check the length of the array and when it is 0, you exit the flow.
Strictly speaking, it is okay to LOOP over ‘data’ when it is null/empty – the LOOP won’t do anything. If the LOOP is the main chunk of your FLOW service, then the service will simply exit after doing nothing.
But if you want to know if the list has at least one entry you can do this (as an alternative to list size suggestion from @Holger_von_Thomsen):
BRANCH on ‘/pendingContractDetailsArrayList[0]/processToken’
…/\S/: SEQUENCE (list has at least one entry; the /\S/ is a regex indicating “anything other than null/whitespace”)
…$default: SEQUENCE (no entries)
No need to use “Evaluate Labels” in this case. Indeed, my guidance is to try whenever possible to avoid using “Evaluate Labels”. Not for any technical reason but for (minor) readability – Using “Evaluate Labels” forces one to expand the branch just to see what is being checked.