Hello Guys
I have the follow code (match the colors yourself for a better understanding)
The code work , in my Main class I haveCode:@Component public class Cliente { private static final long serialVersionUID = 1L; private String nombres; private String apellidos; private Integer edad; private Double peso; private BigDecimal credito; private Date fechaNacimiento; public Cliente(){ } ... setters/getters and toString() } @Bean public CastorMarshaller castorMarshaller(){ return new CastorMarshaller(); } <int-xml:marshalling-transformer marshaller="castorMarshaller" result-type="StringResult" input-channel="input" output-channel="xml" /> <int-xml:unmarshalling-transformer unmarshaller="castorMarshaller" input-channel="xml-string" output-channel="output" /> <int:object-to-string-transformer input-channel="xml" output-channel="xml-string" /> ... <int:channel id="xml"> <int:interceptors> <int:wire-tap channel="logger01"/> </int:interceptors> </int:channel>
I can confirm through the logging-channel-adapter and wire-tap the follow ( I am changing the presentation to let show the output friendly)Code:MessageChannel input = context.getBean("input", MessageChannel.class ); PollableChannel output = context.getBean("output", PollableChannel.class ); Cliente cliente = new Cliente(); cliente.setNombres("Manuel"); cliente.setApellidos("Jordan"); cliente.setEdad(30); cliente.setPeso(70.01); cliente.setCredito(new BigDecimal("150.85")); cliente.setFechaNacimiento( new Date()); Message<?> messageAltern01 = MessageBuilder.withPayload(cliente).build(); input.send(messageAltern01); Message<?> replyAltern01 = output.receive(); logger.info("Mensaje Recibido replyAltern01.toString(){}", replyAltern01.toString());
Therefore the transformation is well doneCode:2011-07-11 12:19:30,329 INFO [org.springframework.integration.handler.LoggingHandler] - <[Payload=<?xml version="1.0" encoding="UTF-8"?> <cliente> <apellidos>Jordan</apellidos> <fecha-nacimiento>2011-07-11T12:19:29.923-05:00</fecha-nacimiento><nombres>Manuel</nombres> <peso>70.01</peso> <edad>30</edad> <credito>150.85</credito> </cliente>] [Headers={timestamp=1310404770329, id=4c20555b-0e1b-4292-bdd9-4baa3d99e449}]>
The problem is if I change only one line
DOMResult is the default used by Spring IntegrationCode:<int-xml:marshalling-transformer marshaller="castorMarshaller" result-type="DOMResult" input-channel="input" output-channel="xml" />
I get this output error ( I am changing the presentation to let show the output friendly)
What is wrong or missing on my Configuration?, it could be this be a bug?Code:... 2011-07-11 12:28:34,563 INFO [org.springframework.integration.handler.LoggingHandler] - <[Payload=javax.xml.transform.dom.DOMResult@179953c] [Headers={timestamp=1310405314563, id=87444587-14d3-41a8-b15b-439d6e44f1c8}]> 2011-07-11 12:28:34,563 INFO [org.springframework.integration.handler.LoggingHandler] - <[Payload=javax.xml.transform.dom.DOMResult@179953c] [Headers={timestamp=1310405314563, id=d5fae7c1-42a8-4022-8d59-c658e8f87cf3}]> Exception in thread "main" org.springframework.integration.transformer.MessageTransformationException: failed to transform message at org.springframework.integration.transformer.AbstractTransformer.transform(AbstractTransformer.java:44) ... Caused by: org.springframework.oxm.UnmarshallingFailureException: Castor unmarshalling exception; nested exception is org.exolab.castor.xml.MarshalException: Content is not allowed in prolog.{File: [not available]; line: 1; column: 1} at org.springframework.oxm.castor.CastorMarshaller.convertCastorException(CastorMarshaller.java:487) ... Caused by: org.exolab.castor.xml.MarshalException: Content is not allowed in prolog.{File: [not available]; line: 1; column: 1} at org.exolab.castor.xml.Unmarshaller.convertSAXExceptionToMarshalException(Unmarshaller.java:761) ... Caused by: org.xml.sax.SAXParseException: Content is not allowed in prolog. at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
Bear in mind I just changed StringResult to DOMResult
Thanks in advanced


Reply With Quote
