本文整理了Java中org.apache.axiom.soap.SOAPHeader
类的一些代码示例,展示了SOAPHeader
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SOAPHeader
类的具体详情如下:
包路径:org.apache.axiom.soap.SOAPHeader
类名称:SOAPHeader
[英]Interface SOAPHeader
[中]接口SOAPHeader
代码示例来源:origin: stackoverflow.com
SOAPHeader header = MessageContext.getCurrentMessageContext().getEnvelope().getHeader();
OMElement firstChildWithName = header.getFirstChildWithName(new QName("http://www.w3.org/2005/09/ws-i18n","locale","i18n"));
if (firstChildWithName != null) {
String locale = firstChildWithName.getText();
System.out.println(locale);
if(locale!=null)
language = locale.trim();
else
language="en";
}
代码示例来源:origin: org.apache.axis2/axis2-kernel
/**
* Add all configured headers to a SOAP envelope.
*
* @param envelope the SOAPEnvelope in which to write the headers
*/
public void addHeadersToEnvelope(SOAPEnvelope envelope) {
if (headers != null) {
SOAPHeader soapHeader = envelope.getHeader();
for (Object header : headers) {
soapHeader.addChild((OMElement)header);
}
}
}
代码示例来源:origin: org.apache.sandesha2/sandesha2-core
public void toHeader(SOAPHeader header){
OMElement sequenceFaultElement = header.addHeaderBlock(Sandesha2Constants.WSRM_COMMON.SEQUENCE_FAULT, omNamespace);
if (faultCode != null)
faultCode.toOMElement(sequenceFaultElement);
}
}
代码示例来源:origin: org.apache.tuscany.sca/tuscany-binding-ws-runtime-axis2
/**
* Add wsa:From SOAP header to the message
* @param sh - the SOAP header for the message
* @param fromEPR - the (Axis2) EPR to include in the wsa:From
* @throws AxisFault - if an error occurs setting the wsa:From into the header
*/
private void addWSAFromHeader( SOAPHeader sh, EndpointReference fromEPR ) throws AxisFault {
OMElement epr = EndpointReferenceHelper.toOM(sh.getOMFactory(),
fromEPR,
QNAME_WSA_FROM,
AddressingConstants.Final.WSA_NAMESPACE);
sh.addChild(epr);
} // end method addWSAFromHeader
代码示例来源:origin: org.apache.synapse/synapse-core
private void addCustomHeader(MessageContext synCtx, String value) {
SOAPEnvelope env = synCtx.getEnvelope();
if (env == null) {
return;
}
SOAPFactory fac = (SOAPFactory) env.getOMFactory();
SOAPHeader header = env.getOrCreateHeader();
if (!isImplicit()) {
SOAPHeaderBlock hb = header.addHeaderBlock(qName.getLocalPart(),
fac.createOMNamespace(qName.getNamespaceURI(), qName.getPrefix()));
hb.setText(value);
} else if (hasEmbeddedXml()) {
for (OMElement e : embeddedXmlContent) {
// Don't attach the original OMElement here.
// If another mediator down the line, changes the OM, we are in trouble.
header.addChild(e.cloneOMElement());
}
}
}
代码示例来源:origin: apache/axis2-java
if (replaceHeaders) {
QName qname = new QName(addressingNamespace, name, WSA_DEFAULT_PREFIX);
Iterator<OMElement> iterator = header.getChildrenWithName(qname);
while (iterator.hasNext()) {
iterator.next();
if (exists && replaceHeaders) {
QName qname = new QName(addressingNamespace, name, WSA_DEFAULT_PREFIX);
OMElement addressingHeader = header.getFirstChildWithName(qname);
if (LoggingControl.debugLoggingAllowed && log.isTraceEnabled()) {
log.trace("isAddressingHeaderAlreadyAvailable: Removing existing header:" +
代码示例来源:origin: org.wso2.mercury/mercury-core
soapFactory.createSOAPHeader(this.originalMessage);
this.originalMessage.getHeader().addChild(this.sequence.toSOAPHeaderBlock());
this.isSequenceHeaderAdded = true;
Iterator iter = this.originalMessage.getHeader().getChildrenWithLocalName(
MercuryConstants.SEQUENCE_ACKNOWLEDGMENT);
for (; iter.hasNext();) {
this.originalMessage.getHeader().addChild(sequenceAcknowledgment.toSOAPHeaderBlock());
for (Iterator iter = this.originalMessage.getHeader().getChildElements(); iter.hasNext();){
soapHeaderBlock = (SOAPHeaderBlock) iter.next();
if (soapHeaderBlock.getLocalName().equals(AddressingConstants.WSA_RELATES_TO)){
代码示例来源:origin: org.apache.rampart/rampart-core
if (part.getName() == null) {
ArrayList headerList = header.getHeaderBlocksWithNSURI(part.getNamespace());
OMElement e = header.getFirstChildWithName(shb.getQName());
OMElement e = header.getFirstChildWithName(new QName(part.getNamespace(), part.getName()));
if (e != null) {
if (!found.contains(e)) {
代码示例来源:origin: org.apache.axis2/axis2-saaj
/**
* Returns an <code>Iterator</code> over all the <code>SOAPHeaderElement</code> objects in this
* <code>SOAPHeader</code> object.
*
* @return an <code>Iterator</code> object over all the <code>SOAPHeaderElement</code> objects
* contained by this <code>SOAPHeader</code>
*/
public Iterator examineAllHeaderElements() {
Collection elements = new ArrayList();
for (Iterator iterator = omTarget.examineAllHeaderBlocks(); iterator.hasNext();) {
elements.add(toSAAJNode((org.w3c.dom.Node)iterator.next()));
}
return elements.iterator();
}
代码示例来源:origin: stackoverflow.com
SOAPHeader header = env.getHeader();
OMChildrenQNameIterator childrenWithName = (OMChildrenQNameIterator) header.getChildrenWithName(omElementauthentication.getQName());
while (childrenWithName.hasNext()) {
org.apache.axiom.om.OMElement omElement = (org.apache.axiom.om.OMElement) childrenWithName.next();
QName mustAnderstandQName = omElement.resolveQName("soapenv:mustUnderstand");
if (mustAnderstandQName == null) {
continue;
}
OMAttribute mustAnderstandAttribute = omElement.getAttribute(mustAnderstandQName);
if (mustAnderstandAttribute == null) {
continue;
}
omElement.removeAttribute(mustAnderstandAttribute);
}
代码示例来源:origin: org.apache.axis2/axis2-saaj
public InvocationResponse invoke(MessageContext msgContext) throws AxisFault {
if (msgContext == null) {
return InvocationResponse.CONTINUE;
}
SOAPEnvelope envelope = msgContext.getEnvelope();
if (envelope.getHeader() == null) {
return InvocationResponse.CONTINUE;
}
// Passing in null will get headers targeted for NEXT and ULTIMATE RECEIVER
Iterator headerBlocks = envelope.getHeader().getHeadersToProcess(null);
while (headerBlocks.hasNext()) {
SOAPHeaderBlock headerBlock = (SOAPHeaderBlock) headerBlocks.next();
headerBlock.setProcessed();
}
return InvocationResponse.CONTINUE;
}
代码示例来源:origin: apache/axis2-java
private void extractToEprReferenceParameters(EndpointReference toEPR, SOAPHeader header,
String namespace) {
if (Final.WSA_NAMESPACE.equals(namespace)) {
Iterator headerBlocks = header.getChildElements();
while (headerBlocks.hasNext()) {
OMElement headerElement = (OMElement)headerBlocks.next();
OMAttribute isRefParamAttr =
headerElement.getAttribute(new QName(namespace, "IsReferenceParameter"));
if (LoggingControl.debugLoggingAllowed && log.isTraceEnabled()) {
log.trace("extractToEprReferenceParameters: Checking header: " +
headerElement.getQName());
}
if (isRefParamAttr != null && "true".equals(isRefParamAttr.getAttributeValue())) {
toEPR.addReferenceParameter(headerElement);
if (LoggingControl.debugLoggingAllowed && log.isTraceEnabled()) {
log.trace("extractToEprReferenceParameters: Header: " +
headerElement.getQName() +
" has IsReferenceParameter attribute. Adding to toEPR.");
}
}
}
}
else {
// there is no exact way to identify ref parameters for Submission version. So let's have a handler
// at the end of the flow, which puts all the handlers (which are of course mustUnderstand=false)
// as reference parameters
// TODO : Chinthaka
}
}
代码示例来源:origin: org.springframework.ws/org.springframework.ws
public SoapHeaderElement addNotUnderstoodHeaderElement(QName headerName) {
try {
SOAPHeaderBlock notUnderstood =
getAxiomHeader().addHeaderBlock("NotUnderstood", getAxiomHeader().getNamespace());
OMNamespace headerNamespace =
notUnderstood.declareNamespace(headerName.getNamespaceURI(), QNameUtils.getPrefix(headerName));
notUnderstood.addAttribute("qname", headerNamespace.getPrefix() + ":" + headerName.getLocalPart(), null);
return new AxiomSoapHeaderElement(notUnderstood, getAxiomFactory());
}
catch (SOAPProcessingException ex) {
throw new AxiomSoapHeaderException(ex);
}
}
代码示例来源:origin: apache/axis2-java
/**
* Sets a mustUnderstand attribute on all headers that are found with the appropriate
* addressing namespace.
*/
private void processMustUnderstandProperty() {
if (addMustUnderstandAttribute) {
List headers = header.getHeaderBlocksWithNSURI(addressingNamespace);
for (int i = 0, size = headers.size(); i < size; i++) {
SOAPHeaderBlock soapHeaderBlock = (SOAPHeaderBlock)headers.get(i);
soapHeaderBlock.setMustUnderstand(true);
if (LoggingControl.debugLoggingAllowed && log.isTraceEnabled()) {
log.trace(
"processMustUnderstandProperty: Setting mustUnderstand=true on: " +
soapHeaderBlock.getLocalName());
}
}
}
}
代码示例来源:origin: org.wso2.mercury/mercury-core
public static LastMessage fromSOAPEnvelope(SOAPEnvelope soapEnvelope) throws RMMessageBuildingException {
String soapNamespace = soapEnvelope.getNamespace().getNamespaceURI();
Iterator childElements = soapEnvelope.getHeader().getChildElements();
SOAPHeaderBlock headerBlock;
LastMessage lastMessage = null;
for (; childElements.hasNext();) {
headerBlock = (SOAPHeaderBlock) childElements.next();
if (headerBlock.getLocalName().equals(MercuryConstants.SEQUENCE)) {
String rmNamespace = headerBlock.getNamespace().getNamespaceURI();
lastMessage = new LastMessage(rmNamespace, soapNamespace);
lastMessage.setSequence(Sequence.fromSOAPHeaderBlock(headerBlock));
}
}
Iterator iter = soapEnvelope.getHeader().getChildrenWithLocalName(MercuryConstants.SEQUENCE_ACKNOWLEDGMENT);
for (; iter.hasNext();) {
SOAPHeaderBlock sequenceAcknowledgmentHeaderBlock = (SOAPHeaderBlock) iter.next();
if (sequenceAcknowledgmentHeaderBlock.getLocalName().equals(
MercuryConstants.SEQUENCE_ACKNOWLEDGMENT)) {
SequenceAcknowledgment sequenceAcknowledgment =
SequenceAcknowledgment.fromSOAPHeaderBlock(sequenceAcknowledgmentHeaderBlock);
lastMessage.setSequenceAcknowledgment(sequenceAcknowledgment);
break;
}
}
return lastMessage;
}
代码示例来源:origin: org.apache.tuscany.sca/tuscany-binding-ws-runtime-axis2
/**
* Add wsa:MessageID SOAP header to the message
* @param sh - the SOAP header for the message
* @param msgID - the message ID
* @throws AxisFault - if an error occurs setting the wsa:From into the header
*/
private void addWSAMessageIDHeader( SOAPHeader sh, String msgID ) throws AxisFault {
if( msgID == null ) return;
OMElement idHeader = sh.getOMFactory().createOMElement(QNAME_WSA_MESSAGEID);
idHeader.setText( msgID );
sh.addChild(idHeader);
} // end method addWSAMessageIDHeader
代码示例来源:origin: apache/axis2-java
/**
* Returns an <code>Iterator</code> over all the <code>SOAPHeaderElement</code> objects in this
* <code>SOAPHeader</code> object.
*
* @return an <code>Iterator</code> object over all the <code>SOAPHeaderElement</code> objects
* contained by this <code>SOAPHeader</code>
*/
public Iterator examineAllHeaderElements() {
Collection elements = new ArrayList();
for (Iterator iterator = omTarget.examineAllHeaderBlocks(); iterator.hasNext();) {
elements.add(toSAAJNode((org.w3c.dom.Node)iterator.next()));
}
return elements.iterator();
}
代码示例来源:origin: org.apache.airavata/airavata-message-broker
private void extractInfoFromHeader(ProcessingContext context, SOAPHeader header) {
Iterator ite = header.getChildrenWithName(new QName(NameSpaceConstants.WSNT_NS.getNamespaceURI(),
WsmgCommonConstants.SUBSCRIPTION_ID));
if (ite.hasNext()) {
OMElement identifier = (OMElement) ite.next();
logger.debug("extracted identifier " + identifier.getText());
context.setContextParameter(ContextParameters.SUB_ID, identifier.getText());
}
}
}
代码示例来源:origin: org.springframework.ws/org.springframework.ws
@SuppressWarnings("unchecked")
public Iterator<SoapHeaderElement> examineHeaderElementsToProcess(final String[] roles, final boolean isUltimateDestination)
throws SoapHeaderException {
RolePlayer rolePlayer = null;
if (!ObjectUtils.isEmpty(roles)) {
rolePlayer = new RolePlayer() {
public List<?> getRoles() {
return Arrays.asList(roles);
}
public boolean isUltimateDestination() {
return isUltimateDestination;
}
};
}
Iterator<SOAPHeaderBlock> result = (Iterator<SOAPHeaderBlock>)getAxiomHeader().getHeadersToProcess(rolePlayer);
return new AxiomSoapHeaderElementIterator(result);
}
}
代码示例来源:origin: org.apache.rampart/rampart-core
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;
}
内容来源于网络,如有侵权,请联系作者删除!