axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eric johnson <>
Subject axis2 mtom attach document to response - help please
Date Mon, 21 May 2012 20:10:35 GMT

I'm having some trouble adding an attachment to my response after
attempting to follow the instructions here:

The example from that url I am following is:

        OMElement imageElement = fac.createOMElement("image", omNs);

        // Creating the Data Handler for the file.  Any implementation of
        // javax.activation.DataSource interface can fit here.
        javax.activation.DataHandler dataHandler = new
javax.activation.DataHandler(new FileDataSource("SomeFile"));

        //create an OMText node with the above DataHandler and set
optimized to true
        OMText textData = fac.createOMText(dataHandler, true);


I suspect I am making a mistake in the creation of OMElement and
OMNameSpace in my code below.

      OMFactory factory = OMAbstractFactory.getOMFactory();
      OMNamespace omNs = factory.createOMNamespace("I put the
targetNamespace from the wsdl here", "ns");
      OMElement documentElement = factory.createOMElement("document", omNs);
      OMText textData = factory.createOMText(documentDataHandler, true);


So what should I be using for the URI and prefix values?  (I realize
this is probably web services 101, but this is all new to me and a bit

The document element is really part of a GetDocumentResponse type
defined in my wsdl as:
      <xs:element name="GetDocumentResponse"
type="tns:GetDocumentResponseType" />

      <xs:complexType name="GetDocumentResponseType">
          <xs:element name="mimeType" type="xs:string" minOccurs="1"
          <xs:element name="documentName" type="xs:string"
minOccurs="1" maxOccurs="1"/>
          <xs:element name="storageTimestamp" type="tns:sDateTime"
minOccurs="1" maxOccurs="1"/>
          <xs:element name="document" type="xs:base64Binary"
minOccurs="1" maxOccurs="1"/>

should I use "tns:GetDocumentResponse" for the prefix when creating
the OMNamespace object?

Should I be using the soap:address from the wsdl:service/wsdl:port as the uri?

Is there anything besides the code example I need to do to complete
the addition of the attachment?



To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message