I have never worked with XML and SOAP envelopes. I am trying to write a generic algorithm to read a flat file and to write the details into a SOAP like XML file. I was thinking of the following approach but want to know if there would be a better approach to do it.
Create a file containing the sample XML envelope with variables instead of the actual values
Create a properties file which contains a mapping between the variables and the index of the column (containing value for this variable) in the flat file.
Read the Flat file line by line in Java Code. Convert the line to an ArrayList based on the columns in the line
For each line, I read the sample XML envelope as defined in Step 1 above. I replace the variables in the XML string with the values from the arraylist based on the associated variable index.
Write the XML to a file.
I can write the xml file by javax.xml.soap.MessageFactory but that would make the mapping complex and would probably take more time to execute.
Any suggestions on the right approach to achieve this?