The response is actually not an MTOM message but a SwA message. Probably you have enabled both. In that case SwA takes precedence over MTOM because MTOM is simply an alternative serialization of an XML message while SwA is a different type of message. In addition, SwA doesn't allow the SOAP stack to automatically convert a base64Binary value to an attachment, and therefore the DataHandler is serialized as a base64Binary value. Avoid enabling SwA on that service and it should work.
Andreas On Thu, Nov 17, 2011 at 16:47, Bonitz Arndt <arndt.bon...@ait.ac.at> wrote: > Dear all, > > > > I am experiencing the following problem with an Axis2 service: Upon a > service request, my service should return a SOAP message with an MTOM > attachment. I enabled XOP in the Axis2 configuaration. All messages are > returned as XOP+MTOM responses, but the attachment is encoded as Base64 > string the SOAPEnvelope. The problem occurs with Axis2 v1.4 and 1.6. > > > > I use the following code in my service to attach the attachment : > > > > byte[] covRaw = getCoverage(); > > final javax.activation.DataHandler dataHandler = new > javax.activation.DataHandler(new ByteArrayDataSource(covRaw, > "application/coverage")); > > final OMText textData = covElement.getOMFactory().createOMText(dataHandler, > true); > > covElement.addChild(textData); > > > > Example response, the Base64 encoded string is located in the wcs:Coverage > element. > > > > HTTP/1.1 200 OK > > Server: Apache-Coyote/1.1 > > Content-Type: multipart/related; > boundary="MIMEBoundary_4a88a88323dbbaaffa1ad8f2065158013b50b42eba59be4b"; > type="text/xml"; > start="<0.5a88a88323dbbaaffa1ad8f2065158013b50b42eba59b...@apache.org>" > > Transfer-Encoding: chunked > > Date: Thu, 17 Nov 2011 15:37:28 GMT > > > > --MIMEBoundary_4a88a88323dbbaaffa1ad8f2065158013b50b42eba59be4b > > Content-Type: text/xml; charset=UTF-8 > > Content-Transfer-Encoding: binary > > Content-ID: <0.5a88a88323dbbaaffa1ad8f2065158013b50b42eba59b...@apache.org> > > > > <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> > > <soapenv:Body> > > <soapenv:Envelope> > > <soapenv:Body> > > <wcs:Coverage > xmlns:wcs="http://www.opengis.net/wcs/2.0">b50FyY5XveGeG1s5cG1LZWsdGVv1peGXdjcwpDs</wcs:Coverage> > > </soapenv:Body> > > </soapenv:Envelope> > > </soapenv:Body> > > </soapenv:Envelope> > > > > Any help would be greatly appreciated. > > > > Best regards, > > Arndt Bonitz --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscr...@axis.apache.org For additional commands, e-mail: java-user-h...@axis.apache.org