Hello

I'm currently doing advanced experiences with CAMEL-CXF, namely MTOM support. It's working as a marvel, the only points to be careful on:

  1. The javax.xml dependency doesn't have MTOM classes and that you'll
     need to use the Geronimo packages
  2. It's the client that decides that it should send stuff in
     MTOM/XOP. You therefore need the MTOM-related annotations in your
     client Java interface (the one you give to CAMEL) if you want
     CAMEL-CXF to generate MTOM

You can see the whole stuff on svn://svn.forge.objectweb.org/svnroot/jonas/sandbox/camel-jonas5/trunk/camel-osgi-package but here's a code sample:

   Server side:

   this.from(
       "cxf://http://localhost:"; + CamelCxfMtomTest.port +
   CamelCxfMtomTest.cxfContext + "/"
           + IMTOMFileSender.WSNAME + "?serviceClass=" +
   IMTOMFileSender.class.getName() + "&dataFormat=POJO&"
           + "bus=#" + CamelCxfMtomTest.busName).process(new Processor() {
       public void process(final Exchange exchange) throws Exception {
           MessageContentsList msgListIn = (MessageContentsList)
   exchange.getIn().getBody();

           Assert.assertNotNull("Assert that the message has content",
   msgListIn);
           Assert.assertEquals("Assert message content size", 2,
   msgListIn.size());

           String inFile = (String) msgListIn.get(0);
           Assert.assertEquals(CamelCxfMtomTest.filename, inFile);
           exchange.getOut().setHeader(Exchange.FILE_NAME, inFile);

           byte[] inFileData = (byte[]) msgListIn.get(1);
           Assert.assertNotNull("Assert that the message's fileContents
   is filled", inFileData);
           exchange.getOut().setBody(inFileData);
       }
   }).to(CamelCxfMtomTest.output.toURL().toString()).process(new
   Processor() {
       public void process(final Exchange exchange) throws Exception {
           // The Web service has a null response type
           exchange.getOut().setBody(null);
       }
   });

   Client side:

   this.from(CamelCxfMtomTest.input.toURL().toString()).process(new
   Processor() {
       public void process(final Exchange exchange) throws Exception {
           GenericFile<?> msgList = (GenericFile<?>)
   exchange.getIn().getBody();

           exchange.getOut().setHeader(CxfConstants.OPERATION_NAME,
   "sendFile");
exchange.getOut().setHeader(CxfConstants.OPERATION_NAMESPACE,
   IMTOMFileSender.NAMESPACE);

           MessageContentsList msgListOut = new MessageContentsList();
           File outFile = new File(msgList.getAbsoluteFilePath());
           msgListOut.set(0, outFile.getName());
           byte[] outFileData =
   CamelCxfMtomTest.readFileAsByteArray(outFile);
           msgListOut.set(1, outFileData);
           exchange.getOut().setBody(msgListOut);
       }
   }).to(
       "cxf://http://localhost:"; + CamelCxfMtomTest.port +
   CamelCxfMtomTest.cxfContext + "/"
           + IMTOMFileSender.WSNAME + "?serviceClass=" +
   IMTOMFileSender.class.getName() + "&dataFormat=POJO&"
           + "bus=#" + CamelCxfMtomTest.busName);

   ... and the class:

   @BindingType(value = SOAPBinding.SOAP11HTTP_MTOM_BINDING)
   @WebService(name = IMTOMFileSender.WSNAME, targetNamespace =
   IMTOMFileSender.NAMESPACE)
   public interface IMTOMFileSender {

       public String NAMESPACE = "http://test.camel.jonas.ow2.org";;

       public String WSNAME = "MTOMFileSender";

       public String sendFile(String fileName, byte[] fileContents);
   }

Now, I have one small issue: when I send a WS message with that configuration, CAMEL sends out a lot of headers:

   POST /services/MTOMFileSender HTTP/1.1
   Content-Type: multipart/related; type="application/xop+xml";
   boundary="uuid:e9c7db1f-395c-459c-8639-9cea3463e8de";
   start="<root.mess...@cxf.apache.org>"; start-info="text/xml"
   *CamelFileNameOnly: someFile.txt
   CamelFileRelativePath:
   
C:\DOCUME~1\Owner\LOCALS~1\Temp\paxexam_runner_Owner\target\mtom-test\input\someFile.txt
   CamelFileLastModified: Sat Jun 20 19:33:41 CEST 2009
   CamelFileAbsolutePath:
   
C:\DOCUME~1\Owner\LOCALS~1\Temp\paxexam_runner_Owner\target\mtom-test\input\someFile.txt
   CamelFileName: someFile.txt
   CamelFileLength: 12
   CamelFilePath:
   
C:\DOCUME~1\Owner\LOCALS~1\Temp\paxexam_runner_Owner\target\mtom-test\input\someFile.txt
   CamelFileParent:
   C:\DOCUME~1\Owner\LOCALS~1\Temp\paxexam_runner_Owner\target\mtom-test\input*
   SOAPAction: ""
   CamelFileAbsolute: true
   Accept: */*
   User-Agent: Apache CXF 2.2.2
   Cache-Control: no-cache
   Pragma: no-cache
   Host: localhost:25742
   Connection: keep-alive
   Content-Length: 820


   --uuid:e9c7db1f-395c-459c-8639-9cea3463e8de
   Content-Type: application/xop+xml; charset=UTF-8; type="text/xml";
   Content-Transfer-Encoding: binary
   Content-ID: <root.mess...@cxf.apache.org>

   <soap:Envelope
   
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";><soap:Body><ns1:sendFile
   
xmlns:ns1="http://test.camel.jonas.ow2.org";><arg0>someFile.txt</arg0><arg1><xop:Include
   xmlns:xop="http://www.w3.org/2004/08/xop/include";
   
href="cid:76e00e28-e0fc-40c9-91e3-03627e8b3cec-1@http%3A%2F%2Fcxf.apache.org%2F"/></arg1></ns1:sendFile></soap:Body></soap:Envelope>
   --uuid:e9c7db1f-395c-459c-8639-9cea3463e8de
   Content-Type: application/octet-stream
   Content-Transfer-Encoding: binary
   Content-ID:
   <76e00e28-e0fc-40c9-91e3-03627e8b3ce...@http://cxf.apache.org/>

   Test Message
   --uuid:e9c7db1f-395c-459c-8639-9cea3463e8de--

How could I tell CAMEL-CXF not to send the file-related headers (marked in red)?

Thanks

--

S. Ali Tokmen
savas-ali.tok...@bull.net

Office: +33 4 76 29 76 19
GSM:    +33 66 43 00 555

Bull, Architect of an Open World TM
http://www.bull.com

Reply via email to