Hi, It is quite difficult to say what exactly wrong without your test case. Could you run the system test I referenced in last mail and try to find the difference between test and your code?
Regards, Andrei. From: Gumudavelli, Alekhya [mailto:[email protected]] Sent: Dienstag, 11. Februar 2014 12:54 To: Andrei Shakirin; [email protected] Subject: RE: Query on CXF dispatch client with MTOM Hi Andrei, I am doing exactly the way you are referring. The service is not able to recognize attachment. Below is my service method . It fails to process attachment as the parameter "attachinfo" does not hold the attachment we have sent. This works well if I manually insert <attachinfo> element by linking it with content-id. public void testDataHandler(Holder<String> name, Holder<DataHandler> attachinfo) { if(attachinfo.value==null) {System.out.println("attachinfo.value is null"); //This gets executed return;} InputStream mtomIn = attachinfo.value.getInputStream(); ByteArrayOutputStream out = new ByteArrayOutputStream(); and so on.... Also, in the below line we can use any random name to set content id. Isn't it? att.setContentId("<[email protected]<mailto:[email protected]>>"); Could you please help me out with this issue Below is the screenshot of my request in TCP mon - [cid:[email protected]] Regards, Alekhya From: Andrei Shakirin [mailto:[email protected]] Sent: Monday, February 10, 2014 9:57 PM To: [email protected]<mailto:[email protected]> Cc: Gumudavelli, Alekhya Subject: RE: Query on CXF dispatch client with MTOM Hi, I do not think that you should add MTOM <include> manually. It should be enough to activate MTOM and add attachment part in following way: DataHandler dh1 = new DataHandler(new ByteArrayDataSource(bigBytes, "text/plain")); AttachmentPart att = msg.createAttachmentPart(dh1); att.setContentId("<[email protected]<mailto:[email protected]>>"); msg.addAttachmentPart(att); See the testSwaTypesWithDispatchAPI() in https://svn.apache.org/repos/asf/cxf/branches/2.7.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/swa/ClientServerSwaTest.java for details. Regards, Andrei. From: Gumudavelli, Alekhya [mailto:[email protected]] Sent: Montag, 10. Februar 2014 08:36 To: Andrei Shakirin Cc: [email protected]<mailto:[email protected]> Subject: Query on CXF dispatch client with MTOM Hi Andrei, team I am writing a CXF client with MTOM by using dynamic dispatch style of service invocation. I understand that dynamic dispatch requires request message to be constructed manually. But I would like to avoid manual insertion of <inc:include href> XOP element in the SOAP message to enable MTOM. I am currently doing the following steps to generate a CXF mtom client 1. Enable MTOM using ((SOAPBinding)binding).setMTOMEnabled(true); 2. Construct SOAP request message programmatically SOAPMessage request = MessageFactory.newInstance().createMessage(); //create attachment and add it to request AttachmentPart attach = request.createAttachmentPart(new DataHandler(new FileDataSource("F:\\CXF3\\CXF3\\src\\me.bmp"))); attach.setContentId("image"); request.addAttachmentPart(attach); SOAPElement operation = body.addChildElement("testDataHandler", "typ", "http://cxf.apache.org/mime/types"); /*Here, I am creating the SOAP body with appropriate nodes needed for MTOM - <inc:include href="image". . . */ SOAPElement value1 = operation.addChildElement("attachinfo", "tns","http://cxf.apache.org/mime/types"); SOAPElement xop = value1.addChildElement("Include","inc","http://www.w3.org/2004/08/xop/include"); xop.addAttribute(QName.valueOf("href"),"cid:image"); Generated request message : <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:typ="http://cxf.apache.org/mime/types"> <soapenv:Header xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"/> <soap:Body> <typ:testDataHandler> <tns:attachinfo xmlns:tns="http://cxf.apache.org/mime/types"><inc:Include xmlns:inc="http://www.w3.org/2004/08/xop/include" href="cid:image"/></tns:attachinfo> </typ:testDataHandler> </soap:Body> </soap:Envelope> The above request works well. However, manual inclusion of DOM elements like this does not appear clean and maintainable. Could you tell me how else can we achieve this to generate the request dynamically? I have the same issue with SWA CXF dispatch client where I am including <cid:image> node programmatically which I want to avoid. Thanks, Alekhya Gumudavelli
