You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by "Talkov, Roger" <Ro...@automic.com> on 2015/08/05 06:16:04 UTC

MTOM attachments

Hi,

I'm trying to send an MTOM attachment to an axis2 sample service that will copy the attachment data to a file.
I can see the data being sent in the Logging Interceptor and the file gets created, but has zero bytes.

Code below:
   Map<String, Object> requestContext = client.getRequestContext ()
        Collection<Attachment> attachments = new ArrayList<Attachment>();
       AttachmentImpl attach = new AttachmentImpl("attachment-1");
       attachments.add(attach);
       attach.setDataHandler(new DataHandler(new FileDataSource ('C:/tmp/keyfile.old')))
       requestContext.put(Message.ATTACHMENTS, attachments);
       requestContext.put(Message.MTOM_ENABLED,"true")

Logging output:
08/04/15 21:13:40.869 mtom1_21: LoggingOutInterceptorCXF: Outbound Message
---------------------------
ID: 1
Address: http://localhost:8080/axis2/services/MTOMSample
Encoding: UTF-8
Http-Method: POST
Content-Type: multipart/related; type="application/xop+xml"; boundary="uuid:cfabac6e-c84c-4303-b6b7-e9d3e35461f9"; start="<ro...@cxf.apache.org>"; start-info="application/soap+xml"; action="attachment"
Headers: {Accept=[*/*]}
Payload: --uuid:cfabac6e-c84c-4303-b6b7-e9d3e35461f9
Content-Type: application/xop+xml; charset=UTF-8; type="application/soap+xml"; action="attachment"
Content-Transfer-Encoding: binary
Content-ID: <ro...@cxf.apache.org>

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"><soap:Body><ns2:AttachmentRequest xmlns:xmime="http://www.w3.org/2005/05/xmlmime" xmlns:ns2="http://ws.apache.org/axis2/mtomsample/"><ns2:fileName>c:/tmp/attach2.txt</ns2:fileName><ns2:binaryData xmime:contentType="text/plain"></ns2:binaryData></ns2:AttachmentRequest></soap:Body></soap:Envelope>
--uuid:cfabac6e-c84c-4303-b6b7-e9d3e35461f9
Content-Type: application/octet-stream
Content-Transfer-Encoding: binary
Content-ID: <attachment-1>

##Do not Change this file##
Custno=999
Company=UC4 Software Demonstration
SAP=01-06-2009x01-06-2010x999
PSE=01-06-2009x01-06-2010x999
OAE=01-06-2009x01-06-2010x999
OAE-C=01-06-2009x01-06-2010x999
APPMASTER=01-06-2009x01-06-2010x999
EXPLORER+=01-06-2009x01-06-2010x999
AGENT=01-06-2009x01-06-2010x999
RME=01-06-2009x01-06-2010x999
JMS=01-06-2009x01-06-2010x999
APPWORX_WEBSERVICES=01-06-2009x01-06-2010x999
EXTERNAL_WEBSERVICES=01-06-2009x01-06-2010x999
ZOS=01-06-2009x01-06-2010x999
RA=01-06-2009x01-06-2010x999
RA_BUILDER=01-06-2009x01-06-2010x999
TESTAGENT=01-06-2009x01-06-2010x999
BANNERAGENT=01-06-2009x01-06-2010x999
FTPAGENT=01-06-2009x01-06-2010x999
VMWAREAGENT=01-06-2009x01-06-2010x999

--uuid:cfabac6e-c84c-4303-b6b7-e9d3e35461f9--
--------------------------------------
08/04/15 21:13:40.879 mtom1_21: LoggingInInterceptorCXF: Inbound Message
----------------------------
ID: 1
Response-Code: 200
Encoding: UTF-8
Content-Type: application/soap+xml; charset=UTF-8; action="http://schemas.xmlsoap.org/wsdl/MTOMServicePortType/AttachmentResponse"
Headers: {connection=[keep-alive], content-type=[application/soap+xml; charset=UTF-8; action="http://schemas.xmlsoap.org/wsdl/MTOMServicePortType/AttachmentResponse"], Date=[Wed, 05 Aug 2015 04:13:40 GMT], Server=[Simple-Server/1.1], transfer-encoding=[chunked]}
Payload: <soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
  <soapenv:Body>
    <ns2:AttachmentResponse xmlns:ns2="http://ws.apache.org/axis2/mtomsample/">File saved succesfully.</ns2:AttachmentResponse>
  </soapenv:Body>
</soapenv:Envelope>


Roger
This email (including any attachments) may contain information which is privileged, confidential, or protected. If you are not the intended recipient, note that any disclosure, copying, distribution, or use of the contents of this message and attached files is prohibited. If you have received this email in error, please notify the sender and delete this email and any attached files.

RE: MTOM attachments

Posted by "Talkov, Roger" <Ro...@automic.com>.
Hi Aki,

For MTOM what I needed to do was find the DataHandler field in the Request Object, and set the DataHandler, then MTOM worked fine

Roger

-----Original Message-----
From: Aki Yoshida [mailto:elakito@gmail.com]
Sent: Monday, August 17, 2015 6:36 AM
To: users@cxf.apache.org
Subject: Re: MTOM attachments

Have you compared the message sent by your CXF client to the expected message or the message that is actually sent from the corresponding sample client code? Without knowing what this sample server does or expects, it's difficult to say what is went wrong.


2015-08-05 6:16 GMT+02:00 Talkov, Roger <Ro...@automic.com>:
> Hi,
>
> I'm trying to send an MTOM attachment to an axis2 sample service that will copy the attachment data to a file.
> I can see the data being sent in the Logging Interceptor and the file gets created, but has zero bytes.
>
> Code below:
>    Map<String, Object> requestContext = client.getRequestContext ()
>         Collection<Attachment> attachments = new ArrayList<Attachment>();
>        AttachmentImpl attach = new AttachmentImpl("attachment-1");
>        attachments.add(attach);
>        attach.setDataHandler(new DataHandler(new FileDataSource ('C:/tmp/keyfile.old')))
>        requestContext.put(Message.ATTACHMENTS, attachments);
>        requestContext.put(Message.MTOM_ENABLED,"true")
>
> Logging output:
> 08/04/15 21:13:40.869 mtom1_21: LoggingOutInterceptorCXF: Outbound
> Message
> ---------------------------
> ID: 1
> Address: http://localhost:8080/axis2/services/MTOMSample
> Encoding: UTF-8
> Http-Method: POST
> Content-Type: multipart/related; type="application/xop+xml"; boundary="uuid:cfabac6e-c84c-4303-b6b7-e9d3e35461f9"; start="<ro...@cxf.apache.org>"; start-info="application/soap+xml"; action="attachment"
> Headers: {Accept=[*/*]}
> Payload: --uuid:cfabac6e-c84c-4303-b6b7-e9d3e35461f9
> Content-Type: application/xop+xml; charset=UTF-8; type="application/soap+xml"; action="attachment"
> Content-Transfer-Encoding: binary
> Content-ID: <ro...@cxf.apache.org>
>
> <soap:Envelope
> xmlns:soap="http://www.w3.org/2003/05/soap-envelope"><soap:Body><ns2:A
> ttachmentRequest xmlns:xmime="http://www.w3.org/2005/05/xmlmime"
> xmlns:ns2="http://ws.apache.org/axis2/mtomsample/"><ns2:fileName>c:/tm
> p/attach2.txt</ns2:fileName><ns2:binaryData
> xmime:contentType="text/plain"></ns2:binaryData></ns2:AttachmentReques
> t></soap:Body></soap:Envelope>
> --uuid:cfabac6e-c84c-4303-b6b7-e9d3e35461f9
> Content-Type: application/octet-stream
> Content-Transfer-Encoding: binary
> Content-ID: <attachment-1>
>
> ##Do not Change this file##
> Custno=999
> Company=UC4 Software Demonstration
> SAP=01-06-2009x01-06-2010x999
> PSE=01-06-2009x01-06-2010x999
> OAE=01-06-2009x01-06-2010x999
> OAE-C=01-06-2009x01-06-2010x999
> APPMASTER=01-06-2009x01-06-2010x999
> EXPLORER+=01-06-2009x01-06-2010x999
> AGENT=01-06-2009x01-06-2010x999
> RME=01-06-2009x01-06-2010x999
> JMS=01-06-2009x01-06-2010x999
> APPWORX_WEBSERVICES=01-06-2009x01-06-2010x999
> EXTERNAL_WEBSERVICES=01-06-2009x01-06-2010x999
> ZOS=01-06-2009x01-06-2010x999
> RA=01-06-2009x01-06-2010x999
> RA_BUILDER=01-06-2009x01-06-2010x999
> TESTAGENT=01-06-2009x01-06-2010x999
> BANNERAGENT=01-06-2009x01-06-2010x999
> FTPAGENT=01-06-2009x01-06-2010x999
> VMWAREAGENT=01-06-2009x01-06-2010x999
>
> --uuid:cfabac6e-c84c-4303-b6b7-e9d3e35461f9--
> --------------------------------------
> 08/04/15 21:13:40.879 mtom1_21: LoggingInInterceptorCXF: Inbound
> Message
> ----------------------------
> ID: 1
> Response-Code: 200
> Encoding: UTF-8
> Content-Type: application/soap+xml; charset=UTF-8; action="http://schemas.xmlsoap.org/wsdl/MTOMServicePortType/AttachmentResponse"
> Headers: {connection=[keep-alive], content-type=[application/soap+xml;
> charset=UTF-8;
> action="http://schemas.xmlsoap.org/wsdl/MTOMServicePortType/Attachment
> Response"], Date=[Wed, 05 Aug 2015 04:13:40 GMT],
> Server=[Simple-Server/1.1], transfer-encoding=[chunked]}
> Payload: <soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
>   <soapenv:Body>
>     <ns2:AttachmentResponse xmlns:ns2="http://ws.apache.org/axis2/mtomsample/">File saved succesfully.</ns2:AttachmentResponse>
>   </soapenv:Body>
> </soapenv:Envelope>
>
>
> Roger
> This email (including any attachments) may contain information which is privileged, confidential, or protected. If you are not the intended recipient, note that any disclosure, copying, distribution, or use of the contents of this message and attached files is prohibited. If you have received this email in error, please notify the sender and delete this email and any attached files.
This email (including any attachments) may contain information which is privileged, confidential, or protected. If you are not the intended recipient, note that any disclosure, copying, distribution, or use of the contents of this message and attached files is prohibited. If you have received this email in error, please notify the sender and delete this email and any attached files.

Re: MTOM attachments

Posted by Aki Yoshida <el...@gmail.com>.
Have you compared the message sent by your CXF client to the expected
message or the message that is actually sent from the corresponding
sample client code? Without knowing what this sample server does or
expects, it's difficult to say what is went wrong.


2015-08-05 6:16 GMT+02:00 Talkov, Roger <Ro...@automic.com>:
> Hi,
>
> I'm trying to send an MTOM attachment to an axis2 sample service that will copy the attachment data to a file.
> I can see the data being sent in the Logging Interceptor and the file gets created, but has zero bytes.
>
> Code below:
>    Map<String, Object> requestContext = client.getRequestContext ()
>         Collection<Attachment> attachments = new ArrayList<Attachment>();
>        AttachmentImpl attach = new AttachmentImpl("attachment-1");
>        attachments.add(attach);
>        attach.setDataHandler(new DataHandler(new FileDataSource ('C:/tmp/keyfile.old')))
>        requestContext.put(Message.ATTACHMENTS, attachments);
>        requestContext.put(Message.MTOM_ENABLED,"true")
>
> Logging output:
> 08/04/15 21:13:40.869 mtom1_21: LoggingOutInterceptorCXF: Outbound Message
> ---------------------------
> ID: 1
> Address: http://localhost:8080/axis2/services/MTOMSample
> Encoding: UTF-8
> Http-Method: POST
> Content-Type: multipart/related; type="application/xop+xml"; boundary="uuid:cfabac6e-c84c-4303-b6b7-e9d3e35461f9"; start="<ro...@cxf.apache.org>"; start-info="application/soap+xml"; action="attachment"
> Headers: {Accept=[*/*]}
> Payload: --uuid:cfabac6e-c84c-4303-b6b7-e9d3e35461f9
> Content-Type: application/xop+xml; charset=UTF-8; type="application/soap+xml"; action="attachment"
> Content-Transfer-Encoding: binary
> Content-ID: <ro...@cxf.apache.org>
>
> <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"><soap:Body><ns2:AttachmentRequest xmlns:xmime="http://www.w3.org/2005/05/xmlmime" xmlns:ns2="http://ws.apache.org/axis2/mtomsample/"><ns2:fileName>c:/tmp/attach2.txt</ns2:fileName><ns2:binaryData xmime:contentType="text/plain"></ns2:binaryData></ns2:AttachmentRequest></soap:Body></soap:Envelope>
> --uuid:cfabac6e-c84c-4303-b6b7-e9d3e35461f9
> Content-Type: application/octet-stream
> Content-Transfer-Encoding: binary
> Content-ID: <attachment-1>
>
> ##Do not Change this file##
> Custno=999
> Company=UC4 Software Demonstration
> SAP=01-06-2009x01-06-2010x999
> PSE=01-06-2009x01-06-2010x999
> OAE=01-06-2009x01-06-2010x999
> OAE-C=01-06-2009x01-06-2010x999
> APPMASTER=01-06-2009x01-06-2010x999
> EXPLORER+=01-06-2009x01-06-2010x999
> AGENT=01-06-2009x01-06-2010x999
> RME=01-06-2009x01-06-2010x999
> JMS=01-06-2009x01-06-2010x999
> APPWORX_WEBSERVICES=01-06-2009x01-06-2010x999
> EXTERNAL_WEBSERVICES=01-06-2009x01-06-2010x999
> ZOS=01-06-2009x01-06-2010x999
> RA=01-06-2009x01-06-2010x999
> RA_BUILDER=01-06-2009x01-06-2010x999
> TESTAGENT=01-06-2009x01-06-2010x999
> BANNERAGENT=01-06-2009x01-06-2010x999
> FTPAGENT=01-06-2009x01-06-2010x999
> VMWAREAGENT=01-06-2009x01-06-2010x999
>
> --uuid:cfabac6e-c84c-4303-b6b7-e9d3e35461f9--
> --------------------------------------
> 08/04/15 21:13:40.879 mtom1_21: LoggingInInterceptorCXF: Inbound Message
> ----------------------------
> ID: 1
> Response-Code: 200
> Encoding: UTF-8
> Content-Type: application/soap+xml; charset=UTF-8; action="http://schemas.xmlsoap.org/wsdl/MTOMServicePortType/AttachmentResponse"
> Headers: {connection=[keep-alive], content-type=[application/soap+xml; charset=UTF-8; action="http://schemas.xmlsoap.org/wsdl/MTOMServicePortType/AttachmentResponse"], Date=[Wed, 05 Aug 2015 04:13:40 GMT], Server=[Simple-Server/1.1], transfer-encoding=[chunked]}
> Payload: <soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
>   <soapenv:Body>
>     <ns2:AttachmentResponse xmlns:ns2="http://ws.apache.org/axis2/mtomsample/">File saved succesfully.</ns2:AttachmentResponse>
>   </soapenv:Body>
> </soapenv:Envelope>
>
>
> Roger
> This email (including any attachments) may contain information which is privileged, confidential, or protected. If you are not the intended recipient, note that any disclosure, copying, distribution, or use of the contents of this message and attached files is prohibited. If you have received this email in error, please notify the sender and delete this email and any attached files.