本文整理了Java中org.apache.axiom.soap.SOAPHeader.addChild()
方法的一些代码示例,展示了SOAPHeader.addChild()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SOAPHeader.addChild()
方法的具体详情如下:
包路径:org.apache.axiom.soap.SOAPHeader
类名称:SOAPHeader
方法名:addChild
暂无
代码示例来源: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: apache/axis2-java
/**
* 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.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: 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.ow2.petals/petals-bc-soap
/**
* Create a SOAPHeader from a source
*
* @param factory
* @param envelope
* @param protocolHeadersProperty
*/
private static void createSOAPHeader(final SOAPFactory factory, final SOAPEnvelope envelope,
final Map<String, DocumentFragment> protocolHeadersProperty, final Logger logger) {
if (protocolHeadersProperty != null) {
final SOAPHeader header = factory.createSOAPHeader(envelope);
for (final DocumentFragment docfrag : protocolHeadersProperty.values()) {
final Node node = docfrag.getFirstChild();
if (node instanceof Element) {
try {
header.addChild(XMLUtils.toOM((Element) node));
} catch (final Exception e) {
logger.log(Level.WARNING,
"Error parsing the response from JBI service to a SOAPHeader, skipping it", e);
}
}
}
}
}
代码示例来源:origin: org.wso2.mercury/mercury-core
public SOAPEnvelope toSOAPEnvelope() throws RMMessageBuildingException {
SOAPFactory soapFactory = getSoapFactory();
SOAPEnvelope soapEnvelope = soapFactory.getDefaultEnvelope();
if (this.sequenceAcknowledgment != null){
soapEnvelope.getHeader().addChild(this.sequenceAcknowledgment.toSOAPHeaderBlock());
}
soapEnvelope.getHeader().addChild(this.sequence.toSOAPHeaderBlock());
return soapEnvelope;
}
代码示例来源:origin: wso2/wso2-synapse
private void addHeaderChildrenToMessageContext(MessageContext synCtx, List<OMElement> headerElements) {
// Convert SOAP Header Blocks to support WS-Addressing
SOAPFactory factory;
if (SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(
synCtx.getEnvelope().getBody().getNamespace().getNamespaceURI())) {
factory = OMAbstractFactory.getSOAP11Factory();
} else {
factory = OMAbstractFactory.getSOAP12Factory();
}
for (OMElement headerElement : headerElements) {
try {
synCtx.getEnvelope().getHeader().addChild(ElementHelper.toSOAPHeaderBlock(headerElement, factory));
} catch (Exception e) {
log.error("Unable to convert to SoapHeader Block", e);
}
}
}
代码示例来源:origin: org.wso2.mercury/mercury-core
public SOAPEnvelope toSOAPEnvelope() throws RMMessageBuildingException {
SOAPFactory soapFactory = getSoapFactory();
SOAPEnvelope soapEnvelope = soapFactory.getDefaultEnvelope();
soapEnvelope.getHeader().addChild(sequenceAcknowledgment.toSOAPHeaderBlock());
return soapEnvelope;
}
代码示例来源:origin: org.apache.tuscany.sca/tuscany-binding-ws-runtime-axis2
/**
* Adds a wsa:RelatesTo SOAP header if the incoming invocation had a wsa:MessageID SOAP header present
* - note that OASIS SCA requires that the RelationshipType attribute is set to a particular SCA value
* @param sh - the SOAP headers
* @param msg - the message
*/
private void addWSARelatesTo( SOAPHeader sh, Message msg ) {
String idValue = (String) msg.getHeaders().get("RELATES_TO");
if( idValue != null ){
OMElement relatesToOM = sh.getOMFactory().createOMElement( QNAME_WSA_RELATESTO );
OMAttribute relType = sh.getOMFactory().createOMAttribute("RelationshipType", null, SCA_CALLBACK_REL);
relatesToOM.addAttribute( relType );
relatesToOM.setText( idValue );
sh.addChild( relatesToOM );
}
} // end method addWSARelatesTo
代码示例来源: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: org.apache.tuscany.sca/tuscany-binding-ws-runtime-axis2
private void addWSAActionHeader( SOAPHeader sh ) {
// Create wsa:Action header which is required by ws-addressing spec
String action = options.getAction();
if (action == null) {
PortType portType = ((WSDLInterface)wsBinding.getBindingInterfaceContract().getInterface()).getPortType();
Operation op = portType.getOperation(wsdlOperationName.getLocalPart(), null, null);
action = WSDL11ActionHelper.getActionFromInputElement(wsBinding.getGeneratedWSDLDocument(), portType, op, op.getInput());
}
OMElement actionOM = sh.getOMFactory().createOMElement(QNAME_WSA_ACTION);
actionOM.setText(action == null ? "" : action);
sh.addChild(actionOM);
} // end method addWSAActionHeader
代码示例来源:origin: org.wso2.mercury/mercury-core
public SOAPEnvelope toSOAPEnvelope() throws RMMessageBuildingException {
SOAPFactory soapFactory = getSoapFactory();
SOAPEnvelope soapEnvelope = soapFactory.getDefaultEnvelope();
OMElement terminateSequenceElement = soapFactory.createOMElement(MercuryConstants.TERMINATE_SEQUENCE,
this.rmNamespace,
MercuryConstants.RM_1_0_NAMESPACE_PREFIX);
OMElement identifierElement = soapFactory.createOMElement(MercuryConstants.IDENTIFIER,
this.rmNamespace,
MercuryConstants.RM_1_0_NAMESPACE_PREFIX);
identifierElement.setText(identifier);
terminateSequenceElement.addChild(identifierElement);
soapEnvelope.getBody().addChild(terminateSequenceElement);
// this is an terminate message for annonymous inout operation
if (sequenceAcknowledgment != null){
soapEnvelope.getHeader().addChild(sequenceAcknowledgment.toSOAPHeaderBlock());
}
return soapEnvelope;
}
代码示例来源:origin: org.wso2.esb.integration/integration-base
/**
* Method to create a SOAP Envelope by evaluating and separating SOAP Header and SOAP Body from an
* OMElement.
*
* @param request The request to add as a SOAP envelope.
* @param xpathHeaderExp XPath expression to evaluate the SOAP header.
* @param xpathBodyExp XPath expression to evaluate the SOAP body.
* @return the built SOAPEnvelope
* @throws JaxenException Thrown on failure to evaluate XPath expression.
*/
private SOAPEnvelope createSOAPEnvelope(final OMElement request, final String xpathHeaderExp,
final String xpathBodyExp) throws JaxenException {
AXIOMXPath xpathHeader = new AXIOMXPath(request, xpathHeaderExp);
AXIOMXPath xpathBody = new AXIOMXPath(request, xpathBodyExp);
@SuppressWarnings("unchecked")
List<OMElement> headerOMElements = xpathHeader.selectNodes(request);
@SuppressWarnings("unchecked")
List<OMElement> bodyOMElements = xpathBody.selectNodes(request);
SOAPFactory soapFactory = OMAbstractFactory.getSOAP11Factory();
SOAPEnvelope soapEnvelope = soapFactory.getDefaultEnvelope();
for (OMElement omElement : headerOMElements) {
soapEnvelope.getHeader().addChild(omElement);
}
for (OMElement omElement : bodyOMElements) {
soapEnvelope.getBody().addChild(omElement);
}
return soapEnvelope;
}
代码示例来源:origin: wso2/wso2-synapse
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());
}
}
代码示例来源:origin: wso2-attic/esb-connectors
soapEnvelope.getHeader().addChild(omElement);
代码示例来源:origin: org.wso2.carbon.commons/org.wso2.carbon.event.ws
public static MessageContext createMessageContext(OMElement payload,
OMElement topic,
int tenantId) throws EventBrokerException {
MessageContext mc = new MessageContext();
mc.setConfigurationContext(new ConfigurationContext(new AxisConfiguration()));
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(tenantId);
SOAPFactory soapFactory = new SOAP12Factory();
SOAPEnvelope envelope = soapFactory.getDefaultEnvelope();
envelope.getBody().addChild(payload);
if (topic != null) {
envelope.getHeader().addChild(topic);
}
try {
mc.setEnvelope(envelope);
} catch (Exception e) {
throw new EventBrokerException("Unable to generate event.", e);
}
return mc;
}
代码示例来源:origin: org.wso2.carbon/org.wso2.carbon.bam.lwevent.core
public static MessageContext createMessageContext(OMElement payload,
OMElement topic,
int tenantId) throws EventBrokerException {
MessageContext mc = new MessageContext();
mc.setConfigurationContext(new ConfigurationContext(new AxisConfiguration()));
SuperTenantCarbonContext.getCurrentContext(mc).setTenantId(tenantId);
SOAPFactory soapFactory = new SOAP12Factory();
SOAPEnvelope envelope = soapFactory.getDefaultEnvelope();
envelope.getBody().addChild(payload);
if (topic != null) {
envelope.getHeader().addChild(topic);
}
try {
mc.setEnvelope(envelope);
} catch (Exception e) {
throw new EventBrokerException("Unable to generate event.", e);
}
return mc;
}
代码示例来源:origin: org.apache.synapse/synapse-samples
private SOAPEnvelope buildSoapEnvelope(String clientID, String value) {
SOAPFactory soapFactory = OMAbstractFactory.getSOAP12Factory();
SOAPEnvelope envelope = soapFactory.createSOAPEnvelope();
SOAPHeader header = soapFactory.createSOAPHeader();
envelope.addChild(header);
OMNamespace synNamespace = soapFactory.
createOMNamespace("http://ws.apache.org/ns/synapse", "syn");
OMElement clientIDElement = soapFactory.createOMElement("ClientID", synNamespace);
clientIDElement.setText(clientID);
header.addChild(clientIDElement);
SOAPBody body = soapFactory.createSOAPBody();
envelope.addChild(body);
OMElement valueElement = soapFactory.createOMElement("Value", null);
valueElement.setText(value);
body.addChild(valueElement);
return envelope;
}
代码示例来源:origin: org.wso2.ei/org.wso2.ei.samples
private SOAPEnvelope buildSoapEnvelope(String clientID, String value) {
SOAPFactory soapFactory = OMAbstractFactory.getSOAP12Factory();
SOAPEnvelope envelope = soapFactory.createSOAPEnvelope();
SOAPHeader header = soapFactory.createSOAPHeader();
envelope.addChild(header);
OMNamespace synNamespace = soapFactory.
createOMNamespace("http://ws.apache.org/ns/synapse", "syn");
OMElement clientIDElement = soapFactory.createOMElement("ClientID", synNamespace);
clientIDElement.setText(clientID);
header.addChild(clientIDElement);
SOAPBody body = soapFactory.createSOAPBody();
envelope.addChild(body);
OMElement valueElement = soapFactory.createOMElement("Value", null);
valueElement.setText(value);
body.addChild(valueElement);
return envelope;
}
代码示例来源:origin: wso2/wso2-synapse
private SOAPEnvelope buildSoapEnvelope(String clientID, String value) {
SOAPFactory soapFactory = OMAbstractFactory.getSOAP12Factory();
SOAPEnvelope envelope = soapFactory.createSOAPEnvelope();
SOAPHeader header = soapFactory.createSOAPHeader();
envelope.addChild(header);
OMNamespace synNamespace = soapFactory.
createOMNamespace("http://ws.apache.org/ns/synapse", "syn");
OMElement clientIDElement = soapFactory.createOMElement("ClientID", synNamespace);
clientIDElement.setText(clientID);
header.addChild(clientIDElement);
SOAPBody body = soapFactory.createSOAPBody();
envelope.addChild(body);
OMElement valueElement = soapFactory.createOMElement("Value", null);
valueElement.setText(value);
body.addChild(valueElement);
return envelope;
}
内容来源于网络,如有侵权,请联系作者删除!