Package org.apache.axis2.om

Examples of org.apache.axis2.om.OMOutputFormat


     *
     * @param output
     * @throws XMLStreamException
     */
    public void serialize(OutputStream output) throws XMLStreamException {
        OMOutputImpl omOutput = new OMOutputImpl(output, new OMOutputFormat());
        serialize(omOutput);
        omOutput.flush();
    }
View Full Code Here


            outputMessage = envelope.getBody().getFirstElement();
        }

        if (outputMessage != null) {
            try {
                OMOutputFormat format = new OMOutputFormat();

                // Pick the char set encoding from the msgContext
                String charSetEnc =
                        (String) msgContext.getProperty(MessageContext.CHARACTER_SET_ENCODING);

                format.setDoOptimize(msgContext.isDoingMTOM());
                format.setCharSetEncoding(charSetEnc);
                outputMessage.serializeAndConsume(out, format);
                out.flush();
            } catch (Exception e) {
                throw new AxisFault(e);
            }
View Full Code Here

            outputMessage = envelope.getBody().getFirstElement();
        }

        if (outputMessage != null) {
            try {
                OMOutputFormat format = new OMOutputFormat();

                // Pick the char set encoding from the msgContext
                String charSetEnc =
                        (String) msgContext.getProperty(MessageContext.CHARACTER_SET_ENCODING);

                format.setDoOptimize(msgContext.isDoingMTOM());
                format.setCharSetEncoding(charSetEnc);
                outputMessage.serializeAndConsume(out, format);
                out.flush();
            } catch (Exception e) {
                throw new AxisFault(e);
            }
View Full Code Here

            throw new AxisFault(Messages.getMessage("outMessageNull"));
        }
    }

    public String getContentType(MessageContext msgCtx) {
        OMOutputFormat format = new OMOutputFormat();
        String soapActionString = getSOAPAction(msgCtx);
        String charSetEnc =
                (String) msgCtx.getProperty(MessageContext.CHARACTER_SET_ENCODING);

        if (charSetEnc != null) {
            format.setCharSetEncoding(charSetEnc);
        } else {
            OperationContext opctx = msgCtx.getOperationContext();

            if (opctx != null) {
                charSetEnc = (String) opctx.getProperty(MessageContext.CHARACTER_SET_ENCODING);
            }
        }

        /**
         * If the char set enc is still not found use the default
         */
        if (charSetEnc == null) {
            charSetEnc = MessageContext.DEFAULT_CHAR_SET_ENCODING;
        }

        format.setSOAP11(msgCtx.isSOAP11());
        format.setCharSetEncoding(charSetEnc);

        String encoding = format.getCharSetEncoding();
        String contentType = format.getContentType();

        if (encoding != null) {
            contentType += "; charset=" + encoding;
        }

View Full Code Here

        public byte[] writeBytes() throws AxisFault {
            try {
                ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();

                if (!doingMTOM) {
                    OMOutputFormat format2 = new OMOutputFormat();

                    format2.setCharSetEncoding(charSetEnc);
                    element.serializeAndConsume(bytesOut, format2);

                    return bytesOut.toByteArray();
                } else {
                    format.setCharSetEncoding(charSetEnc);
View Full Code Here

    }


    public void invoke(MessageContext msgContext) throws AxisFault {
        try {
            OMOutputFormat format = new OMOutputFormat();
            String charSetEnc =
                    (String) msgContext
                            .getProperty(MessageContext.CHARACTER_SET_ENCODING);

            if (charSetEnc != null) {
                format.setCharSetEncoding(charSetEnc);
            } else {
                OperationContext opctx = msgContext.getOperationContext();

                if (opctx != null) {
                    charSetEnc = (String) opctx
                            .getProperty(MessageContext.CHARACTER_SET_ENCODING);
                }
            }

            /**
             * If the char set enc is still not found use the default
             */
            if (charSetEnc == null) {
                charSetEnc = MessageContext.DEFAULT_CHAR_SET_ENCODING;
            }

            msgContext.setDoingMTOM(HTTPTransportUtils.doWriteMTOM(msgContext));
            msgContext.setDoingREST(HTTPTransportUtils.isDoingREST(msgContext));
            format.setSOAP11(msgContext.isSOAP11());
            format.setDoOptimize(msgContext.isDoingMTOM());
            format.setCharSetEncoding(charSetEnc);

            // Trasnport URL can be different from the WSA-To. So processing
            // that now.
            EndpointReference epr = null;
            String transportURL =
                    (String) msgContext
                            .getProperty(MessageContextConstants.TRANSPORT_URL);

            if (transportURL != null) {
                epr = new EndpointReference(transportURL);
            } else if ((msgContext.getTo() != null)
                    && !AddressingConstants.Submission.WSA_ANONYMOUS_URL
                    .equals(msgContext.getTo().getAddress()) &&
                    !AddressingConstants.Final
                            .WSA_ANONYMOUS_URL
                            .equals(msgContext.getTo().getAddress())) {
                epr = msgContext.getTo();
            }

            // Check for the REST behaviour, if you desire rest beahaviour
            // put a <parameter name="doREST" value="true"/> at the
            // server.xml/client.xml file
            // ######################################################
            // Change this place to change the wsa:toepr
            // epr = something
            // ######################################################
            OMElement dataOut;

            /**
             * Figuringout the REST properties/parameters
             */
            if (msgContext.isDoingREST()) {
                dataOut = msgContext.getEnvelope().getBody().getFirstElement();
            } else {
                dataOut = msgContext.getEnvelope();
            }

            if (epr != null) {
                writeMessageWithCommons(msgContext, epr, dataOut, format);
            } else {
                OutputStream out =
                        (OutputStream) msgContext
                                .getProperty(MessageContext.TRANSPORT_OUT);

                if (msgContext.isServerSide()) {
                    OutTransportInfo transportInfo =
                            (OutTransportInfo) msgContext
                                    .getProperty(Constants.OUT_TRANSPORT_INFO);

                    if (transportInfo != null) {
                        boolean soap11 = msgContext.isSOAP11();

                        format.setSOAP11(soap11);

                        String contentType = format.getContentType();
                        String encoding = contentType + "; charset="
                                + format.getCharSetEncoding();

                        transportInfo.setContentType(encoding);
                    } else {
                        throw new AxisFault(Constants.OUT_TRANSPORT_INFO +
                                " has not been set");
                    }
                }

                format.setDoOptimize(msgContext.isDoingMTOM());
                dataOut.serializeAndConsume(out, format);
            }

            if (msgContext.getOperationContext() != null) {
                msgContext.getOperationContext()
View Full Code Here

        public byte[] writeBytes() throws AxisFault {
            try {
                ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();

                if (!doingMTOM) {
                    OMOutputFormat format2 = new OMOutputFormat();

                    format2.setCharSetEncoding(charSetEnc);
                    element.serializeAndConsume(bytesOut, format2);

                    return bytesOut.toByteArray();
                } else {
                    format.setCharSetEncoding(charSetEnc);
View Full Code Here

        public byte[] writeBytes() throws AxisFault {
            try {
                ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();

                if (!doingMTOM) {
                    OMOutputFormat format2 = new OMOutputFormat();
                    format2.setCharSetEncoding(charSetEnc);
                    element.serializeAndConsume(bytesOut, format2);
                    return bytesOut.toByteArray();

                } else {
                    format.setCharSetEncoding(charSetEnc);
View Full Code Here

        assertTrue("XML Declaration missing",-1<xmlDocument.indexOf(xmlDeclStart));
    }

    public void testExcludeXMLDeclaration() throws XMLStreamException {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        OMOutputFormat format = new OMOutputFormat();
        format.setIgnoreXMLDeclaration(true);
        document.serializeAndConsume(baos, format);

        String xmlDocument = new String(baos.toByteArray());

        assertTrue(
View Full Code Here

                                                 -1 < xmlDocument.indexOf(encoding2));
    }

    public void testCharsetEncodingUTF_16() throws XMLStreamException, UnsupportedEncodingException {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        OMOutputFormat format = new OMOutputFormat();
        format.setCharSetEncoding("UTF-16");
        document.serializeAndConsume(baos, format);

        String xmlDocument = new String(baos.toByteArray(),"UTF-16");
        assertTrue("Charset declaration missing",-1<xmlDocument.indexOf(encoding_UTF16) ||
                                                 -1<xmlDocument.indexOf(encoding2_UTF16));
View Full Code Here

TOP

Related Classes of org.apache.axis2.om.OMOutputFormat

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.