The answer depends on the elementFormDefault declared on the schema. Andreas
On Mon, May 21, 2012 at 10:10 PM, eric johnson <ejjohn...@gmail.com> wrote: > Hi, > > I'm having some trouble adding an attachment to my response after > attempting to follow the instructions here: > http://axis.apache.org/axis2/java/core/docs/mtom-guide.html# > > 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); > > imageElement.addChild(textData); > > > 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); > > documentElement.addChild(textData); > > 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 > overwhelming). > > 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:sequence> > <xs:element name="mimeType" type="xs:string" minOccurs="1" > maxOccurs="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"/> > </xs:sequence> > </xs:complexType> > > 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? > > Thanks! > > Eric > > --------------------------------------------------------------------- > To unsubscribe, e-mail: java-user-unsubscr...@axis.apache.org > For additional commands, e-mail: java-user-h...@axis.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscr...@axis.apache.org For additional commands, e-mail: java-user-h...@axis.apache.org