Hi,
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.
My java service is as below:
IDataCursor pipelineCursor = pipeline.getCursor();
try
{
String xmlString = IDataUtil.getString( pipelineCursor, “translatedMessage” );
logInfo("xmlString = " + xmlString);
ArrayList xmlList = new ArrayList();
String splitXml = “”;
do{
splitXml = xmlString.substring(xmlString.indexOf(“”),xmlString.indexOf(“”)+7);
xmlList.add(splitXml);
logInfo(“splitXml = " + splitXml);
xmlString = xmlString.substring(xmlString.indexOf(”")+1,xmlString.length());
}while (splitXml.length()<= xmlString.length());
int poCount = xmlList.size();
logInfo("poCount = "+poCount);
String xmlStringList = new String[poCount];
int i=0;
Iterator iter = xmlList.iterator();
while (iter.hasNext()){
xmlStringList[i]= (String)iter.next();
logInfo(“\n\ntXML=”+xmlStringList[i]);
i++;
}
//debugging end
IDataUtil.put( pipelineCursor, “xmlList”, xmlStringList);
//IDataUtil.put( pipelineCursor, “xmlList”, xmlList);
}catch (Exception e){
logInfo("error message = "+e.getMessage());
}
finally{
pipelineCursor.destroy();
}
I am a java developer and new to Web Methods. Any help would be appreciated. Thanks
sjalis

#Flow-and-Java-services#webMethods#Integration-Server-and-ESB