SOAPMessage message;
MimeHeaders mimeHeaders = new MimeHeaders();
FileInputStream fis = new FileInputStream(msgFile);
ObjectInputStream ois = new ObjectInputStream(
new FileInputStream(mimeHdrsFile));
Hashtable hashTable = (Hashtable) ois.readObject();
ois.close();
if(hashTable.isEmpty()) {
// System.out.println("MimeHeaders Hashtable is empty");
} else {
for(int i=0; i < hashTable.size(); i++) {
Enumeration keys = hashTable.keys();
Enumeration values = hashTable.elements();
while (keys.hasMoreElements() && values.hasMoreElements()) {
String name = (String) keys.nextElement();
String value = (String) values.nextElement();
mimeHeaders.addHeader(name, value);
}
}
}
MessageFactory messageFactory = MessageFactory.newInstance();
message = messageFactory.createMessage(mimeHeaders, fis);
message.saveChanges();
return message;