Package org.apache.axiom.soap

Examples of org.apache.axiom.soap.SOAPHeader


    }

    protected void runTest() throws Throwable {
        SOAPEnvelope envelope = getTestMessage(MESSAGE_WITHOUT_HEADER);
        assertNull(envelope.getHeader());
        SOAPHeader header = soapFactory.createSOAPHeader(envelope);
        assertSame(header, envelope.getHeader());
    }
View Full Code Here


        super(metaFactory, spec);
    }

    protected void runTest() throws Throwable {
        SOAPEnvelope soapEnvelope = soapFactory.createSOAPEnvelope();
        SOAPHeader soapHeader = soapFactory.createSOAPHeader(soapEnvelope);
        String localName = "myPayload";
        String encoding = "utf-8";
        String payload1 = "<tns:myPayload xmlns:tns=\"urn://test\">Payload One</tns:myPayload>";
        OMNamespace ns = soapFactory.createOMNamespace("urn://test", "tns");
        ByteArrayDataSource bads1 = new ByteArrayDataSource(payload1.getBytes(encoding), encoding);
       
        // Set an empty MustUnderstand property on the data source
        bads1.setProperty(SOAPHeaderBlock.MUST_UNDERSTAND_PROPERTY, null);
       
        OMSourcedElement omse = soapFactory.createSOAPHeaderBlock(localName, ns, bads1);
        soapHeader.addChild(omse);
        OMNode firstChild = soapHeader.getFirstOMChild();
        assertTrue("Expected OMSourcedElement child", firstChild instanceof SOAPHeaderBlock);
        SOAPHeaderBlock child = (SOAPHeaderBlock) firstChild;
        assertTrue("OMSourcedElement is expanded.  This is unexpected", !child.isExpanded());
        assertTrue("OMSourcedElement should be backed by a ByteArrayDataSource",
                   child.getDataSource() instanceof ByteArrayDataSource);
       
        // Make sure that getting the MustUnderstand property does not cause expansion.
        assertTrue(!child.getMustUnderstand());
        assertTrue("OMSourcedElement is expanded.  This is unexpected", !child.isExpanded());
        assertTrue("OMSourcedElement should be backed by a ByteArrayDataSource",
                   child.getDataSource() instanceof ByteArrayDataSource);
       
        // A ByteArrayDataSource does not consume the backing object when read.
        // Thus getting the XMLStreamReader of the ByteArrayDataSource should not
        // cause expansion of the OMSourcedElement.
        XMLStreamReader reader = child.getXMLStreamReader();
        reader.next();
        assertTrue("OMSourcedElement is expanded.  This is unexpected", !child.isExpanded());
       
        // Likewise, a ByteArrayDataSource does not consume the backing object when
        // written.  Thus serializing the OMSourcedElement should not cause the expansion
        // of the OMSourcedElement.
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        soapHeader.serialize(baos);
        String output = baos.toString(encoding);
//        System.out.println(output);
        assertTrue("The payload was not present in the output",
                   output.indexOf(payload1) > 0);
        assertTrue("OMSourcedElement is expanded.  This is unexpected", !child.isExpanded());
View Full Code Here

    public void testCreateSOAPHeader() throws Exception {
        OMXMLParserWrapper omBuilder = OMXMLBuilderFactory.createSOAPModelBuilder(
                getTestResource(TestConstants.MINIMAL_MESSAGE), null);
        SOAPEnvelope soapEnvelope = (SOAPEnvelope) omBuilder.getDocumentElement();
        SOAPHeader soapHeader = omFactory.createSOAPHeader(soapEnvelope);
        assertTrue(
                "Programatically created SOAPHeader should have done = true ",
                soapHeader.isComplete());
    }
View Full Code Here

    public void testCreateSOAPHeaderBlock() throws Exception {
        OMXMLParserWrapper omBuilder = OMXMLBuilderFactory.createSOAPModelBuilder(
                getTestResource(TestConstants.SOAP_SOAPMESSAGE), null);
        SOAPEnvelope soapEnvelope = (SOAPEnvelope) omBuilder.getDocumentElement();
        SOAPHeader soapHeader = soapEnvelope.getHeader();
        SOAPHeaderBlock soapHeaderBlock = omFactory.createSOAPHeaderBlock(
                "soapHeaderBlockOne", namespace, soapHeader);
        assertTrue(
                "Programatically created SOAPHeaderBlock should have done = true ",
                soapHeaderBlock.isComplete());
View Full Code Here

        super(metaFactory, spec);
    }

    protected void runTest() throws Throwable {
        SOAPEnvelope soapEnvelope = soapFactory.createSOAPEnvelope();
        SOAPHeader soapHeader = soapFactory.createSOAPHeader(soapEnvelope);
        OMNamespace namespace = soapFactory.createOMNamespace("http://www.example.org", "test");
        soapHeader.addHeaderBlock("echoOk1", namespace);
        soapHeader.addHeaderBlock("echoOk2",
                                    soapFactory.createOMNamespace("http://www.test1.org", "test1"));
        ArrayList arrayList = soapHeader.getHeaderBlocksWithNSURI(
                "http://www.test1.org");
        assertEquals(
                "SOAP Header Test : - getHeaderBlocksWithNSURI returns an arrayList of incorrect size",
                1, arrayList.size());
        assertEquals(
View Full Code Here

        super(metaFactory, spec);
    }

    protected void runTest() throws Throwable {
        SOAPEnvelope envelope = soapFactory.createSOAPEnvelope();
        SOAPHeader header = soapFactory.createSOAPHeader(envelope);
        OMNamespace ns = soapFactory.createOMNamespace("", "");
        try {
            header.addHeaderBlock("test", ns);
            fail("Expected OMException");
        } catch (OMException ex) {
            // Expected
        }
    }
View Full Code Here

        super(metaFactory, spec);
    }

    protected void runTest() throws Throwable {
        SOAPEnvelope envelope = soapFactory.createSOAPEnvelope();
        SOAPHeader header = soapFactory.createSOAPHeader(envelope);
        OMNamespace ns = soapFactory.createOMNamespace("urn:ns", "p");
        SOAPHeaderBlock h1 = header.addHeaderBlock("header1", ns);
        SOAPHeaderBlock h2 = header.addHeaderBlock("header2", ns);
        Iterator it = header.extractAllHeaderBlocks();
        assertTrue(it.hasNext());
        assertSame(h1, it.next());
        assertTrue(it.hasNext());
        assertSame(h2, it.next());
        assertFalse(it.hasNext());
View Full Code Here

        super(metaFactory, spec);
    }

    protected void runTest() throws Throwable {
        SOAPEnvelope soapEnvelope = soapFactory.createSOAPEnvelope();
        SOAPHeader soapHeader = soapFactory.createSOAPHeader(soapEnvelope);
        OMNamespace namespace = soapFactory.createOMNamespace("http://www.example.org", "test");
        soapHeader.addHeaderBlock("echoOk1", namespace);
        soapHeader.addHeaderBlock("echoOk2", namespace);
        Iterator iterator = soapHeader.examineAllHeaderBlocks();
        iterator.hasNext();
        SOAPHeaderBlock headerBlock1 = (SOAPHeaderBlock) iterator.next();
        assertNotNull(
                "SOAP Header Test : - After calling addHeaderBlock method twice, examineAllHeaderBlocks method returns empty iterator",
                headerBlock1);
View Full Code Here

        super(metaFactory, spec);
    }

    protected void runTest() throws Throwable {
        SOAPEnvelope envelope = soapFactory.createSOAPEnvelope();
        SOAPHeader header = soapFactory.createSOAPHeader(envelope);
        try {
            header.addHeaderBlock("test", null);
            fail("Expected OMException");
        } catch (OMException ex) {
            // Expected
        }
    }
View Full Code Here

        super(metaFactory, spec);
    }

    protected void runTest() throws Throwable {
        SOAPEnvelope envelope = getTestMessage(SOAP_MESSAGE);
        SOAPHeader header = envelope.getHeader();
        OMElement from = header.getFirstChildWithName(new QName("http://schemas.xmlsoap.org/ws/2004/03/addressing", "From"));
        from.getFirstElement().getFirstOMChild();
        assertFalse(from.isComplete()); // Just in case getFirstChildWithName or getFirstElement did stupid things
       
        header.discard();
        OMElement body = envelope.getFirstElement();
        assertTrue(body instanceof SOAPBody);
    }
View Full Code Here

TOP

Related Classes of org.apache.axiom.soap.SOAPHeader

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.