@Override @Nullable protected Object convertToInternal(Object payload, @Nullable MessageHeaders headers, @Nullable Object conversionHint) { Assert.notNull(this.marshaller, "Property 'marshaller' is required"); try { if (byte[].class == getSerializedPayloadClass()) { ByteArrayOutputStream out = new ByteArrayOutputStream(); Result result = new StreamResult(out); this.marshaller.marshal(payload, result); payload = out.toByteArray(); } else { Writer writer = new StringWriter(); Result result = new StreamResult(writer); this.marshaller.marshal(payload, result); payload = writer.toString(); } } catch (Throwable ex) { throw new MessageConversionException("Could not marshal XML: " + ex.getMessage(), ex); } return payload; }
@Override @Nullable protected Object convertToInternal(Object payload, @Nullable MessageHeaders headers, @Nullable Object conversionHint) { Assert.notNull(this.marshaller, "Property 'marshaller' is required"); try { if (byte[].class == getSerializedPayloadClass()) { ByteArrayOutputStream out = new ByteArrayOutputStream(); Result result = new StreamResult(out); this.marshaller.marshal(payload, result); payload = out.toByteArray(); } else { Writer writer = new StringWriter(); Result result = new StreamResult(writer); this.marshaller.marshal(payload, result); payload = writer.toString(); } } catch (Throwable ex) { throw new MessageConversionException("Could not marshal XML: " + ex.getMessage(), ex); } return payload; }
@Override @Nullable protected Object convertToInternal(Object payload, @Nullable MessageHeaders headers, @Nullable Object conversionHint) { Assert.notNull(this.marshaller, "Property 'marshaller' is required"); try { if (byte[].class == getSerializedPayloadClass()) { ByteArrayOutputStream out = new ByteArrayOutputStream(); Result result = new StreamResult(out); this.marshaller.marshal(payload, result); payload = out.toByteArray(); } else { Writer writer = new StringWriter(); Result result = new StreamResult(writer); this.marshaller.marshal(payload, result); payload = writer.toString(); } } catch (Throwable ex) { throw new MessageConversionException("Could not marshal XML: " + ex.getMessage(), ex); } return payload; }
@Override @Nullable protected Object convertToInternal(Object payload, @Nullable MessageHeaders headers, @Nullable Object conversionHint) { Assert.notNull(this.marshaller, "Property 'marshaller' is required"); try { if (byte[].class == getSerializedPayloadClass()) { ByteArrayOutputStream out = new ByteArrayOutputStream(); Result result = new StreamResult(out); this.marshaller.marshal(payload, result); payload = out.toByteArray(); } else { Writer writer = new StringWriter(); Result result = new StreamResult(writer); this.marshaller.marshal(payload, result); payload = writer.toString(); } } catch (Throwable ex) { throw new MessageConversionException("Could not marshal XML: " + ex.getMessage(), ex); } return payload; }