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

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


            } 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


            if ((builder != null) && (builder instanceof StAXBuilder)) {
                try {
                    if (log.isDebugEnabled()) {
                        log.debug("closing builder: " + builder);
                    }
                    StAXBuilder staxBuilder = (StAXBuilder) builder;
                    staxBuilder.close();
                } catch (Exception e) {
                    if (log.isDebugEnabled()) {
                        log.error("Could not close builder or parser due to: ", e);
                    }
                }
View Full Code Here

        }
    }
   
    public void testAccessToParser() throws Exception {
        OMElement root = createTestMTOMMessage();
        StAXBuilder builder = (StAXBuilder) root.getBuilder();
        // Disable caching so that the reader can be accessed.
        builder.setCache(false);
        XMLStreamReader reader = (XMLStreamReader) builder.getParser();
       
        // For an MTOM message, the reader is actually an XOPDecodingStreamReader. This one
        // cannot be unwrapped by getOriginalXMLStreamReader
        assertSame(reader, XMLStreamReaderUtils.getOriginalXMLStreamReader(reader));
       
View Full Code Here

    public void testElementPullStreamAndOMExpansion() throws Exception {
        // Create a reader sourced from a message containing an interesting payload
        XMLStreamReader reader = StAXUtils.createXMLStreamReader(getTestResource("soap/OMElementTest.xml"));
       
        // Create a builder connected to the reader
        StAXBuilder builder = (StAXBuilder)OMXMLBuilderFactory.createStAXSOAPModelBuilder(
                reader);
       
        // Create a custom builder to store the sub trees as a byte array instead of a full tree
        ByteArrayCustomBuilder customBuilder = new ByteArrayCustomBuilder("utf-8");
       
        // Register the custom builder on the builder so that they body payload is stored as bytes
        builder.registerCustomBuilderForPayload(customBuilder);
       
       
        // Create an output stream
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        writer = StAXUtils.createXMLStreamWriter(byteArrayOutputStream);

        // Now use StreamingOMSerializer to write the input stream to the output stream
        SOAPEnvelope env = (SOAPEnvelope) builder.getDocumentElement();
        SOAPBody body = env.getBody();
        OMSourcedElement omse = (OMSourcedElement) body.getFirstElement();
       
        StreamingOMSerializer serializer = new StreamingOMSerializer();
        serializer.serialize(env.getXMLStreamReaderWithoutCaching(),
View Full Code Here

    public void testElementPullStreamAndOMExpansion2() throws Exception {
        // Create a reader sourced from a message containing an interesting payload
        XMLStreamReader reader = StAXUtils.createXMLStreamReader(getTestResource("soap/soapmessageWithXSI.xml"));
       
        // Create a builder connected to the reader
        StAXBuilder builder = (StAXBuilder)OMXMLBuilderFactory.createStAXSOAPModelBuilder(
                reader);
       
        // Create a custom builder to store the sub trees as a byte array instead of a full tree
        ByteArrayCustomBuilder customBuilder = new ByteArrayCustomBuilder("utf-8");
       
        // Register the custom builder on the builder so that they body payload is stored as bytes
        builder.registerCustomBuilderForPayload(customBuilder);
       
       
        // Create an output stream
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        writer = StAXUtils.createXMLStreamWriter(byteArrayOutputStream);

        // Now use StreamingOMSerializer to write the input stream to the output stream
        SOAPEnvelope env = (SOAPEnvelope) builder.getDocumentElement();
        SOAPBody body = env.getBody();
        OMSourcedElement omse = (OMSourcedElement) body.getFirstElement();
       
        StreamingOMSerializer serializer = new StreamingOMSerializer();
        serializer.serialize(env.getXMLStreamReaderWithoutCaching(),
View Full Code Here

    public void testElementPullStreamAndOMExpansion3() throws Exception {
        // Create a reader sourced from a message containing an interesting payload
        XMLStreamReader reader = StAXUtils.createXMLStreamReader(getTestResource("soap/noprettyprint.xml"));
       
        // Create a builder connected to the reader
        StAXBuilder builder = (StAXBuilder)OMXMLBuilderFactory.createStAXSOAPModelBuilder(
                reader);
       
        // Create a custom builder to store the sub trees as a byte array instead of a full tree
        ByteArrayCustomBuilder customBuilder = new ByteArrayCustomBuilder("utf-8");
       
        // Register the custom builder on the builder so that they body payload is stored as bytes
        builder.registerCustomBuilderForPayload(customBuilder);
       
       
        // Create an output stream
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        writer = StAXUtils.createXMLStreamWriter(byteArrayOutputStream);

        // Now use StreamingOMSerializer to write the input stream to the output stream
        SOAPEnvelope env = (SOAPEnvelope) builder.getDocumentElement();
        SOAPBody body = env.getBody();
        OMSourcedElement omse = (OMSourcedElement) body.getFirstElement();
       
        StreamingOMSerializer serializer = new StreamingOMSerializer();
        serializer.serialize(env.getXMLStreamReaderWithoutCaching(),
View Full Code Here

     */
    public void close() throws XMLStreamException {

        // If there is a builder, it controls its parser
        if (builder != null && builder instanceof StAXBuilder) {
            StAXBuilder staxBuilder = (StAXBuilder) builder;
            staxBuilder.close();
            setParser(null);
        } else {
            if (parser != null) {
                try {
                    if (!isClosed()) {
View Full Code Here

        if (parser != null) {
            return parser.getProperty(s);
        }
        // Delegate to the builder's parser.
        if (builder != null && builder instanceof StAXBuilder) {
            StAXBuilder staxBuilder = (StAXBuilder) builder;
            if (!staxBuilder.isClosed()) {
                // If the parser was closed by something other
                // than the builder, an IllegalStateException is
                // thrown.  For now, return null as this is unexpected
                // by the caller.
                try {
View Full Code Here

     */
    public void close() throws XMLStreamException {

        // If there is a builder, it controls its parser
        if (builder != null && builder instanceof StAXBuilder) {
            StAXBuilder staxBuilder = (StAXBuilder) builder;
            staxBuilder.close();
            setParser(null);
        } else {
            if (parser != null) {
                try {
                    if (!isClosed()) {
View Full Code Here

        if (parser != null) {
            return parser.getProperty(s);
        }
        // Delegate to the builder's parser.
        if (builder != null && builder instanceof StAXBuilder) {
            StAXBuilder staxBuilder = (StAXBuilder) builder;
            if (!staxBuilder.isClosed()) {
                // If the parser was closed by something other
                // than the builder, an IllegalStateException is
                // thrown.  For now, return null as this is unexpected
                // by the caller.
                try {
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.