@Override public void setText(String content) { getAxiomHeaderBlock().setText(content); }
public void toHeader(SOAPHeader header){ SOAPHeaderBlock headerBlock = header.addHeaderBlock(Sandesha2Constants.WSRM_COMMON.MESSAGE_PENDING,Sandesha2Constants.SPEC_2007_02.OM_MC_NS_URI); headerBlock.addAttribute(Sandesha2Constants.WSRM_COMMON.PENDING, Boolean.valueOf (pending).toString(), null); } }
/** * Returns whether the mustUnderstand attribute for this <CODE>SOAPHeaderElement</CODE> object * is turned on. * * @return <CODE>true</CODE> if the mustUnderstand attribute of this * <CODE>SOAPHeaderElement</CODE> object is turned on; <CODE>false</CODE> otherwise */ public boolean getMustUnderstand() { return this.omTarget.getMustUnderstand(); }
public String getRole() { if (((SOAPFactory)this.omTarget.getOMFactory()).getSOAPVersion() == SOAPVersion.SOAP11) { throw new UnsupportedOperationException(); } else { return this.omTarget.getRole(); } }
public Object fromHeaderBlock(SOAPHeaderBlock messagePendingElement) throws OMException, SandeshaException { String value = messagePendingElement.getAttributeValue(new QName (Sandesha2Constants.WSRM_COMMON.PENDING)); if (Constants.VALUE_TRUE.equals(value)) pending = true; else if (Constants.VALUE_FALSE.equals(value)) pending = false; else { String message = "Attribute 'pending' must have value 'true' or 'false'. Value was:"+value; throw new SandeshaException (message); } // Mark this element as processed messagePendingElement.setProcessed(); return messagePendingElement; }
public Object fromHeaderBlock(SOAPHeaderBlock ackReqElement) throws OMException,SandeshaException { originalAckRequestedElement = ackReqElement; identifier = new Identifier(namespaceValue); OMElement identifierPart = ackReqElement.getFirstChildWithName(new QName( namespaceValue, Sandesha2Constants.WSRM_COMMON.IDENTIFIER)); if(identifierPart != null){ identifier.fromOMElement(identifierPart); } // Indicate that we have processed this SOAPHeaderBlock ackReqElement.setProcessed(); return this; }
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); } }
while (headerBlocks.hasNext()) { SOAPHeaderBlock headerBlock = (SOAPHeaderBlock) headerBlocks.next(); QName headerName = headerBlock.getQName(); if (headerBlock.isProcessed() || !headerBlock.getMustUnderstand()) { continue; QName faultQName = headerBlock.getVersion().getMustUnderstandFaultCode(); throw new AxisFault(Messages.getMessage("mustunderstandfailed", headerBlock.getNamespace().getNamespaceURI(), headerBlock.getLocalName()), faultQName);
final QName hbQName = hb.getQName(); final SOAPHeaderElement headerEle = header.addHeaderElement(env.createName(hbQName .getLocalPart(), hbQName.getPrefix(), hbQName.getNamespaceURI())); for (Iterator attribIter = hb.getAllAttributes(); attribIter.hasNext();) { OMAttribute attr = (OMAttribute)attribIter.next(); final QName attrQName = attr.getQName(); .getPrefix(), attrQName.getNamespaceURI()), attr.getAttributeValue()); final String role = hb.getRole(); if (role != null) { headerEle.setActor(role); headerEle.setMustUnderstand(hb.getMustUnderstand());
/** * Remove the MustUnderstand header blocks. * @param envelope */ public static SOAPEnvelope removeMustUnderstand(SOAPEnvelope envelope) { if (LoggingControl.isAnyTracingEnabled() && log.isDebugEnabled()) log.debug("Enter: SandeshaUtil::removeMustUnderstand"); // you have to explicitely set the 'processed' attribute for header // blocks, since it get lost in the above read from the stream. SOAPHeader header = envelope.getHeader(); if (header != null) { Iterator childrenOfOldEnv = header.getChildElements(); while (childrenOfOldEnv.hasNext()) { SOAPHeaderBlock oldEnvHeaderBlock = (SOAPHeaderBlock) childrenOfOldEnv.next(); QName oldEnvHeaderBlockQName = oldEnvHeaderBlock.getQName(); if (oldEnvHeaderBlockQName != null) { // If we've processed the part and it has a must understand, set it as processed if (oldEnvHeaderBlock.isProcessed() && oldEnvHeaderBlock.getMustUnderstand()) { // Remove the MustUnderstand part oldEnvHeaderBlock.setMustUnderstand(false); } } } } if (LoggingControl.isAnyTracingEnabled() && log.isDebugEnabled()) log.debug("Exit: SandeshaUtil::removeMustUnderstand"); return envelope; }
public boolean checkHeader(SOAPHeaderBlock header) { OMNamespace headerNamespace = header.getNamespace(); if (headerNamespace == null || !namespace.equals(headerNamespace.getNamespaceURI())) { return false; String role = header.getRole(); SOAPVersion version = header.getVersion();
public InvocationResponse invoke(MessageContext messageContext) throws AxisFault { SOAPEnvelope envelope = messageContext.getEnvelope(); 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); } return InvocationResponse.CONTINUE; } }
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; }
public static Sequence fromSOAPHeaderBlock(SOAPHeaderBlock soapHeaderBlock) { soapHeaderBlock.setProcessed(); String soapNamespace = soapHeaderBlock.getQName().getNamespaceURI(); Sequence sequence = new Sequence(); sequence.setSoapNamesapce(soapNamespace); String rmNamesapce = soapHeaderBlock.getNamespace().getNamespaceURI(); sequence.setRmNamespace(rmNamesapce); soapHeaderBlock.setProcessed(); if (soapHeaderBlock.getNamespace().getNamespaceURI().equals(MercuryConstants.RM_1_0_NAMESPACE)) { // we have found the sequence header block. Iterator sequenceElementIter = soapHeaderBlock.getChildElements(); OMElement childElement; for (; sequenceElementIter.hasNext();) { childElement = (OMElement) sequenceElementIter.next(); if (childElement.getLocalName().equals(MercuryConstants.IDENTIFIER)) { sequence.setSequenceID(childElement.getText()); } else if (childElement.getLocalName().equals(MercuryConstants.MESSAGE_NUMBER)) { sequence.setMessageNumber(Long.parseLong(childElement.getText())); } else if (childElement.getLocalName().equals(MercuryConstants.LAST_MESSAGE)) { sequence.setLastMessage(true); } } } return sequence; }
@Override public SoapHeaderElement addNotUnderstoodHeaderElement(QName headerName) { try { SOAPHeaderBlock notUnderstood = getAxiomHeader().addHeaderBlock("NotUnderstood", getAxiomHeader().getNamespace()); OMNamespace headerNamespace = notUnderstood.declareNamespace(headerName.getNamespaceURI(), headerName.getPrefix()); notUnderstood.addAttribute("qname", headerNamespace.getPrefix() + ":" + headerName.getLocalPart(), null); return new AxiomSoapHeaderElement(notUnderstood, getAxiomFactory()); } catch (SOAPProcessingException ex) { throw new AxiomSoapHeaderException(ex); } }
/** * Returns the uri of the actor associated with this <CODE> SOAPHeaderElement</CODE> object. * * @return a <CODE>String</CODE> giving the URI of the actor * @see #setActor(String) setActor(java.lang.String) */ public String getActor() { return this.omTarget.getRole(); }
private SOAPHeaderBlock getSecurityHeader(MessageContext msgContext) throws AxisFault { SOAPHeader header = null; try { header = msgContext.getEnvelope().getHeader(); } catch (OMException ex) { throw new AxisFault( "PostDispatchVerificationHandler: cannot get SOAP header after security processing", ex); } if(header == null) { return null; } Iterator headers = header.getChildElements(); SOAPHeaderBlock headerBlock = null; while (headers.hasNext()) { // Find the wsse header SOAPHeaderBlock hb = (SOAPHeaderBlock) headers.next(); if (hb.getLocalName().equals(WSConstants.WSSE_LN) && hb.getNamespace().getNamespaceURI().equals(WSConstants.WSSE_NS)) { headerBlock = hb; break; } } return headerBlock; }
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); } } }
private void performTestForCloneEnvelope(SOAPFactory soapFactory, SOAPHeaderBlock header, OMElement childNode) { SOAPEnvelope tempEnvelope = soapFactory.getDefaultEnvelope(); //adding a text value header.setText("my custom header"); //adding an attribute header.addAttribute("name", "value", null); tempEnvelope.getHeader().addChild(header); tempEnvelope.getBody().addChild(childNode); SOAPEnvelope clonedEnvelope= MessageHelper.cloneSOAPEnvelope(tempEnvelope); assertEquals(tempEnvelope.toString(),clonedEnvelope.toString()); } }
if(headerBlock.getMustUnderstand()){ headerBlock.setProcessed();