webMethods string lists, LOOPs and nulls

Imagine you are looping with a string list as output array (say, its name is output[]). If the loop happens to map nulls (and only nulls) to output[], then after the loop ends, output[] is presented as a document list containing null objects (and not as a string list).

But if the loop mapped even one non-null element, then output[] is properly represented as a string list. These two outcomes are contrasted below.

This behaviour means subsequent code that uses output[] becomes unreliable. For example, if subsequent code MAPs output[] to another string list, and then loops over the second list, that second loop will not kick in if the original output[] elements were all null.

Thank you for this - another great example.
There could be some complexity to change this as people may have coded around the original behaviour, but I agree - this looks a little odd and unusual!

Adding John Carter to this response!

1 Like