String addressingNamespace)
throws AddressingException {
Iterator addressingHeadersIt = addressingHeaders.iterator();
while (addressingHeadersIt.hasNext()) {
SOAPHeaderBlock soapHeaderBlock = (SOAPHeaderBlock) addressingHeadersIt.next();
EndpointReference epr;
if (AddressingConstants.WSA_TO.equals(soapHeaderBlock.getLocalName())) {
//here the addressing epr overidde what ever already there in the message context
epr = new EndpointReference(soapHeaderBlock.getText());
messageContextOptions.setTo(epr);
// check for reference parameters
extractToEprReferenceParameters(epr, header);
soapHeaderBlock.setProcessed();
} else if (AddressingConstants.WSA_FROM.equals(soapHeaderBlock.getLocalName())) {
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);
soapHeaderBlock.setProcessed();
} else if (AddressingConstants.WSA_REPLY_TO.equals(soapHeaderBlock.getLocalName())) {
epr = messageContextOptions.getReplyTo();
if (epr == null) {
epr = new EndpointReference("");
messageContextOptions.setReplyTo(epr);
}
extractEPRInformation(soapHeaderBlock, epr, addressingNamespace);
soapHeaderBlock.setProcessed();
} else if (AddressingConstants.WSA_FAULT_TO.equals(soapHeaderBlock.getLocalName())) {
epr = messageContextOptions.getFaultTo();
if (epr == null) {
epr = new EndpointReference("");
messageContextOptions.setFaultTo(epr);
}
extractEPRInformation(soapHeaderBlock, epr, addressingNamespace);
soapHeaderBlock.setProcessed();
} else if (AddressingConstants.WSA_MESSAGE_ID.equals(soapHeaderBlock.getLocalName())) {
messageContextOptions.setMessageId(soapHeaderBlock.getText());
soapHeaderBlock.setProcessed();
} else if (AddressingConstants.WSA_ACTION.equals(soapHeaderBlock.getLocalName())) {
messageContextOptions.setAction(soapHeaderBlock.getText());
soapHeaderBlock.setProcessed();
} else if (AddressingConstants.WSA_RELATES_TO.equals(soapHeaderBlock.getLocalName())) {
String address = soapHeaderBlock.getText();
OMAttribute relationshipType =
soapHeaderBlock.getAttribute(
new QName(AddressingConstants.WSA_RELATES_TO_RELATIONSHIP_TYPE));
String relationshipTypeDefaultValue =
Submission.WSA_NAMESPACE.equals(addressingNamespace)
? Submission.WSA_RELATES_TO_RELATIONSHIP_TYPE_DEFAULT_VALUE
: Final.WSA_RELATES_TO_RELATIONSHIP_TYPE_DEFAULT_VALUE;
RelatesTo relatesTo =
new RelatesTo(
address,
relationshipType == null
? relationshipTypeDefaultValue
: relationshipType.getAttributeValue());
messageContextOptions.setRelatesTo(relatesTo);
soapHeaderBlock.setProcessed();
}
}
return messageContextOptions;
}