I have a String which contains multiple repeating xml nodes. For Eg:
PurchaseOrderabc…
PurchaseOrderabc…
I wrote a java service which splits the String into indivdual messages into an ArrayList and put it to the pipeline. When I try to loop through the ArrayList (which I assume is an object list), it does not even enter the loop. However, if put the Arraylist elements into a String array, it works fine.
But to put the messages inside a string list, I will need to go through an extra loop in the java service as a String array in java is static while an ArrayList can grow dynamically and I do not know before hand how many xml nodes are present.
This could have performance issues when the volumes are high. Is there a way I can avoid this extra loop by looping through an object list in WM.
i have attached an image of my WM Developer instance.
If using Java is not a mandate here then I would suggest you to go with wM itself if it is just to split the xml nodes and extract data.
Since the XML string looks like a straight forward and a well formed XML, the built-in services to convert XML String to Document would do the spliting for you and give you each node as a document element in a documentList(txml). Then you can extract/map out the required values as you wish under a loop.
Actually the xml is not well formed. If you save the below string as an xml file and open it in a browser, it will be unable to display it. The individual tXML nodes by themselves are well formed. See below log message…
That’s the reason i want to split them into individual xmls and post them to the App Server via the IS.
2010-04-23 09:37:47 EDT [ISP.0090.0004I] Manh.Utils.Ftp.Services:processFtpJob – translated message - PO = <?xml version="1.0" encoding="UTF-8"?>
It is actually a well formed XML but with more than one top level element. Once you receive this XML data in IS you can easily solve this by enclosing the XML inside a temporary top level element. Just check the attached file, I ve done it by adding a tempHead, now it will open in a browser as well as get converted to IS doc by using built-in the services. wmusers_sjalis.xml (3.58 KB)
Well-formed XML documents can contain only one top level element. A good rule of thumb is to always make the source of bad XML do the fix. Of course that isn’t always practical but I often see bizarre code put into place to address poor XML from partners–and the partners were never notified/asked to fix what they were doing wrong.
Usually, if you’re working with XML and you find you need to/want to resort to using Java for some reason, then the XML is probably malformed.
It worked! Thanks a lot. One last question. Are java services generally considered heavy as opposed to using flow services in WM. Particularly in this context where I was doing a lot of string manipulations in my java service. How would i compare these two approaches in terms of performance.