Package org.apache.ws.commons.soap

Examples of org.apache.ws.commons.soap.SOAPHeaderBlock


        Map alreadyFoundAddrHeader = new HashMap(7); // there are seven frequently used WS-A headers

        // First pass just check for duplicates
        Iterator addressingHeadersIt = addressingHeaders.iterator();
        while (addressingHeadersIt.hasNext()) {
            SOAPHeaderBlock soapHeaderBlock = (SOAPHeaderBlock) addressingHeadersIt.next();
            if (SOAP12Constants.SOAP_ROLE_NONE.equals(soapHeaderBlock.getRole()))
                continue;
            if (WSA_TO.equals(soapHeaderBlock.getLocalName())) {
                checkDuplicateHeaders(WSA_TO, messageContext, alreadyFoundAddrHeader);
            } else if (WSA_FROM.equals(soapHeaderBlock.getLocalName())) {
                checkDuplicateHeaders(WSA_FROM, messageContext, alreadyFoundAddrHeader);
            } else if (WSA_REPLY_TO.equals(soapHeaderBlock.getLocalName())) {
                checkDuplicateHeaders(WSA_REPLY_TO, messageContext, alreadyFoundAddrHeader);
            } else if (WSA_FAULT_TO.equals(soapHeaderBlock.getLocalName())) {
                checkDuplicateHeaders(WSA_FAULT_TO, messageContext, alreadyFoundAddrHeader);
            } else if (WSA_MESSAGE_ID.equals(soapHeaderBlock.getLocalName())) {
                checkDuplicateHeaders(WSA_MESSAGE_ID, messageContext, alreadyFoundAddrHeader);
            } else if (WSA_ACTION.equals(soapHeaderBlock.getLocalName())) {
                checkDuplicateHeaders(WSA_ACTION, messageContext, alreadyFoundAddrHeader);
            } else if (WSA_RELATES_TO.equals(soapHeaderBlock.getLocalName())) {
                checkDuplicateHeaders(WSA_RELATES_TO, messageContext, alreadyFoundAddrHeader);
            }
        }

        // Now extract information
        Iterator addressingHeadersIt2 = addressingHeaders.iterator();
        while (addressingHeadersIt2.hasNext()) {
            SOAPHeaderBlock soapHeaderBlock = (SOAPHeaderBlock) addressingHeadersIt2.next();
            if (SOAP12Constants.SOAP_ROLE_NONE.equals(soapHeaderBlock.getRole()))
                continue;
            if (WSA_TO.equals(soapHeaderBlock.getLocalName())) {
                extractToEPRInformation(soapHeaderBlock, messageContextOptions, header);
            } else if (WSA_FROM.equals(soapHeaderBlock.getLocalName())) {
                extractFromEPRInformation(messageContextOptions, soapHeaderBlock, addressingNamespace);
            } else if (WSA_REPLY_TO.equals(soapHeaderBlock.getLocalName())) {
                extractReplyToEPRInformation(messageContextOptions, soapHeaderBlock, addressingNamespace);
            } else if (WSA_FAULT_TO.equals(soapHeaderBlock.getLocalName())) {
                extractFaultToEPRInformation(messageContextOptions, soapHeaderBlock, addressingNamespace);
            } else if (WSA_MESSAGE_ID.equals(soapHeaderBlock.getLocalName())) {
                messageContextOptions.setMessageId(soapHeaderBlock.getText());
                soapHeaderBlock.setProcessed();
            } else if (WSA_ACTION.equals(soapHeaderBlock.getLocalName())) {
                messageContextOptions.setAction(soapHeaderBlock.getText());
                soapHeaderBlock.setProcessed();
            } else if (WSA_RELATES_TO.equals(soapHeaderBlock.getLocalName())) {
                extractRelatesToInformation(soapHeaderBlock, addressingNamespace, messageContextOptions);
            }
        }

        // check for the presense of madatory addressing headers
View Full Code Here


        SOAPHeader header = msgContext.getEnvelope().getHeader();
        if (header != null) {
            ArrayList addressingHeaders = header.getHeaderBlocksWithNSURI(addressingNamespace);
            Iterator addressingHeadersIt = addressingHeaders.iterator();
            while (addressingHeadersIt.hasNext()) {
                SOAPHeaderBlock soapHeaderBlock = (SOAPHeaderBlock) addressingHeadersIt.next();
                if (WSA_MESSAGE_ID.equals(soapHeaderBlock.getLocalName())) {
                    return soapHeaderBlock.getText();
                }
            }
        }
        return null;
    }
View Full Code Here


    protected void extractToEprReferenceParameters(EndpointReference toEPR, SOAPHeader header) {
        Iterator headerBlocks = header.getChildElements();
        while (headerBlocks.hasNext()) {
            SOAPHeaderBlock soapHeaderBlock = (SOAPHeaderBlock) headerBlocks.next();
            OMAttribute isRefParamAttr = soapHeaderBlock.getAttribute(new QName(addressingNamespace, "IsReferenceParameter"));
            if (isRefParamAttr != null && "true".equals(isRefParamAttr.getAttributeValue())) {
                toEPR.addReferenceParameter(soapHeaderBlock.getQName(), soapHeaderBlock.getText());
            }
        }
    }
View Full Code Here

        Map faultInfo = (Map) msgContext.getProperty(Constants.FAULT_INFORMATION_FOR_HEADERS);
        if (faultInfo != null) {
            String faultyHeaderQName = (String) faultInfo.get(Final.FAULT_HEADER_PROB_HEADER_QNAME);
            if (faultyHeaderQName != null && !"".equals(faultyHeaderQName)) {
                // add to header
                SOAPHeaderBlock faultDetail = envelope.getHeader().addHeaderBlock(Final.FAULT_HEADER_DETAIL, addressingNamespaceObject);
                OMElement probHeaderQName = OMAbstractFactory.getOMFactory().createOMElement(Final.FAULT_HEADER_PROB_HEADER_QNAME, addressingNamespaceObject, faultDetail);
                probHeaderQName.setText(faultyHeaderQName);

                String messageID = (String) faultInfo.get(AddressingConstants.WSA_RELATES_TO);
                if (messageID != null) {
                    SOAPHeaderBlock relatesTo = envelope.getHeader().addHeaderBlock(AddressingConstants.WSA_RELATES_TO, addressingNamespaceObject);
                    relatesTo.setText(messageID);
                }

                // add to header
                SOAPFault fault = envelope.getBody().getFault();
                if (fault != null && fault.getDetail() != null) {
View Full Code Here

            address = epr.getAddress();
            referenceParameters = epr.getAllReferenceParameters();
//            }

            if (!"".equals(address) && address != null) {
                SOAPHeaderBlock toHeaderBlock = envelope.getHeader().addHeaderBlock(WSA_TO, addressingNamespaceObject);
                toHeaderBlock.setText(address);
            }
            processToEPRReferenceInformation(referenceParameters, envelope.getHeader(),addressingNamespaceObject);
        }
    }
View Full Code Here

    private OMElement processStringInfo(String value,
                                        String type,
                                        SOAPEnvelope soapEnvelope, OMNamespace addressingNamespaceObject) {
        if (!"".equals(value) && value != null) {
            SOAPHeaderBlock soapHeaderBlock =
                    soapEnvelope.getHeader().addHeaderBlock(type, addressingNamespaceObject);
            soapHeaderBlock.addChild(
                    OMAbstractFactory.getOMFactory().createText(value));
            return soapHeaderBlock;
        }
        return null;
    }
View Full Code Here

        if (epr == null || isAddressingHeaderAlreadyAvailable(type, envelope, addressingNamespaceObject))
        {
            return;
        }

        SOAPHeaderBlock soapHeaderBlock =
                envelope.getHeader().addHeaderBlock(type, addressingNamespaceObject);

        // add epr address
        String address = epr.getAddress();
        if (!"".equals(address) && address != null) {
            OMElement addressElement = OMAbstractFactory.getOMFactory().createOMElement(EPR_ADDRESS, addressingNamespaceObject, soapHeaderBlock);
            addressElement.setText(address);
        }

        // add reference parameters
        Map referenceParameters = epr.getAllReferenceParameters();
        if (referenceParameters != null) {
            OMElement reference =
                    OMAbstractFactory.getOMFactory().createOMElement(
                            EPR_REFERENCE_PARAMETERS,
                            addressingNamespaceObject, soapHeaderBlock);
            processReferenceInformation(referenceParameters, reference);

        }

        // add xs:any
        ArrayList omElements = epr.getExtensibleElements();
        if (omElements != null) {
            for (int i = 0; i < omElements.size(); i++) {
                soapHeaderBlock.addChild((OMElement) omElements.get(i));
            }
        }

        // add metadata
        ArrayList metaDataList = epr.getMetaData();
        if (metaDataList != null) {
            OMElement metadata =
                    OMAbstractFactory.getOMFactory().createOMElement(
                            Final.WSA_METADATA,
                            addressingNamespaceObject, soapHeaderBlock);
            for (int i = 0; i < metaDataList.size(); i++) {
                metadata.addChild((OMNode) metaDataList.get(i));
            }

        }

        if (epr.getAttributes() != null) {
            Iterator attrIter = epr.getAttributes().iterator();
            while (attrIter.hasNext()) {
                OMAttribute omAttributes = (OMAttribute) attrIter.next();
                soapHeaderBlock.addAttribute(omAttributes);
            }
        }


    }
View Full Code Here

        OMNamespace namespace = findNamespace(ns.getName(), ns.getPrefix());
        if (namespace != null) {
            ns = namespace;
        }

        SOAPHeaderBlock soapHeaderBlock = null;
        try {
            soapHeaderBlock = new SOAP11HeaderBlockImpl(localName, ns, this,
                    (SOAPFactory)this.factory);
        } catch (SOAPProcessingException e) {
            throw new OMException(e);
View Full Code Here

        soapHeader = soapEnvelope.getHeader();
    }

    public void testAddHeaderElement() {
        String newElementName = "MyHeaderElement";
        SOAPHeaderBlock soapHeaderElement = soapHeader.addHeaderBlock(
                newElementName,
                new OMNamespaceImpl("http://opensource.lk", "lsf", soapHeader.getOMFactory()));
        assertTrue(
                "Header Element added has different parent than it should have",
                soapHeaderElement.getParent() == soapHeader);
        assertTrue(
                "Header Element added has different localname than it was given",
                soapHeaderElement.getLocalName().equalsIgnoreCase(
                        newElementName));
    }
View Full Code Here

        OMNamespace namespace = findNamespace(ns.getName(), ns.getPrefix());
        if (namespace != null) {
            ns = namespace;
        }

        SOAPHeaderBlock soapHeaderBlock = null;
        try {
            soapHeaderBlock = new SOAP12HeaderBlockImpl(localName, ns, this,
                    (SOAPFactory) this.factory);
        } catch (SOAPProcessingException e) {
            throw new OMException(e);
View Full Code Here

TOP

Related Classes of org.apache.ws.commons.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.