title: Marshalling of java object to XML in Preprocessor phase of Mirth?
body: <p>Mirth is receiving java object from ActiveMQ JMS Topic.I have set source connector inbound data type to <strong>Delimited Text</strong> in Mirth Channel and Connector Type is <strong>JMS Reader</strong>. Now in <code>preprocessor</code> phase i want to marshal this java object into XML.I have put logger like this </p>
  
  <pre><code>logger.info("incoming data "+message);
  </code></pre>
  
  <p>And it is printing <strong>OrderDetails@240aaf81</strong></p>
  
  <p>Now i am calling custom java class for marshaling java object into XML.But this incoming message is converted to String by Mirth.Code in preprocessor script looks like this :</p>
  
  <pre><code>// Modify the message variable below to pre process data
  logger.info("incoming data "+message);
  var object = new Packages.coms.controller.JAXBMarshalling();
  object.marshallJavaObjectToXml(message);
  return message;
  </code></pre>
  
  <p>While passing incoming message to method it is showing error that method does not exist because method expects custom java object as method parameter,but it going as String.
  Method looks like this:</p>
  
  <pre><code>public  void marshallJavaObjectToXml(OrderDetails orderDetails) {
          JAXBContext jaxbContext;
          try {
              File file = new File(
                      "C:\\Program Files (x86)\\Mirth Connect\\conf\\xml\\xmlrepresentation.xml");
              jaxbContext = JAXBContext.newInstance(OrderDetails.class);
              Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
              // output pretty printed
              jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
              jaxbMarshaller.marshal(orderDetails, file);
              jaxbMarshaller.marshal(orderDetails, System.out);
          } catch (JAXBException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
      }
  </code></pre>
  
  <p>Class which object is passed looks like this:</p>
  
  <pre><code> @XmlRootElement
      public class OrderDetails implements Serializable{
  
          private static final long serialVersionUID = -4617153110762983450L;
          private Long mrn;
          private Long orderNo;
          private Long patientId;
          private Long orderId;**strong text**
          private Long encounterId;
      }
  </code></pre>
  
  <p>I have created jar file with these two classes and put in <strong>custom-lib</strong> folder of Mirth.How can i get the actual java object in <code>preprocessor</code> script of Mirth?
  I am using Mirth version 2.2.1.5861</p>