Collection attachPolicyComponents = policySubject
.getAttachedPolicyComponents();
for (Object policyElement : attachPolicyComponents) {
if (policyElement instanceof Policy) {
PolicyReference policyReference =
PolicyUtil.createPolicyReference((Policy)policyElement);
OMElement policyRefElement =
PolicyUtil.getPolicyComponentAsOMElement(policyReference, serializer);
OMNode firstChildElem = wsdlElement.getFirstElement();
if (firstChildElem == null) {
wsdlElement.addChild(policyRefElement);
} else {
firstChildElem.insertSiblingBefore(policyRefElement);
}
String key = policyReference.getURI();
if (key.startsWith("#")) {
key = key.substring(key.indexOf("#") + 1);
}
addPolicyToDefinitionElement(key, (Policy)policyElement);