Package org.apache.axiom.soap

Examples of org.apache.axiom.soap.SOAPHeaderBlock


            header = factory.createSOAPHeader(envelope);
        }
        OMElement element = xmlHelper.toOMElement(content);
        // We can't add the element directly to the SOAPHeader. Instead, we need to copy the
        // information over to a SOAPHeaderBlock.
        SOAPHeaderBlock headerBlock = header.addHeaderBlock(element.getLocalName(),
                element.getNamespace());
        for (Iterator it = element.getAllAttributes(); it.hasNext(); ) {
            headerBlock.addAttribute((OMAttribute)it.next());
        }
        headerBlock.setMustUnderstand(mustUnderstand);
        OMNode child = element.getFirstOMChild();
        while (child != null) {
            // Get the next child before addChild will detach the node from its original place.
            OMNode next = child.getNextOMSibling();
            headerBlock.addChild(child);
            child = next;
        }
    }
View Full Code Here


        if (envelope.getHeader() != null) {
            Iterator headerBlocks = envelope.getHeader().getHeadersToProcess(null);
            ArrayList<SOAPHeaderBlock> markedHeaderBlocks = new ArrayList<SOAPHeaderBlock>();

            while (headerBlocks.hasNext()) {
                SOAPHeaderBlock headerBlock = (SOAPHeaderBlock) headerBlocks.next();

                // if this header block mustUnderstand but has not been processed
                // then mark it as processed to get the message in to Synapse
                if (!headerBlock.isProcessed() && headerBlock.getMustUnderstand()) {
                    markedHeaderBlocks.add(headerBlock);
                    headerBlock.setProcessed();
                }
            }

            // incase we need to get them inside synapse
            messageContext.setProperty("headersMarkedAsProcessedBySynapse", markedHeaderBlocks);
View Full Code Here

            SOAPHeader header = synCtx.getEnvelope().getHeader();
            if (header != null) {
                for (Iterator iter = header.examineAllHeaderBlocks(); iter.hasNext();) {
                    Object o = iter.next();
                    if (o instanceof SOAPHeaderBlock) {
                        SOAPHeaderBlock headerBlk = (SOAPHeaderBlock) o;
                        sb.append(separator).append(headerBlk.getLocalName()).
                                append(" : ").append(headerBlk.getText());
                    } else if (o instanceof OMElement) {
                        OMElement headerElem = (OMElement) o;
                        sb.append(separator).append(headerElem.getLocalName()).
                                append(" : ").append(headerElem.getText());
                    }
View Full Code Here

    public static void addSOAPHeaderBlock(org.apache.axis2.context.MessageContext msgCtx,
                                          QName qname, String value) {

        SOAPEnvelope env = msgCtx.getEnvelope();
        SOAPHeaderBlock header = env.getHeader().addHeaderBlock(
                qname.getLocalPart(),
                msgCtx.getEnvelope().getOMFactory().
                        createOMNamespace(qname.getNamespaceURI(), qname.getPrefix()));
        header.setText(value);       
    }
View Full Code Here

            for (Iterator iter = soapHeader.examineAllHeaderBlocks(); iter.hasNext();) {

                Object o = iter.next();
                if (o instanceof SOAPHeaderBlock) {

                    SOAPHeaderBlock headerBlock = (SOAPHeaderBlock) o;
                    sb.append(separator).append("\t").append(
                        headerBlock.getLocalName()).append(" : ").append(headerBlock.getText());

                } else if (o instanceof OMElement) {

                    OMElement headerElem = (OMElement) o;
                    sb.append(separator).append("\t").append(
View Full Code Here

        SOAPFactory fac = (SOAPFactory) env.getOMFactory();
        SOAPHeader header = env.getHeader();
        if (header == null) {
            header = fac.createSOAPHeader(env);
        }
        SOAPHeaderBlock hb = header.addHeaderBlock(qName.getLocalPart(),
                fac.createOMNamespace(qName.getNamespaceURI(), qName.getPrefix()));
        hb.setText(value);
    }
View Full Code Here

        if (headersList == null || headersList.isEmpty()) {
            return;
        }
        for (Object o : headersList) {
            if (o instanceof SOAPHeaderBlock) {
                SOAPHeaderBlock header = (SOAPHeaderBlock) o;
                if (header.getLocalName().equals(qName.getLocalPart())) {
                    header.detach();
                }
            } else if (o instanceof OMElement) {
                OMElement omElem = (OMElement) o;
                if (omElem.getLocalName().equals(qName.getLocalPart())) {
                    omElem.detach();
View Full Code Here

        super(metaFactory, spec);
    }

    protected void runTest() throws Throwable {
        SOAPEnvelope envelope = getTestMessage(SOAP_MESSAGE);
        SOAPHeaderBlock headerBlock = (SOAPHeaderBlock)envelope.getHeader().getFirstChildWithName(
                new QName("http://schemas.xmlsoap.org/ws/2004/03/addressing", "From"));
        headerBlock.getFirstElement().getFirstOMChild();
        assertFalse(headerBlock.isComplete());
        XMLStreamReader reader = envelope.getXMLStreamReaderWithoutCaching();
        while (reader.hasNext()) {
            reader.next();
        }
        assertFalse(headerBlock.isComplete());
    }
View Full Code Here

    public TestSetMustUnderstandString01(OMMetaFactory metaFactory, SOAPSpec spec) {
        super(metaFactory, spec);
    }

    protected void runTest() throws Throwable {
        SOAPHeaderBlock soapHeaderBlock = createSOAPHeaderBlock();
        soapHeaderBlock.setMustUnderstand("1");
        assertTrue(
                "SOAP HeaderBlock Test : - After setting MustUnderstand \"1\" calling setMustUnderstand method , getMustUnderstand method returns false",
                soapHeaderBlock.getMustUnderstand());
        soapHeaderBlock.setMustUnderstand("0");
        assertFalse(
                "SOAP HeaderBlock Test : - After setting MustUnderstand \"0\" calling setMustUnderstand method , getMustUnderstand method returns true",
                soapHeaderBlock.getMustUnderstand());
    }
View Full Code Here

    public TestGetRole(OMMetaFactory metaFactory, SOAPSpec spec) {
        super(metaFactory, spec);
    }

    protected void runTest() throws Throwable {
        SOAPHeaderBlock soapHeaderBlock = createSOAPHeaderBlock();
        assertNull(
                "SOAP HeaderBlock Test : - After creating SOAPHeaderBlock, it has a role",
                soapHeaderBlock.getRole());
        soapHeaderBlock.setRole(
                "http://example.org/my-role");
        assertEquals(
                "SOAP HeaderBlock Test : - After calling setRole method, getRole method returns incorrect role value",
                "http://example.org/my-role", soapHeaderBlock.getRole());
    }
View Full Code Here

TOP

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

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.