in rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/impl/MAPAggregatorImpl.java [427:569]
protected boolean mediate(Message message, boolean isFault) {
boolean continueProcessing = true;
if (ContextUtils.isOutbound(message)) {
if (usingAddressing(message)) {
// request/response MAPs must be aggregated
aggregate(message, isFault);
}
AddressingProperties theMaps =
ContextUtils.retrieveMAPs(message, false, ContextUtils.isOutbound(message));
if (isAddressingRequired() && ContextUtils.isRequestor(message)) {
theMaps.setRequired(true);
}
if (null != theMaps) {
if (ContextUtils.isRequestor(message)) {
assertAddressing(message,
theMaps.getReplyTo(),
theMaps.getFaultTo());
} else {
checkReplyTo(message, theMaps);
}
}
} else if (!ContextUtils.isRequestor(message)) {
//responder validates incoming MAPs
AddressingProperties maps = getMAPs(message, false, false);
//check responses
if (maps != null) {
checkAddressingResponses(maps.getReplyTo(), maps.getFaultTo());
assertAddressing(message,
maps.getReplyTo(),
maps.getFaultTo());
}
boolean isOneway = message.getExchange().isOneWay();
if (null == maps && !addressingRequired) {
return false;
}
continueProcessing = validateIncomingMAPs(maps, message);
if (maps != null) {
AddressingProperties theMaps =
ContextUtils.retrieveMAPs(message, false, ContextUtils.isOutbound(message));
if (null != theMaps) {
assertAddressing(message, theMaps.getReplyTo(), theMaps.getFaultTo());
}
if (isOneway
|| !ContextUtils.isGenericAddress(maps.getReplyTo())) {
InternalContextUtils.rebaseResponse(maps.getReplyTo(),
maps,
message);
}
if (!isOneway) {
if (ContextUtils.isNoneAddress(maps.getReplyTo())) {
LOG.warning("Detected NONE value in ReplyTo WSA header for request-respone MEP");
} else {
// ensure the inbound MAPs are available in both the full & fault
// response messages (used to determine relatesTo etc.)
ContextUtils.propogateReceivedMAPs(maps,
message.getExchange());
}
}
}
if (continueProcessing) {
// any faults thrown from here on can be correlated with this message
message.put(FaultMode.class, FaultMode.LOGICAL_RUNTIME_FAULT);
} else {
// validation failure => dispatch is aborted, response MAPs
// must be aggregated
//isFault = true;
//aggregate(message, isFault);
if (isSOAP12(message)) {
SoapFault soap12Fault = new SoapFault(ContextUtils.retrieveMAPFaultReason(message),
Soap12.getInstance().getSender());
soap12Fault.setSubCode(new QName(Names.WSA_NAMESPACE_NAME, ContextUtils
.retrieveMAPFaultName(message)));
throw soap12Fault;
}
throw new SoapFault(ContextUtils.retrieveMAPFaultReason(message),
new QName(Names.WSA_NAMESPACE_NAME,
ContextUtils.retrieveMAPFaultName(message)));
}
} else {
AddressingProperties theMaps =
ContextUtils.retrieveMAPs(message, false, ContextUtils.isOutbound(message));
if (null != theMaps) {
assertAddressing(message, theMaps.getReplyTo(), theMaps.getFaultTo());
}
// If the wsa policy is enabled , but the client sets the
// WSAddressingFeature.isAddressingRequired to false , we need to assert all WSA assertion to true
if (!ContextUtils.isOutbound(message) && ContextUtils.isRequestor(message)
&& getWSAddressingFeature(message) != null
&& !getWSAddressingFeature(message).isAddressingRequired()) {
assertAddressing(message);
}
//CXF-3060 :If wsa policy is not enforced, AddressingProperties map is null and
// AddressingFeature.isRequired, requestor checks inbound message and throw exception
if (null == theMaps
&& !ContextUtils.isOutbound(message)
&& ContextUtils.isRequestor(message)
&& getWSAddressingFeature(message) != null
&& getWSAddressingFeature(message).isAddressingRequired()) {
boolean missingWsaHeader = false;
AssertionInfoMap aim = message.get(AssertionInfoMap.class);
if (aim == null || aim.isEmpty()) {
missingWsaHeader = true;
}
if (aim != null && !aim.isEmpty()) {
missingWsaHeader = true;
QName[] types = new QName[] {
MetadataConstants.ADDRESSING_ASSERTION_QNAME,
MetadataConstants.USING_ADDRESSING_2004_QNAME,
MetadataConstants.USING_ADDRESSING_2005_QNAME,
MetadataConstants.USING_ADDRESSING_2006_QNAME
};
for (QName type : types) {
for (AssertionInfo assertInfo : aim.getAssertionInfo(type)) {
if (assertInfo.isAsserted()) {
missingWsaHeader = false;
}
}
}
}
if (missingWsaHeader) {
throw new SoapFault("MISSING_ACTION_MESSAGE", BUNDLE,
new QName(Names.WSA_NAMESPACE_NAME,
Names.HEADER_REQUIRED_NAME));
}
}
if (MessageUtils.isPartialResponse(message)
&& message.getExchange().getOutMessage() != null) {
// marked as a partial response, let's see if it really is
MessageInfo min = message.get(MessageInfo.class);
MessageInfo mout = message.getExchange().getOutMessage().get(MessageInfo.class);
if (min != null && mout != null
&& min.getOperation() == mout.getOperation()
&& message.getContent(List.class) != null) {
// the in and out messages are on the same operation
// and we were able to get a response for it.
message.remove(Message.PARTIAL_RESPONSE_MESSAGE);
}
}
}
return continueProcessing;
}