Not sure if it is something before this - but it would definitely choke on the EXIT ‘$loop’ if this is all your flow does (since there is no loop in the code you have written here). Choose EXIT ‘$parent’.
Now if all this is nested in a loop, that’s different, but then you’ll need to give a larger code sample.
in your sample XML I notice that first sample has “OrderItemList” as an array but in the second sample it isn’t, am i right on that ? If this is the case then try to populate “documentTypeName” input in your xmlNodeToDocument service.