Package org.apache.axiom.attachments

Examples of org.apache.axiom.attachments.ByteArrayDataSource


    private void performTestNewDataHandler(StandardTypesServiceClient serviceClient) throws IOException {
        DataHandler[] dha = new DataHandler[3];
        dha[0] = new DataHandler("Some data", "text/plain");
        dha[1] = new DataHandler(new URL("http://tuscany.apache.org/home.html"));
        dha[2] = new DataHandler(new ByteArrayDataSource("Some data2".getBytes()));

        for (int i = 0; i < dha.length; ++i) {
            DataHandler actual = serviceClient.getNewDataHandlerForward(dha[i]);
            // Note: The DataHandler returned may use a different type of DataSource.
            // Compare the data content instead of using equals().
View Full Code Here


    private void performTestNewDataHandlerArray(StandardTypesServiceClient serviceClient) throws IOException {
        DataHandler[] dha = new DataHandler[3];
        dha[0] = new DataHandler("Some data", "text/plain");
        dha[1] = new DataHandler(new URL("http://tuscany.apache.org/home.html"));
        dha[2] = new DataHandler(new ByteArrayDataSource("Some data2".getBytes()));

        DataHandler[] actual = serviceClient.getNewDataHandlerArrayForward(dha);
        Assert.assertEquals(dha.length, actual.length);
        for (int i = 0; i < dha.length; ++i) {
            // Note: The DataHandler returned may use a different type of DataSource.
View Full Code Here

                        BytesMessage bm = (BytesMessage) message;
                        byte[] msgBytes = new byte[(int) bm.getBodyLength()];
                        bm.reset();
                        bm.readBytes(msgBytes);
                        DataHandler dataHandler = new DataHandler(
                            new ByteArrayDataSource(msgBytes));
                        OMText textData = soapFactory.createOMText(dataHandler, true);
                        wrapper.addChild(textData);
                        msgContext.setDoingMTOM(true);
                    } else {
                        handleException("Unsupported JMS Message format : " + message.getJMSType());
View Full Code Here

   
    public JAXBProviderTests() {
        super();
        //Create a DataSource from a String
        String string = "Sending a JAXB generated string object to Source Provider endpoint";
        stringDS = new ByteArrayDataSource(string.getBytes(),"text/plain");

        try {
            //Create a DataSource from an image
            File file = new File(imageResourceDir + File.separator + "test.jpg");
            ImageInputStream fiis = new FileImageInputStream(file);
View Full Code Here

    public void testretByteArray() throws java.lang.Exception {


        byte[] input = new byte[]{(byte) 0xDE, (byte) 0xAD, (byte) 0xBE, (byte) 0xEF};
        ComplexDataTypesDocLitBareStub.RetByteArray req = new ComplexDataTypesDocLitBareStub.RetByteArray();
        req.setInByteArray(new DataHandler(new ByteArrayDataSource(input)));
        DataHandler ret = stub.retByteArray(req).get_return();
        byte[] bytes = IOUtils.getStreamAsByteArray(ret.getInputStream());
        assertTrue(Arrays.equals(bytes, input));
    }
View Full Code Here

     */
    public void testretByteArray() throws java.lang.Exception {


        byte[] input = new byte[]{(byte) 0xDE, (byte) 0xAD, (byte) 0xBE, (byte) 0xEF};
        DataHandler ret = stub.retByteArray(new DataHandler(new ByteArrayDataSource(input)));
        byte[] bytes = IOUtils.getStreamAsByteArray(ret.getInputStream());
        assertTrue(Arrays.equals(bytes, input));
    }
View Full Code Here

                Base64.encode(textTobeSent.getBytes()) +
                "</ns2:QualifiedElement></ns1:testElementText>";
        try {
            ArrayList properties = new ArrayList();
            properties.add(new QName("http://testQElementText.org", "QualifiedElement", "ns2"));
            properties.add(new DataHandler(new ByteArrayDataSource(textTobeSent.getBytes())));

            XMLStreamReader pullParser = new ADBXMLStreamReaderImpl(
                    new QName("http://testElementText.org", "testElementText", "ns1"),
                    properties.toArray(),
                    null);
View Full Code Here

        DataSource source = null;

        // Part two is attachment
        if (outputStream instanceof ByteArrayOutputStream) {
            source = new ByteArrayDataSource(((ByteArrayOutputStream) outputStream).toByteArray());
        }
        messageBodyPart = new MimeBase64BodyPart();
        messageBodyPart.setDataHandler(new DataHandler(source));
        messageBodyPart.setDisposition(Part.ATTACHMENT);
View Full Code Here

    public static javax.activation.DataHandler convertToBase64Binary(String s) {
        // reusing the byteArrayDataSource from the Axiom classes
        if ((s == null) || s.equals("")){
            return null;
        }
        ByteArrayDataSource byteArrayDataSource = new ByteArrayDataSource(
                Base64.decode(s)
        );
        return new DataHandler(byteArrayDataSource);
    }
View Full Code Here

    @Override
    protected XMLMessage prepareMessage() throws Exception {
        OMFactory factory = OMAbstractFactory.getOMFactory();
        OMElement payload = factory.createOMElement(new QName("root"));
        Attachments attachments = new Attachments();
        attachments.addDataHandler(contentID, new DataHandler(new ByteArrayDataSource(attachmentContent, "application/octet-stream")));
        return new XMLMessage(payload, XMLMessage.Type.SWA, attachments);
    }
View Full Code Here

TOP

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

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.