Package org.apache.axis2.context

Examples of org.apache.axis2.context.MessageContext.addAttachment()


        for (int i = 0; i < fileList.size(); i++) {
            OMElement file = fac.createOMElement("file" + (i + 1), omNs);
            file.addAttribute(fac.createOMAttribute("type", omNs,((File)fileList.get(i)).getName()));
            FileDataSource dataSource = new FileDataSource((File)fileList.get(i));
            dataHandler = new DataHandler(dataSource);
            String contentID = mc.addAttachment(dataHandler);

            file.setText(contentID);
            files.addChild(file);
        }
        SOAPBody body = fac.createSOAPBody(soapEnvelope);
View Full Code Here


    FileDataSource fileDataSource = new FileDataSource(file);

    // Create a dataHandler using the fileDataSource. Any implementation of
    // javax.activation.DataSource interface can fit here.
    DataHandler dataHandler = new DataHandler(fileDataSource);
    String attachmentID = mc.addAttachment(dataHandler);

    SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
    SOAPEnvelope env = fac.getDefaultEnvelope();
    OMNamespace omNs = fac.createOMNamespace(
        "http://service.soapwithattachments.sample", "swa");
View Full Code Here

        MessageContext mc = new MessageContext();
        mc.setEnvelope(createEnvelope());
        FileDataSource fileDataSource = new FileDataSource(TestingUtils.prefixBaseDirectory("test-resources/mtom/test.jpg"));
        DataHandler dataHandler = new DataHandler(fileDataSource);
        mc.addAttachment("FirstAttachment", dataHandler);

        mepClient.addMessageContext(mc);
        mepClient.execute(true);
        MessageContext response = mepClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
        DataHandler dataHandler2 = response.getAttachment("FirstAttachment");
View Full Code Here

        OMElement response = factory.createOMElement("response", ns);
        OMElement imageId  = factory.createOMElement("imageId", ns);

        FileDataSource fileDataSource = new FileDataSource(tempFile);
        dataHandler = new DataHandler(fileDataSource);
        imageContentId = outMsgCtx.addAttachment(dataHandler);
        imageId.setText(imageContentId);
        response.addChild(imageId);
        payload.addChild(response);

        return payload;
View Full Code Here

        MessageContext mc = new MessageContext();

        System.out.println("Sending file : " + fileName + " as SwA");
        FileDataSource fileDataSource = new FileDataSource(new File(fileName));
        DataHandler dataHandler = new DataHandler(fileDataSource);
        String attachmentID = mc.addAttachment(dataHandler);


        SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
        SOAPEnvelope env = factory.getDefaultEnvelope();
        OMNamespace ns = factory.createOMNamespace("http://services.samples/xsd", "m0");
View Full Code Here

        for (int i = 0; i < fileList.size(); i++) {
            OMElement file = fac.createOMElement("file" + (i + 1), omNs);
            file.addAttribute(fac.createOMAttribute("type", omNs,((File)fileList.get(i)).getName()));
            FileDataSource dataSource = new FileDataSource((File)fileList.get(i));
            dataHandler = new DataHandler(dataSource);
            String contentID = mc.addAttachment(dataHandler);

            file.setText(contentID);
            files.addChild(file);
        }
        SOAPBody body = fac.createSOAPBody(soapEnvelope);
View Full Code Here

    FileDataSource fileDataSource = new FileDataSource(file);

    // Create a dataHandler using the fileDataSource. Any implementation of
    // javax.activation.DataSource interface can fit here.
    DataHandler dataHandler = new DataHandler(fileDataSource);
    String attachmentID = mc.addAttachment(dataHandler);

    SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
    SOAPEnvelope env = fac.getDefaultEnvelope();
    OMNamespace omNs = fac.createOMNamespace(
        "http://service.soapwithattachments.sample/xsd", "swa");
View Full Code Here

        MessageContext mc = new MessageContext();
        mc.setEnvelope(createEnvelope());
        FileDataSource fileDataSource = new FileDataSource(TestingUtils.prefixBaseDirectory("test-resources/mtom/test.jpg"));
        DataHandler dataHandler = new DataHandler(fileDataSource);
        mc.addAttachment("FirstAttachment", dataHandler);

        mepClient.addMessageContext(mc);
        mepClient.execute(true);
        MessageContext response = mepClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
        DataHandler dataHandler2 = response.getAttachment("FirstAttachment");
View Full Code Here

        MessageContext msgCtxOut = operationContext.getMessageContext(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);

        FileDataSource fileDataSource = new FileDataSource(name);
        DataHandler dataHandler = new DataHandler(fileDataSource);

        String contentID = "cid:" + msgCtxOut.addAttachment(dataHandler);

        OMFactory factory = OMAbstractFactory.getOMFactory();
        OMNamespace omNs = factory.createOMNamespace(namespace, "swa");
        OMElement wrapperElement = factory.createOMElement("downloadFileResponse", omNs);
        OMElement dataElement = factory.createOMElement("data", omNs, wrapperElement);
View Full Code Here

    FileDataSource fileDataSource = new FileDataSource(file);

    // Create a dataHandler using the fileDataSource. Any implementation of
    // javax.activation.DataSource interface can fit here.
    DataHandler dataHandler = new DataHandler(fileDataSource);
    String attachmentID = mc.addAttachment(dataHandler);

    SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
    SOAPEnvelope env = fac.getDefaultEnvelope();
    OMNamespace omNs = fac.createOMNamespace(
        "http://service.soapwithattachments.sample/xsd", "swa");
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.