OMOutputFormat format = new OMOutputFormat();
String charSetEncoding = (String) mc.getProperty(Constants.Configuration.CHARACTER_SET_ENCODING);
charSetEncoding = (charSetEncoding == null) ? "UTF-8" : charSetEncoding;
format.setCharSetEncoding(charSetEncoding);
MTOMXMLStreamWriter writer = new MTOMXMLStreamWriter(baos, format);
msg.outputTo(writer, false);
writer.flush();
text = baos.toString(charSetEncoding);
} catch (Throwable t) {
if (log.isDebugEnabled()) {
log.debug("Cannot access message as string", t);