* @param toStream The output stream that will be written to.
*/
public void marshal(final Exchange exchange, final Object fromBody, final OutputStream toStream) throws Exception {
final ExecutionContext execContext = smooks.createExecutionContext();
final TypeConverter typeConverter = exchange.getContext().getTypeConverter();
final JavaSource source = typeConverter.mandatoryConvertTo(JavaSource.class, exchange, fromBody);
final StringResult stringResult = new StringResult();
smooks.filterSource(execContext, source, stringResult);
toStream.write(stringResult.getResult().getBytes(execContext.getContentEncoding()));
}