Package org.apache.axis2.om.impl.llom.builder

Examples of org.apache.axis2.om.impl.llom.builder.StAXBuilder


                msgContext.setProperty(MessageContext.TRANSPORT_OUT, out);

                //create the SOAP Envelope
                Reader in = new InputStreamReader(socket.getInputStream());
                XMLStreamReader xmlreader = XMLInputFactory.newInstance().createXMLStreamReader(in);
                StAXBuilder builder = new StAXSOAPModelBuilder(xmlreader, null);
                SOAPEnvelope envelope = (SOAPEnvelope) builder.getDocumentElement();
                msgContext.setEnvelope(envelope);
                if (envelope.getBody().hasFault()) {
                    engine.receiveFault(msgContext);
                } else {
                    engine.receive(msgContext);
View Full Code Here


            msgContext.setTo(new EndpointReference(requestURI));
            msgContext.setProperty(MessageContext.TRANSPORT_OUT, out);
            msgContext.setServerSide(true);

            SOAPEnvelope envelope = null;
            StAXBuilder builder = null;
            if (contentType != null) {
                if (contentType
                    .indexOf(HTTPConstants.HEADER_ACCEPT_MULTIPART_RELATED)
                    > -1) {
                    //It is MTOM
                    builder = selectBuilderForMIME(msgContext, in, contentType);
                    envelope = (SOAPEnvelope) builder.getDocumentElement();
                } else {
                    Reader reader = new InputStreamReader(in);

                    XMLStreamReader xmlreader;
                    //Figure out the char set encoding and create the reader

                    //If charset is not specified
                    if ( getCharSetEncoding(contentType) == null ) {
                        xmlreader =
                            XMLInputFactory
                                .newInstance()
                                .createXMLStreamReader(
                                in,
                                MessageContext.DEFAULT_CHAR_SET_ENCODING);
                        //Set the encoding scheme in the message context
                        msgContext.setProperty(
                            MessageContext.CHARACTER_SET_ENCODING,
                            MessageContext.DEFAULT_CHAR_SET_ENCODING);
                    } else {
                        //get the type of char encoding
                        String charSetEnc = getCharSetEncoding(contentType);
                        xmlreader =
                            XMLInputFactory
                                .newInstance()
                                .createXMLStreamReader(
                                in,
                                charSetEnc);

                        //Setting the value in msgCtx
                        msgContext.setProperty(
                            MessageContext.CHARACTER_SET_ENCODING,
                            charSetEnc);

                    }
                    if (contentType
                        .indexOf(SOAP12Constants.SOAP_12_CONTENT_TYPE)
                        > -1) {
                        soap11 = false;
                        //it is SOAP 1.2
                        builder =
                            new StAXSOAPModelBuilder(
                                xmlreader,
                                SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
                        envelope = (SOAPEnvelope) builder.getDocumentElement();
                    } else if (
                        contentType.indexOf(
                            SOAP11Constants.SOAP_11_CONTENT_TYPE)
                            > -1) {
                        soap11 = true;
                        //it is SOAP 1.1
                        Object enable =
                            msgContext.getProperty(
                                Constants.Configuration.ENABLE_REST);
                        if ((soapActionHeader == null
                            || soapActionHeader.length() == 0)
                            && Constants.VALUE_TRUE.equals(enable)) {
                            //If the content Type is text/xml (BTW which is the SOAP 1.1 Content type ) and
                            //the SOAP Action is absent it is rest !!
                            msgContext.setDoingREST(true);

                            SOAPFactory soapFactory = new SOAP11Factory();
                            builder = new StAXOMBuilder(xmlreader);
                            builder.setOmbuilderFactory(soapFactory);
                            envelope = soapFactory.getDefaultEnvelope();
                            envelope.getBody().addChild(
                                builder.getDocumentElement());
                        } else {
                            builder =
                                new StAXSOAPModelBuilder(
                                    xmlreader,
                                    SOAP11Constants
                                        .SOAP_ENVELOPE_NAMESPACE_URI);
                            envelope =
                                (SOAPEnvelope) builder.getDocumentElement();
                        }
                    }

                }

            }

            String charsetEncoding = builder.getDocument().getCharsetEncoding();
            if(charsetEncoding != null && !"".equals(charsetEncoding) &&
                    !((String)msgContext.getProperty(MessageContext.CHARACTER_SET_ENCODING))
                            .equalsIgnoreCase(charsetEncoding)){
                String faultCode;
                if(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(envelope.getNamespace().getName())){
View Full Code Here

        InputStream inStream,
        String contentTypeString)
        throws OMException,
      XMLStreamException, FactoryConfigurationError,
      UnsupportedEncodingException {
        StAXBuilder builder = null;


        Parameter parameter_cache_attachment = msgContext.getParameter(
                Constants.Configuration.CACHE_ATTACHMENTS);
         boolean fileCacheForAttachments ;
View Full Code Here

            XMLStreamReader reader =
                XMLInputFactory.newInstance().createXMLStreamReader(
                    new BufferedReader(new InputStreamReader(in)));

            StAXBuilder builder = new StAXSOAPModelBuilder(reader, null);
            SOAPEnvelope envelope = (SOAPEnvelope) builder.getDocumentElement();
            msgCtx.setEnvelope(envelope);
            AxisEngine engine = new AxisEngine(confContext);

            if (envelope.getBody().hasFault()) {
                engine.receiveFault(msgCtx);
View Full Code Here

                msgContext.setProperty(MessageContext.TRANSPORT_OUT, out);

                //create the SOAP Envelope
                Reader in = new InputStreamReader(socket.getInputStream());
                XMLStreamReader xmlreader = XMLInputFactory.newInstance().createXMLStreamReader(in);
                StAXBuilder builder = new StAXSOAPModelBuilder(xmlreader, null);
                SOAPEnvelope envelope = (SOAPEnvelope) builder.getDocumentElement();
                msgContext.setEnvelope(envelope);
                if (envelope.getBody().hasFault()) {
                    engine.receiveFault(msgContext);
                } else {
                    engine.receive(msgContext);
View Full Code Here

            XMLStreamReader reader =
                XMLInputFactory.newInstance().createXMLStreamReader(
                    new BufferedReader(new InputStreamReader(in)));

            StAXBuilder builder = new StAXSOAPModelBuilder(reader, null);
            SOAPEnvelope envelope = (SOAPEnvelope) builder.getDocumentElement();
            msgCtx.setEnvelope(envelope);
            AxisEngine engine = new AxisEngine(confContext);

            if (envelope.getBody().hasFault()) {
                engine.receiveFault(msgCtx);
View Full Code Here

        InputStream inStream,
        String contentTypeString)
        throws OMException,
      XMLStreamException, FactoryConfigurationError,
      UnsupportedEncodingException {
        StAXBuilder builder = null;


        Parameter parameter_cache_attachment = msgContext.getParameter(
                Constants.Configuration.CACHE_ATTACHMENTS);
         boolean fileCacheForAttachments ;
View Full Code Here

            msgContext.setTo(new EndpointReference(requestURI));
            msgContext.setProperty(MessageContext.TRANSPORT_OUT, out);
            msgContext.setServerSide(true);

            SOAPEnvelope envelope = null;
            StAXBuilder builder = null;
            if (contentType != null) {
                if (contentType
                    .indexOf(HTTPConstants.HEADER_ACCEPT_MULTIPART_RELATED)
                    > -1) {
                    //It is MTOM
                    builder = selectBuilderForMIME(msgContext, in, contentType);
                    envelope = (SOAPEnvelope) builder.getDocumentElement();
                } else {
                    Reader reader = new InputStreamReader(in);

                    XMLStreamReader xmlreader;
                    //Figure out the char set encoding and create the reader

                    //If charset is not specified
                    if ( getCharSetEncoding(contentType) == null ) {
                        xmlreader =
                            XMLInputFactory
                                .newInstance()
                                .createXMLStreamReader(
                                in,
                                MessageContext.DEFAULT_CHAR_SET_ENCODING);
                        //Set the encoding scheme in the message context
                        msgContext.setProperty(
                            MessageContext.CHARACTER_SET_ENCODING,
                            MessageContext.DEFAULT_CHAR_SET_ENCODING);
                    } else {
                        //get the type of char encoding
                        String charSetEnc = getCharSetEncoding(contentType);
                        xmlreader =
                            XMLInputFactory
                                .newInstance()
                                .createXMLStreamReader(
                                in,
                                charSetEnc);

                        //Setting the value in msgCtx
                        msgContext.setProperty(
                            MessageContext.CHARACTER_SET_ENCODING,
                            charSetEnc);

                    }
                    if (contentType
                        .indexOf(SOAP12Constants.SOAP_12_CONTENT_TYPE)
                        > -1) {
                        soap11 = false;
                        //it is SOAP 1.2
                        builder =
                            new StAXSOAPModelBuilder(
                                xmlreader,
                                SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
                        envelope = (SOAPEnvelope) builder.getDocumentElement();
                    } else if (
                        contentType.indexOf(
                            SOAP11Constants.SOAP_11_CONTENT_TYPE)
                            > -1) {
                        soap11 = true;
                        //it is SOAP 1.1

//                            msgContext.getProperty(
//                                Constants.Configuration.ENABLE_REST);
                        /**
                         * Configuration via Deployment
                         */

                        Parameter enable  = msgContext.getParameter(Constants.Configuration.ENABLE_REST);

                        if ((soapActionHeader == null
                                || soapActionHeader.length() == 0)
                                && enable != null) {
                            if (Constants.VALUE_TRUE
                                    .equals(enable.getValue())) {
                                //If the content Type is text/xml (BTW which is the SOAP 1.1 Content type ) and
                                //the SOAP Action is absent it is rest !!
                                msgContext.setDoingREST(true);

                                SOAPFactory soapFactory = new SOAP11Factory();
                                builder = new StAXOMBuilder(xmlreader);
                                builder.setOmbuilderFactory(soapFactory);
                                envelope = soapFactory.getDefaultEnvelope();
                                envelope.getBody().addChild(
                                        builder.getDocumentElement());
                            }
                        } else {
                            builder =
                                new StAXSOAPModelBuilder(
                                    xmlreader,
                                    SOAP11Constants
                                        .SOAP_ENVELOPE_NAMESPACE_URI);
                            envelope =
                                (SOAPEnvelope) builder.getDocumentElement();
                        }
                    }

                }

            }

            String charsetEncoding = builder.getDocument().getCharsetEncoding();
            if(charsetEncoding != null && !"".equals(charsetEncoding) &&
                    !((String)msgContext.getProperty(MessageContext.CHARACTER_SET_ENCODING))
                            .equalsIgnoreCase(charsetEncoding)){
                String faultCode;
                if(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(envelope.getNamespace().getName())){
View Full Code Here

    public void testCode() {
        try {
            String filename = "test-resources/soap/wrongEnvelopeNamespace.xml";
            XMLStreamReader xmlr = XMLInputFactory.newInstance()
                    .createXMLStreamReader(new FileInputStream(filename));
            StAXBuilder builder = new StAXSOAPModelBuilder(xmlr, null); //exception here
            fail("Builder must fail here due to wrong SOAP namespace");
        } catch (SOAPProcessingException e) {
            assertTrue(true);
        } catch (FileNotFoundException e) {
            fail("Only SOAPProcessingException can be thrown here");
View Full Code Here

                                HTTPConstants.MTOM_RECIVED_CONTENT_TYPE);
            } else {
                throw new AxisFault(Messages.getMessage("cannotBeNullOperationContext"));
            }

            StAXBuilder builder = null;
            SOAPEnvelope envelope = null;

            String charSetEnc = (String)msgContext.getProperty(MessageContext.CHARACTER_SET_ENCODING);
            if(charSetEnc == null) {
              charSetEnc = MessageContext.DEFAULT_CHAR_SET_ENCODING;
            }
           
      if (contentType != null) {
                msgContext.setDoingMTOM(true);
                builder =
                        HTTPTransportUtils.selectBuilderForMIME(msgContext,
                                inStream,
                                (String) contentType);
                envelope = (SOAPEnvelope) builder.getDocumentElement();
            } else if (msgContext.isDoingREST()) {
                XMLStreamReader xmlreader =
                        XMLInputFactory.newInstance().createXMLStreamReader(
                                inStream,charSetEnc);
                SOAPFactory soapFactory = new SOAP11Factory();
                builder = new StAXOMBuilder(xmlreader);
                builder.setOmbuilderFactory(soapFactory);
                envelope = soapFactory.getDefaultEnvelope();
                envelope.getBody().addChild(builder.getDocumentElement());
            } else {
                XMLStreamReader xmlreader =
                        XMLInputFactory.newInstance().createXMLStreamReader(
                            inStream,charSetEnc);
                builder = new StAXSOAPModelBuilder(xmlreader, soapNamespaceURI);
                envelope = (SOAPEnvelope) builder.getDocumentElement();
            }
            return envelope;
        } catch (Exception e) {
            throw new AxisFault(e);
        }
View Full Code Here

TOP

Related Classes of org.apache.axis2.om.impl.llom.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.