public SOAPHeaderBlock toSOAPHeaderBlock() throws RMMessageBuildingException { SOAPFactory soapFactory = getSoapFactory(); OMNamespace omNamespace = soapFactory.createOMNamespace( MercuryConstants.RM_1_0_NAMESPACE, MercuryConstants.RM_1_0_NAMESPACE_PREFIX); SOAPHeaderBlock sequenceAcknowledgment = soapFactory.createSOAPHeaderBlock(MercuryConstants.SEQUENCE_ACKNOWLEDGMENT, omNamespace); OMElement identifierElement = soapFactory.createOMElement( MercuryConstants.IDENTIFIER, this.rmNamespace, MercuryConstants.RM_1_0_NAMESPACE_PREFIX); identifierElement.setText(this.identifier); sequenceAcknowledgment.addChild(identifierElement); AcknowledgmentRange acknowledgmentRange = null; for (Iterator iter = this.acknowledgmentRanges.iterator(); iter.hasNext();) { acknowledgmentRange = (AcknowledgmentRange) iter.next(); sequenceAcknowledgment.addChild(acknowledgmentRange.toOM()); } return sequenceAcknowledgment; }
private OMElement createSOAPHeaderBlock(String value, String headerName, ArrayList<OMAttribute> attributes) { if (LoggingControl.debugLoggingAllowed && log.isTraceEnabled()) { log.trace("createSOAPHeaderBlock: value=" + value + " headerName=" + headerName); } if (value != null && value.length()!=0) { SOAPHeaderBlock soapHeaderBlock = header.addHeaderBlock(headerName, addressingNamespaceObject); soapHeaderBlock.addChild(factory.createOMText(value)); if (attributes != null && !attributes.isEmpty()) { Iterator<OMAttribute> attrIterator = attributes.iterator(); while (attrIterator.hasNext()) { soapHeaderBlock.addAttribute( (OMAttribute)soapHeaderBlock.getOMFactory().importInformationItem(attrIterator.next())); } } addRoleToHeader(soapHeaderBlock); return soapHeaderBlock; } return null; }
switch (childNodes.item(i).getNodeType()) { case Node.CDATA_SECTION_NODE: hb.addChild(soapFactory.createOMText(node.getTextContent(), XMLStreamConstants.CDATA)); break; case Node.TEXT_NODE: hb.addChild(soapFactory.createOMText(node.getTextContent(), XMLStreamConstants.CHARACTERS)); break; case Node.ELEMENT_NODE:
public SOAPHeaderBlock toSOAPHeaderBlock() throws RMMessageBuildingException { SOAPFactory soapFactory = getSoapFactory(); OMNamespace rmNamespace = soapFactory.createOMNamespace( MercuryConstants.RM_1_0_NAMESPACE, MercuryConstants.RM_1_0_NAMESPACE_PREFIX); SOAPHeaderBlock sequenceHeaderBolck = soapFactory.createSOAPHeaderBlock(MercuryConstants.SEQUENCE, rmNamespace); OMElement identifierElement = soapFactory.createOMElement( MercuryConstants.IDENTIFIER, this.rmNamespace, MercuryConstants.RM_1_0_NAMESPACE_PREFIX); identifierElement.setText(this.sequenceID); sequenceHeaderBolck.addChild(identifierElement); OMElement messageNumberElement = soapFactory.createOMElement( MercuryConstants.MESSAGE_NUMBER, this.rmNamespace, MercuryConstants.RM_1_0_NAMESPACE_PREFIX); messageNumberElement.setText(String.valueOf(this.messageNumber)); sequenceHeaderBolck.addChild(messageNumberElement); if (this.isLastMessage) { OMElement lastMessageElement = soapFactory.createOMElement( MercuryConstants.LAST_MESSAGE, this.rmNamespace, MercuryConstants.RM_1_0_NAMESPACE_PREFIX); sequenceHeaderBolck.addChild(lastMessageElement); } return sequenceHeaderBolck; }
protected void addHeader(OMElement omElementToadd, SOAPEnvelope envelop, boolean mustUnderstand){ SOAPHeaderBlock soapHeaderBlock = envelop.getHeader().addHeaderBlock(omElementToadd.getLocalName(),omElementToadd.getNamespace()); soapHeaderBlock.setMustUnderstand(mustUnderstand); OMNode omNode = null; // add child elements for (Iterator iter = omElementToadd.getChildren(); iter.hasNext();){ omNode = (OMNode) iter.next(); iter.remove(); soapHeaderBlock.addChild(omNode); } OMAttribute omatribute = null; // add attributes for (Iterator iter = omElementToadd.getAllAttributes(); iter.hasNext();){ omatribute = (OMAttribute) iter.next(); soapHeaderBlock.addAttribute(omatribute); } }
protected void addHeader(OMElement omElementToadd, SOAPEnvelope envelop, boolean mustUnderstand){ SOAPHeaderBlock soapHeaderBlock = envelop.getHeader().addHeaderBlock(omElementToadd.getLocalName(),omElementToadd.getNamespace()); soapHeaderBlock.setMustUnderstand(mustUnderstand); OMNode omNode = null; // add child elements for (Iterator iter = omElementToadd.getChildren(); iter.hasNext();){ omNode = (OMNode) iter.next(); iter.remove(); soapHeaderBlock.addChild(omNode); } OMAttribute omatribute = null; // add attributes for (Iterator iter = omElementToadd.getAllAttributes(); iter.hasNext();){ omatribute = (OMAttribute) iter.next(); soapHeaderBlock.addAttribute(omatribute); } }
public void toHeader(SOAPHeader header){ if (identifier == null) throw new OMException(SandeshaMessageHelper.getMessage( SandeshaMessageKeys.nullMsgId)); if (messageNumber <= 0 ){ throw new OMException(SandeshaMessageHelper.getMessage( SandeshaMessageKeys.setAValidMsgNumber, Long.toString(messageNumber))); } SOAPHeaderBlock sequenceHeaderBlock = header.addHeaderBlock( Sandesha2Constants.WSRM_COMMON.SEQUENCE, omNamespace); // Always set the MustUnderstand to true for Sequence messages sequenceHeaderBlock.setMustUnderstand(true); identifier.toOMElement(sequenceHeaderBlock, omNamespace); OMElement messageNoElement = sequenceHeaderBlock.getOMFactory().createOMElement(Sandesha2Constants.WSRM_COMMON.MSG_NUMBER,omNamespace); messageNoElement.setText(Long.toString(messageNumber)); sequenceHeaderBlock.addChild(messageNoElement); if (lastMessage){ OMElement lastMessageElement = sequenceHeaderBlock.getOMFactory().createOMElement(Sandesha2Constants.WSRM_COMMON.LAST_MSG, omNamespace); sequenceHeaderBlock.addChild(lastMessageElement); } } }
/** * Creates a new Upgrade SOAPHeaderElement object initialized with the specified List of * supported SOAP URIs and adds it to this SOAPHeader object. This operation is supported on * both SOAP 1.1 and SOAP 1.2 header. * * @param supportedSOAPURIs - an Iterator object with the URIs of SOAP versions supported. * @return the new SOAPHeaderElement object that was inserted into this SOAPHeader object * @throws SOAPException - if a SOAP error occurs. */ public SOAPHeaderElement addUpgradeHeaderElement(Iterator iterator) throws SOAPException { SOAPHeaderBlock upgrade = this.omTarget.addHeaderBlock( Constants.ELEM_UPGRADE, this.omTarget.getNamespace()); int index = 0; String prefix = "ns"; while (iterator.hasNext()) { index++; String supported = (String)iterator.next(); OMNamespace namespace = omTarget.getOMFactory().createOMNamespace(supported, prefix + index); OMElement supportedEnvelop = omTarget.getOMFactory().createOMElement(Constants.ELEM_SUPPORTEDENVELOPE, namespace); supportedEnvelop.addAttribute(Constants.ATTR_QNAME, prefix + index + ":" + Constants.ELEM_ENVELOPE, null); upgrade.addChild(supportedEnvelop); } SOAPHeaderElementImpl soapHeaderElementImpl = new SOAPHeaderElementImpl(upgrade); return soapHeaderElementImpl; }
omNode = (OMNode) iter.next(); iter.remove(); soapHeaderBlock.addChild(omNode);
if (securityHeader != null) { while (securityHeader.getChildElements().hasNext()) { soapBloackingHeader.addChild((OMNode) securityHeader.getChildElements().next());
/** * Creates a new Upgrade SOAPHeaderElement object initialized with the specified List of * supported SOAP URIs and adds it to this SOAPHeader object. This operation is supported on * both SOAP 1.1 and SOAP 1.2 header. * * @param supportedSOAPURIs - an Iterator object with the URIs of SOAP versions supported. * @return the new SOAPHeaderElement object that was inserted into this SOAPHeader object * @throws SOAPException - if a SOAP error occurs. */ public SOAPHeaderElement addUpgradeHeaderElement(Iterator iterator) throws SOAPException { SOAPHeaderBlock upgrade = this.omTarget.addHeaderBlock( Constants.ELEM_UPGRADE, this.omTarget.getNamespace()); int index = 0; String prefix = "ns"; while (iterator.hasNext()) { index++; String supported = (String)iterator.next(); OMNamespace namespace = omTarget.getOMFactory().createOMNamespace(supported, prefix + index); OMElement supportedEnvelop = omTarget.getOMFactory().createOMElement(Constants.ELEM_SUPPORTEDENVELOPE, namespace); supportedEnvelop.addAttribute(Constants.ATTR_QNAME, prefix + index + ":" + Constants.ELEM_ENVELOPE, null); upgrade.addChild(supportedEnvelop); } SOAPHeaderElementImpl soapHeaderElementImpl = new SOAPHeaderElementImpl(upgrade); return soapHeaderElementImpl; }
OMNode child = (OMNode)children.next(); children.remove(); header.addChild(child);
hb.addChild((OMNode) elements.next());
/** * Add a new SOAP header to the message. * * @param mustUnderstand the value for the <code>soapenv:mustUnderstand</code> attribute * @param content the XML for the new header * @throws ScriptException if an error occurs when converting the XML to OM */ public void addHeader(boolean mustUnderstand, Object content) throws ScriptException { SOAPHeader header = mc.getEnvelope().getOrCreateHeader(); 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; } }
OMNode node = (OMNode) itrChildren.next(); itrChildren.remove(); newSOAPHeader.addChild(node);
OMNode node = (OMNode) itrChildren.next(); itrChildren.remove(); newSOAPHeader.addChild(node);
/** * Add a new SOAP header to the message. * * @param mustUnderstand the value for the <code>soapenv:mustUnderstand</code> attribute * @param content the XML for the new header * @throws ScriptException if an error occurs when converting the XML to OM */ public void addHeader(boolean mustUnderstand, Object content) throws ScriptException { SOAPEnvelope envelope = mc.getEnvelope(); SOAPFactory factory = (SOAPFactory) envelope.getOMFactory(); SOAPHeader header = envelope.getHeader(); if (header == null) { 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; } }
private void processFaultsInfoIfPresent() { OMElement detailElement = AddressingFaultsHelper .getDetailElementForAddressingFault(messageContext, addressingNamespaceObject); if (detailElement != null) { //The difference between SOAP 1.1 and SOAP 1.2 fault messages is explained in the WS-Addressing Specs. if (isFinalAddressingNamespace && messageContext.isSOAP11()) { // Add detail as a wsa:FaultDetail header if (!isAddressingHeaderAlreadyAvailable(Final.FAULT_HEADER_DETAIL, false)) { SOAPHeaderBlock faultDetail = header.addHeaderBlock( Final.FAULT_HEADER_DETAIL, addressingNamespaceObject); faultDetail.addChild((OMElement)factory.importInformationItem(detailElement)); } } else if (!messageContext.isSOAP11()) { // Add detail to the Fault in the SOAP Body SOAPFault fault = envelope.getBody().getFault(); if (fault != null && fault.getDetail() != null) { fault.getDetail().addDetailEntry( (OMElement)factory.importInformationItem(detailElement)); } } } }
headerBlock.addChild(child); child = next;