Package org.apache.axiom.attachments

Examples of org.apache.axiom.attachments.Attachments


        element.detach();
        return element;
    }

    public OMElement sendReceiveUsingSwA(OMElement element) throws Exception {
        Attachments attachment = (opcts.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE)).getAttachmentMap();
        opcts.getMessageContext(WSDLConstants.MESSAGE_LABEL_OUT_VALUE).setAttachmentMap(attachment);
        element.buildWithAttachments();
        element.detach();
        return element;
    }
View Full Code Here


public class EchoService2 {


    public OMElement mtomSample(OMElement element) throws Exception {

        Attachments attachments = null;
        attachments = (Attachments)MessageContext.getCurrentMessageContext()
                .getProperty(MTOMConstants.ATTACHMENTS);
        // Get image data
        IncomingAttachmentStreams streams = attachments.getIncomingAttachmentStreams();
        IncomingAttachmentInputStream stream = streams.getNextStream();

        byte[] data = IOUtils.getStreamAsByteArray(stream);

        //setting response
View Full Code Here

        if (contentID.substring(0, 3).equalsIgnoreCase("cid")) {
            contentID = contentID.substring(4);
        }

        MessageContext msgCtx = MessageContext.getCurrentMessageContext();
        Attachments attachment = (msgCtx).getAttachmentMap();

        DataHandler dataHandler = attachment.getDataHandler(contentID);
        OMText textNode = new OMTextImpl(dataHandler, omEle.getOMFactory());
        omEle.build();
        child.detach();
        omEle.addChild(textNode);
        return omEle;
View Full Code Here

    }

    public OMElement echoOMElement(OMElement omEle) throws AxisFault {
        OMElement child = (OMElement)omEle.getFirstOMChild();
        MessageContext msgCtx = MessageContext.getCurrentMessageContext();
        Attachments attachment = (msgCtx).getAttachmentMap();
        msgCtx.removeAttachment(attachment.getSOAPPartContentID());
        msgCtx.getOperationContext().getMessageContext(
                WSDLConstants.MESSAGE_LABEL_OUT_VALUE).setAttachmentMap(attachment);

        omEle.build();
        return omEle;
View Full Code Here

        InputStreamReader isReader = null;

        if (contentType.indexOf("multipart/related") == 0) {
            //This contains attachements
            try {
                Attachments attachments =
                        new Attachments(inputStream, fullContentTypeStr, false, "", "");
                modifiedInputStream = attachments.getSOAPPartInputStream();
                 isReader = new InputStreamReader(modifiedInputStream);
              

                String soapEnvelopeNamespaceURI =
                        BuilderUtil.getEnvelopeNamespace(fullContentTypeStr);

                String charSetEncoding =
                        BuilderUtil.getCharSetEncoding(attachments.getSOAPPartContentType());

                XMLStreamReader streamReader =
                        StAXUtils.createXMLStreamReader(BuilderUtil.getReader(
                                attachments.getSOAPPartInputStream(), charSetEncoding));

                SOAPFactory factory;
                if (SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(soapEnvelopeNamespaceURI)) {
                    factory = new SOAP11Factory();
                } else {
                    factory = new SOAP12Factory();
                }
                if (attachments.getAttachmentSpecType().equals(
                        MTOMConstants.MTOM_TYPE)) {
                    //Creates the MTOM specific MTOMStAXSOAPModelBuilder
                    builder = new MTOMStAXSOAPModelBuilder(streamReader,
                                                           factory,
                                                           attachments,
                                                           soapEnvelopeNamespaceURI);
                } else if (attachments.getAttachmentSpecType().equals(
                        MTOMConstants.SWA_TYPE)) {
                    builder = new StAXSOAPModelBuilder(streamReader,
                                                       factory,
                                                       soapEnvelopeNamespaceURI);
                } else if (attachments.getAttachmentSpecType().equals(
                        MTOMConstants.SWA_TYPE_12)) {
                    builder = new StAXSOAPModelBuilder(streamReader,
                                                       factory,
                                                       soapEnvelopeNamespaceURI);
                }
View Full Code Here

     */
    private static void makeXOPIncludeNodes(MessageContext msgContext, Message message) {
        // This destroys performance by forcing a double pass through the message.
        //If attachments are found on the MessageContext, then that means
        //the inbound message has more than just the normal XML payload
        Attachments as = (Attachments) msgContext.getProperty(MTOMConstants.ATTACHMENTS);
        if (as != null) {
            if (log.isDebugEnabled()) {
                log.debug("Found Axis MTOM Attachments");
            }
           
View Full Code Here

    }
   
    public void setMessageContext(MessageContext messageContext) {
        if (this.messageContext != messageContext) {
            // Copy attachments to the new map
            Attachments newMap = messageContext.getAxisMessageContext().getAttachmentMap();
            Attachments oldMap = attachments;
            for (String cid:oldMap.getAllContentIDs()) {
                DataHandler dh = oldMap.getDataHandler(cid);
                if (dh != null) {
                    newMap.addDataHandler(cid, dh);
                }
            }
            // If not MTOM and there are attachments, set SWA style
View Full Code Here

public class AttachmentService {

  public String uploadFile(String name, String attchmentID) throws IOException
  {
        MessageContext msgCtx = MessageContext.getCurrentMessageContext();
        Attachments attachment = msgCtx.getAttachmentMap();
        DataHandler dataHandler = attachment.getDataHandler(attchmentID);
        File file = new File(
        name);
    FileOutputStream fileOutputStream = new FileOutputStream(file);
    dataHandler.writeTo(fileOutputStream);
    fileOutputStream.flush();
View Full Code Here

     *
     * @return attachment
     */
    public Attachments getAttachmentMap() {
        if (attachments == null) {
            attachments = new Attachments();
        }
        return attachments;
    }
View Full Code Here

     *                    will be the content ID of the MIME part
     * @param dataHandler
     */
    public void addAttachment(String contentID, DataHandler dataHandler) {
        if (attachments == null) {
            attachments = new Attachments();
        }
        attachments.addDataHandler(contentID, dataHandler);
    }
View Full Code Here

TOP

Related Classes of org.apache.axiom.attachments.Attachments

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.