public void addAddressingHeaders(SoapMessage message, MessageAddressingProperties map) {
SoapHeader header = message.getSoapHeader();
header.addNamespaceDeclaration(getNamespacePrefix(), getNamespaceUri());
// To
if (map.getTo() != null) {
SoapHeaderElement to = header.addHeaderElement(getToName());
to.setText(map.getTo().toString());
to.setMustUnderstand(true);
}
// From
if (map.getFrom() != null) {
SoapHeaderElement from = header.addHeaderElement(getFromName());
addEndpointReference(from, map.getFrom());
}
//ReplyTo
if (map.getReplyTo() != null) {
SoapHeaderElement replyTo = header.addHeaderElement(getReplyToName());
addEndpointReference(replyTo, map.getReplyTo());
}
// FaultTo
if (map.getFaultTo() != null) {
SoapHeaderElement faultTo = header.addHeaderElement(getFaultToName());
addEndpointReference(faultTo, map.getFaultTo());
}
// Action
SoapHeaderElement action = header.addHeaderElement(getActionName());
action.setText(map.getAction().toString());
// MessageID
if (map.getMessageId() != null) {
SoapHeaderElement messageId = header.addHeaderElement(getMessageIdName());
messageId.setText(map.getMessageId().toString());
}
// RelatesTo
if (map.getRelatesTo() != null) {
SoapHeaderElement relatesTo = header.addHeaderElement(getRelatesToName());
relatesTo.setText(map.getRelatesTo().toString());
}
addReferenceNodes(header.getResult(), map.getReferenceParameters());
addReferenceNodes(header.getResult(), map.getReferenceProperties());
}