Search in sources :

Example 1 with FirstAlternativeSelector

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();
}
Also used : FirstAlternativeSelector(org.apache.cxf.ws.policy.selector.FirstAlternativeSelector) WSPolicyFeature(org.apache.cxf.ws.policy.WSPolicyFeature) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList) PolicyEngine(org.apache.cxf.ws.policy.PolicyEngine) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean)

Aggregations

ArrayList (java.util.ArrayList)1 JaxWsServerFactoryBean (org.apache.cxf.jaxws.JaxWsServerFactoryBean)1 PolicyEngine (org.apache.cxf.ws.policy.PolicyEngine)1 WSPolicyFeature (org.apache.cxf.ws.policy.WSPolicyFeature)1 FirstAlternativeSelector (org.apache.cxf.ws.policy.selector.FirstAlternativeSelector)1 Element (org.w3c.dom.Element)1