* @return Policy from the mex service
*/
public static Policy getPolicyFromMetadataRef(OMElement mex) throws RampartException {
try {
Metadata metadata = new Metadata();
metadata.fromOM(mex.getFirstElement());
MetadataSection[] metadataSections = metadata.getMetadatSections();
MetadataReference reference = metadataSections[0].getMetadataReference();
MexClient serviceClient = new MexClient();
Options options = serviceClient.getOptions();
options.setTo(reference.getEPR());
options.setAction(DRConstants.SPEC.Actions.GET_METADATA_REQUEST);
OMElement request = serviceClient.setupGetMetadataRequest(
MexConstants.SPEC.DIALECT_TYPE_POLICY,null);
OMElement result = serviceClient.sendReceive(request);
metadata.fromOM(result);
MetadataSection[] mexSecs = metadata.getMetadataSection(MexConstants.SPEC.DIALECT_TYPE_POLICY, null);
OMElement policyElement = (OMElement) mexSecs[0].getInlineData();
return PolicyEngine.getPolicy(policyElement);