// check if found reference is addressing policy
Element wsAddressing = XmlUtils.getFirstChildElementNS(wsamAddressingElm, WsaUtils.WS_A_NAMESPACE_200705,
"Addressing");
Element addressingPolicy = null;
Policy newPolicy = PolicyDocument.Factory.newInstance().addNewPolicy();
Addressing newAddressing = null;
if (wsAddressing != null) {
newAddressing = newPolicy.addNewAddressing();
String optional = wsAddressing.getAttributeNS(usedPolicyNamespace, "Optional");
if (!StringUtils.isNullOrEmpty(optional) && optional.equals(OptionalType.TRUE.toString())) {
newAddressing.setOptional(OptionalType.TRUE);
} else {
newAddressing.setOptional(OptionalType.FALSE);
}
addressingPolicy = XmlUtils.getFirstChildElementNS(wsAddressing, usedPolicyNamespace, "Policy");
if (addressingPolicy != null) {
Element exactlyOne = XmlUtils.getFirstChildElementNS(addressingPolicy, usedPolicyNamespace, "ExactlyOne");
if (exactlyOne != null) {