0 Replies Latest reply on Nov 1, 2012 9:20 AM by jamie3_james.archibald

    JAXB + Part classes + ProducerTemplate problem?

    jamie3_james.archibald

      I have an WSDL which I used wsdl2java to produce the following data contract:

       

      class PositionReportList {

       

          List getPositionReports();

      }

       

      and service contract:

       

      interface PositionReportService {

       

         PositionReportList getPositionReports();

         void sendPositionReport(PositionReportType reportPosition);

      }

       

       

      The Web Service implementation is as follows. The service is deployed on ServiceMix using CXF and simply acts as proxy to activemq:

       

       

      class PositionReportServiceImpl {

       

         void sendPositionReport(PositionReportType reportPosition) {

            template.sendBody("activemq:topic:positionReport?jmsMessageType=TEXT", reportPosition);

         }

      }

       

      The problem with the above is that JAXB can't serialize the positionReportType and rather calls the toString() method.

       

      Normally in a camel route I would use the JAXBDataFormat class and set the PartClass such that It can serialize the object. For example:

       

      JAXBDataFormat dataFormat = ..

      dataFormat.setPartClass(..);

       

      from("direct:position")

      .marshal().jaxb(dataFormat).to("activemq:topic:positionReport")

       

      My only option right now is to take that camel route and stick it in my service, but ideally I dont want to do this and would rather somehow tell the producerTemplate or JMS component how to marshal the object.

       

      Is this possible?