addressinginhandler.java
来自「开源的axis2框架的源码。用于开发WEBSERVER」· Java 代码 · 共 426 行 · 第 1/2 页
JAVA
426 行
if (log.isTraceEnabled()) {
log.trace("checkDuplicateHeaders: addressingHeaderName=" + addressingHeaderName +
" isDuplicate=" + shouldIgnore);
}
return shouldIgnore;
}
protected abstract void extractToEprReferenceParameters(EndpointReference toEPR,
SOAPHeader header, String namespace);
private void extractRelatesToInformation(SOAPHeaderBlock soapHeaderBlock,
Options messageContextOptions) {
String address = soapHeaderBlock.getText();
// Extract the RelationshipType attribute if it exists
OMAttribute relationshipType =
soapHeaderBlock.getAttribute(
new QName(AddressingConstants.WSA_RELATES_TO_RELATIONSHIP_TYPE));
String relationshipTypeString =
relationshipType == null ? null : relationshipType.getAttributeValue();
if (log.isTraceEnabled()) {
log.trace("extractRelatesToInformation: Extracted Relationship. Value=" + address +
" RelationshipType=" + relationshipTypeString);
}
RelatesTo relatesTo = new RelatesTo(address, relationshipTypeString);
ArrayList attributes = extractAttributesFromSOAPHeaderBlock(soapHeaderBlock);
relatesTo.setExtensibilityAttributes(attributes);
messageContextOptions.addRelatesTo(relatesTo);
// Completed processing of this header
soapHeaderBlock.setProcessed();
}
private void extractFaultToEPRInformation(SOAPHeaderBlock soapHeaderBlock,
String addressingNamespace,
MessageContext messageContext) throws AxisFault {
Options messageContextOptions = messageContext.getOptions();
EndpointReference epr = messageContextOptions.getFaultTo();
if (epr == null) {
epr = new EndpointReference("");
messageContextOptions.setFaultTo(epr);
}
extractEPRInformation(soapHeaderBlock, epr, addressingNamespace, messageContext);
if (log.isTraceEnabled()) {
log.trace("extractFaultToEPRInformation: Extracted FaultTo EPR: " + epr);
}
soapHeaderBlock.setProcessed();
}
private void extractReplyToEPRInformation(SOAPHeaderBlock soapHeaderBlock,
String addressingNamespace,
MessageContext messageContext) throws AxisFault {
Options messageContextOptions = messageContext.getOptions();
EndpointReference epr = messageContextOptions.getReplyTo();
if (epr == null) {
epr = new EndpointReference("");
messageContextOptions.setReplyTo(epr);
}
extractEPRInformation(soapHeaderBlock, epr, addressingNamespace, messageContext);
if (log.isTraceEnabled()) {
log.trace("extractReplyToEPRInformation: Extracted ReplyTo EPR: " + epr);
}
soapHeaderBlock.setProcessed();
}
private void extractFromEPRInformation(SOAPHeaderBlock soapHeaderBlock,
String addressingNamespace,
MessageContext messageContext) throws AxisFault {
Options messageContextOptions = messageContext.getOptions();
EndpointReference epr = messageContextOptions.getFrom();
if (epr == null) {
epr = new EndpointReference(
""); // I don't know the address now. Let me pass the empty string now and fill this
// once I process the Elements under this.
messageContextOptions.setFrom(epr);
}
extractEPRInformation(soapHeaderBlock, epr, addressingNamespace, messageContext);
if (log.isTraceEnabled()) {
log.trace("extractFromEPRInformation: Extracted From EPR: " + epr);
}
soapHeaderBlock.setProcessed();
}
private void extractToEPRInformation(SOAPHeaderBlock soapHeaderBlock,
Options messageContextOptions, SOAPHeader header,
String namespace) {
EndpointReference epr;
//here the addressing epr overidde what ever already there in the message context
epr = new EndpointReference(soapHeaderBlock.getText());
messageContextOptions.setTo(epr);
// check for address attributes
Iterator addressAttributes = soapHeaderBlock.getAllAttributes();
if (addressAttributes != null && addressAttributes.hasNext()) {
ArrayList attributes = new ArrayList();
while (addressAttributes.hasNext()) {
OMAttribute attr = (OMAttribute)addressAttributes.next();
attributes.add(attr);
}
epr.setAddressAttributes(attributes);
}
// check for reference parameters
extractToEprReferenceParameters(epr, header, namespace);
soapHeaderBlock.setProcessed();
if (log.isTraceEnabled()) {
log.trace("extractToEPRInformation: Extracted To EPR: " + epr);
}
}
//We assume that any action that already exists in the message context must be the
//soapaction. We compare that action to the WS-Addressing action, and if they are
//different we throw a fault.
private void extractActionInformation(SOAPHeaderBlock soapHeaderBlock,
MessageContext messageContext)
throws AxisFault {
Options messageContextOptions = messageContext.getOptions();
String soapAction = messageContextOptions.getAction();
String wsaAction = soapHeaderBlock.getText();
if (log.isTraceEnabled()) {
log.trace("extractActionInformation: soapAction='" + soapAction + "' wsa:Action='" +
wsaAction + "'");
}
// Need to validate that the content of the wsa:Action header is not null or whitespace
if ((wsaAction == null) || "".equals(wsaAction.trim())) {
AddressingFaultsHelper.triggerActionNotSupportedFault(messageContext, wsaAction);
}
// The isServerSide check is because the underlying Options object is
// shared between request and response MessageContexts for Sync
// invocations. If the soapAction is set outbound and a wsa:Action is
// received on the response they will differ (because there is no
// SOAPAction header on an HTTP response). In this case we should not
// check that soapAction==wsa:Action
if (soapAction != null && !"".equals(soapAction) && messageContext.isServerSide()) {
if (!soapAction.equals(wsaAction)) {
AddressingFaultsHelper.triggerActionMismatchFault(messageContext);
}
} else {
messageContextOptions.setAction(wsaAction);
}
ArrayList attributes = extractAttributesFromSOAPHeaderBlock(soapHeaderBlock);
if (attributes != null) {
messageContext.setProperty(AddressingConstants.ACTION_ATTRIBUTES, attributes);
}
soapHeaderBlock.setProcessed();
}
private void extractMessageIDInformation(SOAPHeaderBlock soapHeaderBlock,
MessageContext messageContext) throws AxisFault {
messageContext.getOptions().setMessageId(soapHeaderBlock.getText());
ArrayList attributes = extractAttributesFromSOAPHeaderBlock(soapHeaderBlock);
if (attributes != null) {
messageContext.setProperty(AddressingConstants.MESSAGEID_ATTRIBUTES, attributes);
}
soapHeaderBlock.setProcessed();
}
/**
* Given the soap header block, this should extract the information within EPR.
*
* @param headerBlock a SOAP header which is of type EndpointReference
* @param epr the EndpointReference to fill in with the extracted data
* @param addressingNamespace the WSA namespace URI
* @param messageContext the active MessageContext
* @throws AxisFault if there is a problem
*/
private void extractEPRInformation(SOAPHeaderBlock headerBlock, EndpointReference epr,
String addressingNamespace, MessageContext messageContext)
throws AxisFault {
try {
EndpointReferenceHelper.fromOM(epr, headerBlock, addressingNamespace);
} catch (AxisFault af) {
if (log.isTraceEnabled()) {
log.trace(
"extractEPRInformation: Exception occurred deserialising an EndpointReference.",
af);
}
AddressingFaultsHelper
.triggerMissingAddressInEPRFault(messageContext, headerBlock.getLocalName());
}
}
private ArrayList extractAttributesFromSOAPHeaderBlock(SOAPHeaderBlock soapHeaderBlock) {
Iterator actionAttributes = soapHeaderBlock.getAllAttributes();
if (actionAttributes != null && actionAttributes.hasNext()) {
ArrayList attributes = new ArrayList();
while (actionAttributes.hasNext()) {
OMAttribute attr = (OMAttribute)actionAttributes.next();
attributes.add(attr);
}
return attributes;
}
return null;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?