Examples of OMOutputFormat


Examples of org.apache.axiom.om.OMOutputFormat

            forceExpand();
            return super.toString();
        } else {
            try {
                StringWriter writer = new StringWriter();
                OMOutputFormat format = new OMOutputFormat();
                dataSource.serialize(writer, format);
                String text = writer.toString();
                writer.close();
                return text;
            } catch (XMLStreamException e) {
View Full Code Here

Examples of org.apache.axiom.om.OMOutputFormat

     * @param log Log
     * @param limit limit of message to write
     * @return length of entire message
     */
    public static long logDebug(OMElement om, Log log, int limit) {
        OMOutputFormat format = new OMOutputFormat();
        format.setDoOptimize(true);
        format.setIgnoreXMLDeclaration(true);
        return logDebug(om, log, limit, format);
    }
View Full Code Here

Examples of org.apache.axiom.om.OMOutputFormat

    @Override
    public void writeTo(OutputStream outputStream) throws IOException {
        try {

            OMOutputFormat outputFormat = getOutputFormat();
            if (outputStream instanceof TransportOutputStream) {
                TransportOutputStream transportOutputStream = (TransportOutputStream) outputStream;
                String contentType = outputFormat.getContentType();
                if (!(outputFormat.isDoingSWA() || outputFormat.isOptimized())) {
                    String charsetEncoding = axiomMessage.getCharsetEncoding();
                    contentType += "; charset=" + charsetEncoding;
                }
                SoapVersion version = getVersion();
                if (SoapVersion.SOAP_11 == version) {
                    transportOutputStream.addHeader(TransportConstants.HEADER_SOAP_ACTION, soapAction);
                    transportOutputStream.addHeader(TransportConstants.HEADER_ACCEPT, version.getContentType());
                }
                else if (SoapVersion.SOAP_12 == version) {
                    contentType += "; action=" + soapAction;
                    transportOutputStream.addHeader(TransportConstants.HEADER_ACCEPT, version.getContentType());
                }
                transportOutputStream.addHeader(TransportConstants.HEADER_CONTENT_TYPE, contentType);

            }
            if (!(outputFormat.isOptimized()) & outputFormat.isDoingSWA()) {
                writeSwAMessage(outputStream, outputFormat);
            }
            else {
                if (payloadCaching) {
                    axiomMessage.serialize(outputStream, outputFormat);
View Full Code Here

Examples of org.apache.axiom.om.OMOutputFormat

            return outputFormat;
        }
        else {
            String charsetEncoding = axiomMessage.getCharsetEncoding();

            OMOutputFormat outputFormat = new OMOutputFormat();
            outputFormat.setCharSetEncoding(charsetEncoding);
            outputFormat.setSOAP11(getVersion() == SoapVersion.SOAP_11);
            if (isXopPackage()) {
                outputFormat.setDoOptimize(true);
            }
            else if (!attachments.getContentIDSet().isEmpty()) {
                outputFormat.setDoingSWA(true);
            }
            return outputFormat;
        }
    }
View Full Code Here

Examples of org.apache.axiom.om.OMOutputFormat

     * @return id of the send mail message
     */
    private String sendMail(MailOutTransportInfo outInfo, MessageContext msgContext)
        throws AxisFault, MessagingException, IOException {

        OMOutputFormat format = BaseUtils.getOMOutputFormat(msgContext);
        // Make sure that non textual attachements are sent with base64 transfer encoding
        // instead of binary.
        format.setProperty(OMOutputFormat.USE_CTE_BASE64_FOR_NON_TEXTUAL_ATTACHMENTS, true);
       
        MessageFormatter messageFormatter = BaseUtils.getMessageFormatter(msgContext);

        if (log.isDebugEnabled()) {
            log.debug("Creating MIME message using message formatter " +
View Full Code Here

Examples of org.apache.axiom.om.OMOutputFormat

    @Test
    public void testWithXOP() throws Exception {
        DataHandler dh = new DataHandler(new RandomDataSource(10000));
        MemoryBlob blob = new MemoryBlob();
        OutputStream out = blob.getOutputStream();
        OMOutputFormat format = new OMOutputFormat();
        format.setDoOptimize(true);
        createTestDocument(dh).serialize(out, format);
        out.close();
        Attachments attachments = new Attachments(blob.getInputStream(), format.getContentType());
        test(dh, new XOPAwareStAXOMBuilder(attachments.getRootPartInputStream(), attachments), false, true, true);
    }
View Full Code Here

Examples of org.apache.axiom.om.OMOutputFormat

       
        attachments.getRootPartInputStream();

        String[] contentIDs = attachments.getAllContentIDs();
       
        OMOutputFormat oof = new OMOutputFormat();
        oof.setDoOptimize(true);
        oof.setMimeBoundary(testMessage.getBoundary());
        oof.setRootContentId(testMessage.getStart());
       
        // Write out the message
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        MTOMXMLStreamWriter writer = new MTOMXMLStreamWriter(baos, oof);
       
        OMXMLParserWrapper builder =
            OMXMLBuilderFactory.createOMBuilder(StAXParserConfiguration.DEFAULT, attachments);
        OMElement om = builder.getDocumentElement();
        om.serialize(writer);
        om.close(false);
        String outNormal = baos.toString();
       
        assertTrue(outNormal.indexOf("base64") == -1);
       
        // Now do it again but use base64 content-type-encoding for
        // binary attachments
        baos = new ByteArrayOutputStream();
        oof.setProperty(OMOutputFormat.USE_CTE_BASE64_FOR_NON_TEXTUAL_ATTACHMENTS,
                        Boolean.TRUE);
        writer = new MTOMXMLStreamWriter(baos, oof);
        builder =
            OMXMLBuilderFactory.createOMBuilder(StAXParserConfiguration.DEFAULT, attachments);
        om = builder.getDocumentElement();
        om.serialize(writer);
        om.close(false);
        String outBase64 = baos.toString();
       
       
        // Do a quick check to see if the data is base64 and is
        // writing base64 compliant code.
        assertTrue(outBase64.indexOf("base64") != -1);
        assertTrue(outBase64.indexOf("GBgcGBQgHBwcJCQgKDBQNDAsL") != -1);
       
        // Now read the data back in
        InputStream is = new ByteArrayInputStream(outBase64.getBytes());
        Attachments attachments2 = new Attachments(is, testMessage.getContentType());
       
        // Now write it back out with binary...
        baos = new ByteArrayOutputStream();
        oof.setProperty(OMOutputFormat.USE_CTE_BASE64_FOR_NON_TEXTUAL_ATTACHMENTS,
                        Boolean.FALSE);
        writer = new MTOMXMLStreamWriter(baos, oof);
        builder =
            OMXMLBuilderFactory.createOMBuilder(StAXParserConfiguration.DEFAULT, attachments2);
        om = builder.getDocumentElement();
        om.serialize(writer);
        om.close(false);
        String outBase64ToNormal = baos.toString();
       
        assertTrue(outBase64ToNormal.indexOf("base64") == -1);
       
        // Now do it again but use base64 content-type-encoding for
        // binary attachments
        is = new ByteArrayInputStream(outBase64.getBytes());
        attachments2 = new Attachments(is, testMessage.getContentType());
        baos = new ByteArrayOutputStream();
        oof.setProperty(OMOutputFormat.USE_CTE_BASE64_FOR_NON_TEXTUAL_ATTACHMENTS,
                        Boolean.TRUE);
        writer = new MTOMXMLStreamWriter(baos, oof);
        builder =
            OMXMLBuilderFactory.createOMBuilder(StAXParserConfiguration.DEFAULT, attachments2);
        om = builder.getDocumentElement();
View Full Code Here

Examples of org.apache.axiom.om.OMOutputFormat

        OMElement root = builder.getDocumentElement();
        StringWriter xmlWriter = new StringWriter();
        root.serialize(xmlWriter);
       
        // Serialize the message using the legacy behavior (order by content id)
        OMOutputFormat format = new OMOutputFormat();
        format.setCharSetEncoding("utf-8");
        format.setDoingSWA(true);
       
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
       
        MIMEOutputUtils.writeSOAPWithAttachmentsMessage(xmlWriter, baos, attachments, format);
       
View Full Code Here

Examples of org.apache.axiom.om.OMOutputFormat

        URLConnection connection = serviceURL.openConnection();
        connection.setDoOutput(true);
        connection.addRequestProperty("Content-Type", "text/xml; charset=UTF-8");
        OutputStream out = connection.getOutputStream();
        // Send the request
        OMOutputFormat format = new OMOutputFormat();
        format.setCharSetEncoding("UTF-8");
        request.serialize(out, format);
        out.close();
       
        // Get the SOAP response
        InputStream in = connection.getInputStream();
View Full Code Here

Examples of org.apache.axiom.om.OMOutputFormat

    protected void runTest() throws Throwable {
        String encoding = "iso-8859-15";
        SOAPEnvelope orgEnvelope = soapFactory.getDefaultEnvelope();
        soapFactory.createOMElement("echo", soapFactory.createOMNamespace("urn:test", null)).setText("test");
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        OMOutputFormat format = new OMOutputFormat();
        format.setCharSetEncoding(encoding);
        orgEnvelope.serialize(baos, format);
        SOAPMessage message = (SOAPMessage)OMXMLBuilderFactory.createSOAPModelBuilder(metaFactory,
                new ByteArrayInputStream(baos.toByteArray()), encoding).getDocument();
        assertEquals(encoding, message.getCharsetEncoding());
    }
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.