use of org.apache.cxf.ws.policy.selector.FirstAlternativeSelector in project cxf by apache.
the class MtomPolicyTest method setupServer.
public void setupServer(boolean mtomRequired, String address) throws Exception {
getStaticBus().getExtension(PolicyEngine.class).setAlternativeSelector(new FirstAlternativeSelector());
JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
sf.setServiceBean(new EchoService());
sf.setBus(getStaticBus());
sf.setAddress(address);
WSPolicyFeature policyFeature = new WSPolicyFeature();
List<Element> policyElements = new ArrayList<>();
if (mtomRequired) {
policyElements.add(StaxUtils.read(getClass().getResourceAsStream("mtom-policy.xml")).getDocumentElement());
} else {
policyElements.add(StaxUtils.read(getClass().getResourceAsStream("mtom-policy-optional.xml")).getDocumentElement());
}
policyFeature.setPolicyElements(policyElements);
sf.getFeatures().add(policyFeature);
sf.create();
}
Aggregations