...
Instead of loading the policies via Spring as detailed in the previous section, we can load the policies via code using the WSPolicyFeature, and then set it on a ClientFactoryBean, ServerFactoryBean or ClientProxyFactoryBean instance, for example:
Code Block | ||||
---|---|---|---|---|
| ||||
import org.apache.cxf.staxutils.StaxUtils;
import org.apache.cxf.ws.policy.WSPolicyFeature;
...
WSPolicyFeature policyFeature = new WSPolicyFeature();
Element policyElement =
StaxUtils.read(getClass().getResourceAsStream("saml.policy")).getDocumentElement();
policyFeature.setPolicyElements(Collections.singletonList(policyElement));
JaxWsProxyFactoryBean clientFactoryBean = new JaxWsProxyFactoryBean();
clientFactoryBean.setFeatures(Collections.singletonList(policyFeature)); |
Dynamically via message property
...