Search code examples
cxfapache-cameljibx

Camel - Trying to marshall parameters with JIBX and send it to CXF-CAMEL endpoint


Basiaclly I've got the XML-d object to send, thanks to JIBX, I've got the WSDL endpoint. I just want to get the thing to that endpoint. it's proving extremely difficult for me.

I would like to use POJO mode because it looks much simpelr than the other modes doesn't involve messing with SOAP-Headers, and so on

POJO mode seems to invoke JAXB by default but I'd like to use JIBX - since the projects I'm interfacing with are already JIBX annotated and

I would like to either swap the POJO automatic JAXB-ing with my JIBX or just let me do the marshalling myself (which I can do successfully) and pass on my xml message

from( "A" )
  .marshall().jibx() // works fine, and gives byte[] of marshalled object in In.body
  .process() {
      exchange.getIn().setHeader( CxfConstants.OPERATION_NAME, OPERATION);    
   }
   .to("cxf://SERVICE"
     + "?serviceClass=SERVICE_CLASS"
     + "&wsdlURL=SERVICE?wsdl"
     + "&dataFormat=POJO" );

It then tries to invoke Jaxb on the messagebody and dies.

I've tried wrapping byte[] as a String, and wrapping in a List and sending with dataformat=MESSAGE but I can't seem to get what I'm trying to do


Solution

  • user1958722,

    I would recommend taking a look at some of the examples on the JiBX web site and in my blog at blog.tourgeek.com

    JiBX has a dataconnector that is included with CXF. This means that all you have to do is specify the jibx dataconnector in your spring bean.xml file and JiBX automatically does the marshaling/unmarshaling.

    Athough CXF is a great tool for SOAP servers, I've found it is a bit difficult to use for SOAP clients. You can save yourself a bunch of time by using the JiBX client library. It's very lightweight, because it uses the javax.xml.ws.soap package to package your message in a SOAP container.

    I would suggest reading my post on creating a SOAP client and taking a look at some of the sample client code in our repository.

    The JiBX schema library has some great web service client and server examples.

    If you are dealing with a public message set, please consider donating your binding to the JiBX schema library.

    I hope this helps!

    Don