*/
public void prepare(final Message message) throws IOException
{
// save in a separate place in case we need to resend the request
final ByteArrayOutputStream cache = new ByteArrayOutputStream();
final DelegatingOutputStream delegating = new DelegatingOutputStream(cache);
message.setContent(OutputStream.class, delegating);
message.setContent(DelegatingOutputStream.class, delegating);
OutputHandler handler = new OutputHandler()
{
public void write(MuleEvent event, OutputStream out) throws IOException
{
out.write(cache.toByteArray());
delegating.setOutputStream(out);
// resume writing!
message.getInterceptorChain().doIntercept(message);
}
};