Package org.apache.axiom.om.impl.builder

Examples of org.apache.axiom.om.impl.builder.StAXBuilder


        }
    }

    public static StAXBuilder getBuilder(SOAPFactory soapFactory, InputStream in, String charSetEnc)
            throws XMLStreamException {
        StAXBuilder builder;
        XMLStreamReader xmlreader = StAXUtils.createXMLStreamReader(in, charSetEnc);
        builder = new StAXOMBuilder(soapFactory, xmlreader);
        return builder;
    }
View Full Code Here


        if (documentElement == null) {
            if (msgContext.isDoingREST()) {
                if (log.isDebugEnabled()) {
                    log.debug("Could not find a Builder for type (" + type + ").  Using REST.");
                }
                StAXBuilder builder = BuilderUtil.getPOXBuilder(inStream, null);
                documentElement = builder.getDocumentElement();
            } else {
                // FIXME making soap defualt for the moment..might effect the
                // performance
                if (log.isDebugEnabled()) {
                    log.debug("Could not find a Builder for type (" + type + ").  Using SOAP.");
                }
                String charSetEnc = (String) msgContext
                        .getProperty(Constants.Configuration.CHARACTER_SET_ENCODING);
                StAXBuilder builder = BuilderUtil.getSOAPBuilder(inStream, charSetEnc);
                documentElement = builder.getDocumentElement();
            }
        }
        return documentElement;
    }
View Full Code Here

            } else if (o instanceof String) {
                String soap = (String) o;
                try {
                    XMLStreamReader xmlReader =
                            StAXUtils.createXMLStreamReader(new ByteArrayInputStream(soap.getBytes()));
                    StAXBuilder builder = new StAXSOAPModelBuilder(xmlReader);
                    OMElement elem = builder.getDocumentElement();
                    elem.build();
                    if (elem instanceof SOAPEnvelope) {
                        SOAPEnvelope soapEnvelope = (SOAPEnvelope) elem;
                        String soapNamespace = soapEnvelope.getNamespace().getNamespaceURI();
                        if (soapEnvelope.getHeader() == null) {
View Full Code Here

    private void closeStaxBuilder(MessageContext messageContext) throws ServletException {
        if (closeReader && messageContext != null) {
            try {
                SOAPEnvelope envelope = messageContext.getEnvelope();
                if(envelope != null) {
                    StAXBuilder builder = (StAXBuilder) envelope.getBuilder();
                    if (builder != null) {
                        builder.close();
                    }
                }
            } catch (Exception e) {
                log.debug(e.toString(), e);
            }
View Full Code Here

    public static SOAPEnvelope getSOAPEnvelope(
            Message message, MessageContext msgContext, InputStream in)
            throws XMLStreamException {

        SOAPEnvelope envelope = null;
        StAXBuilder builder = null;
        String contentType = JMSUtils.getProperty(message, JMSConstants.CONTENT_TYPE);

        if (contentType != null) {
            if (contentType.indexOf(
                    HTTPConstants.HEADER_ACCEPT_MULTIPART_RELATED) > -1) {
                builder = BuilderUtil.getAttachmentsBuilder(
                        msgContext, in, contentType, true);
                envelope = (SOAPEnvelope) builder.getDocumentElement();
            } else {
                String charSetEnc = BuilderUtil.getCharSetEncoding(contentType);
                builder = BuilderUtil.getSOAPBuilder(in, charSetEnc);

                // Set the encoding scheme in the message context
                msgContext.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING, charSetEnc);
                envelope = (SOAPEnvelope) builder.getDocumentElement();
            }
        }

        // handle pure plain vanilla POX and binary content (non SOAP)
        if (builder == null) {
            SOAPFactory soapFactory = new SOAP11Factory();
            try {
                XMLStreamReader xmlreader = StAXUtils.createXMLStreamReader
                    (in, MessageContext.DEFAULT_CHAR_SET_ENCODING);

                // Set the encoding scheme in the message context
                msgContext.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING,
                                       MessageContext.DEFAULT_CHAR_SET_ENCODING);
                builder = new StAXOMBuilder(xmlreader);
                builder.setOMBuilderFactory(soapFactory);

                String ns = builder.getDocumentElement().getNamespace().getNamespaceURI();
                if (SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(ns)) {
                    envelope = getEnvelope(in, SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
                } else if (SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(ns)) {
                    envelope = getEnvelope(in, SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
                } else {
                    // this is POX ... mark MC as REST
                    msgContext.setDoingREST(true);
                    envelope = soapFactory.getDefaultEnvelope();
                    envelope.getBody().addChild(builder.getDocumentElement());
                }
            } catch (Exception e) {
                log.debug("Non SOAP/XML JMS message received");

                Parameter operationParam = msgContext.getAxisService().
                    getParameter(JMSConstants.OPERATION_PARAM);
                QName operationQName = (operationParam != null ?
                    getQName(operationParam.getValue()) : JMSConstants.DEFAULT_OPERATION);

                AxisOperation operation = msgContext.getAxisService().getOperation(operationQName);
                if (operation != null) {
                    msgContext.setAxisOperation(operation);
                } else {
                    handleException("Cannot find operation : " + operationQName + " on the service "
                        + msgContext.getAxisService());
                }

                Parameter wrapperParam = msgContext.getAxisService().
                    getParameter(JMSConstants.WRAPPER_PARAM);
                QName wrapperQName = (wrapperParam != null ?
                    getQName(wrapperParam.getValue()) : JMSConstants.DEFAULT_WRAPPER);

                OMElement wrapper = soapFactory.createOMElement(wrapperQName, null);

                try {
                    if (message instanceof TextMessage) {
                        OMTextImpl textData = (OMTextImpl) soapFactory.createOMText(
                            ((TextMessage) message).getText());
                        wrapper.addChild(textData);
                    } else if (message instanceof BytesMessage) {
                        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());
                    }
                    envelope = soapFactory.getDefaultEnvelope();
                    envelope.getBody().addChild(wrapper);

                } catch (JMSException j) {
                    handleException("Error wrapping JMS message into a SOAP envelope ", j);
                }
            }
        }

        String charEncOfMessage = builder == null ? null :
            builder.getDocument() == null ? null : builder.getDocument().getCharsetEncoding();
        String charEncOfTransport = ((String) msgContext.getProperty(
                Constants.Configuration.CHARACTER_SET_ENCODING));

        if (charEncOfMessage != null &&
                !(charEncOfMessage.trim().length() == 0) &&
View Full Code Here

        } catch (IOException e) {
            throw new XMLStreamException("Error resetting message input stream", e);
        }
        XMLStreamReader xmlreader = StAXUtils.createXMLStreamReader
            (in, MessageContext.DEFAULT_CHAR_SET_ENCODING);
        StAXBuilder builder = new StAXSOAPModelBuilder(xmlreader, namespace);
        return (SOAPEnvelope) builder.getDocumentElement();
    }
View Full Code Here

        }
    }

    public static StAXBuilder getPOXBuilder(InputStream inStream, String charSetEnc)
            throws XMLStreamException {
        StAXBuilder builder;
        XMLStreamReader xmlreader =
                StAXUtils.createXMLStreamReader(inStream, charSetEnc);
        builder = new StAXOMBuilder(xmlreader);
        return builder;
    }
View Full Code Here

    public static StAXBuilder getAttachmentsBuilder(MessageContext msgContext,
                                                    InputStream inStream, String contentTypeString,
                                                    boolean isSOAP)
            throws OMException, XMLStreamException, FactoryConfigurationError {
        StAXBuilder builder = null;
        XMLStreamReader streamReader;

        Attachments attachments = createAttachmentsMap(msgContext, inStream, contentTypeString);
        String charSetEncoding = getCharSetEncoding(attachments.getSOAPPartContentType());
View Full Code Here

     * @throws XMLStreamException
     * @deprecated If some one really need this method, please shout.
     */
    public static StAXBuilder getBuilder(Reader in) throws XMLStreamException {
        XMLStreamReader xmlreader = StAXUtils.createXMLStreamReader(in);
        StAXBuilder builder = new StAXSOAPModelBuilder(xmlreader, null);
        return builder;
    }
View Full Code Here

     */
    public static StAXBuilder getBuilder(InputStream inStream, String charSetEnc)
            throws XMLStreamException {
        XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(inStream, charSetEnc);
        try {
            StAXBuilder builder =  new StAXSOAPModelBuilder(xmlReader);
            return builder;
        } catch (OMException e){
            log.info("OMException in getSOAPBuilder", e);
            try {
                log.info("Remaining input stream :[" + new String(IOUtils.getStreamAsByteArray(inStream), charSetEnc)+ "]");
View Full Code Here

TOP

Related Classes of org.apache.axiom.om.impl.builder.StAXBuilder

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.