if (outboundProperty) {
MessageFactory factory = MessageFactory.newInstance();
MimeHeaders mhs = null;
//Safe to do this cast as SOAPHandlerInterceptor has explictly
//replaced OutputStream with AbstractCachedOutputStream.
AbstractCachedOutputStream out = (AbstractCachedOutputStream)getWrappedMessage()
.getContent(OutputStream.class);
InputStream is = out.getInputStream();
message = factory.createMessage(mhs, is);
} else {
CachedStream cs = new CachedStream();
XMLStreamWriter writer = StaxUtils.getXMLOutputFactory().createXMLStreamWriter(cs);
XMLStreamReader xmlReader = getWrappedMessage().getContent(XMLStreamReader.class);