Search in sources :

Example 11 with ClientConfig

use of org.jboss.wsf.spi.metadata.config.ClientConfig in project wildfly by wildfly.

the class XTSClientIntegrationService method start.

@Override
public void start(final StartContext context) {
    final List<UnifiedHandlerChainMetaData> postHandlerChainsList = new ArrayList<>();
    postHandlerChainsList.add(postHandlerChains.get());
    ClientConfig wrapper = new ClientConfig(null, null, postHandlerChainsList, null, null);
    ((ServerConfigImpl) (serverConfig.get())).setClientConfigWrapper(wrapper, true);
}
Also used : UnifiedHandlerChainMetaData(org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerChainMetaData) ArrayList(java.util.ArrayList) ServerConfigImpl(org.jboss.as.webservices.config.ServerConfigImpl) ClientConfig(org.jboss.wsf.spi.metadata.config.ClientConfig)

Example 12 with ClientConfig

use of org.jboss.wsf.spi.metadata.config.ClientConfig in project jbossws-cxf by jbossws.

the class Helper method modifyDefaultConfiguration.

protected static void modifyDefaultConfiguration(final boolean client) {
    final Map<String, String> props = new HashMap<String, String>();
    props.put("schema-validation-enabled", "true");
    if (client) {
        registerClientConfigAndReload(new ClientConfig(ClientConfig.STANDARD_CLIENT_CONFIG, null, null, props, null));
    } else {
        registerEndpointConfigAndReload(new EndpointConfig(EndpointConfig.STANDARD_ENDPOINT_CONFIG, null, null, props, null));
    }
}
Also used : HashMap(java.util.HashMap) ClientConfig(org.jboss.wsf.spi.metadata.config.ClientConfig) EndpointConfig(org.jboss.wsf.spi.metadata.config.EndpointConfig)

Example 13 with ClientConfig

use of org.jboss.wsf.spi.metadata.config.ClientConfig in project jbossws-cxf by jbossws.

the class Helper method testDefaultClientValidation.

public boolean testDefaultClientValidation() throws Exception {
    // first verify schema validation is not enabled yet: a wsdl with schema restrictions is used on client side,
    // but schema validation is not enabled; the invoked endpoint does not have schema validation on
    final QName serviceName = new QName("http://jboss.org/schemavalidation", "HelloService");
    final QName portName = new QName("http://jboss.org/schemavalidation", "HelloPort");
    final URL wsdlURL = Thread.currentThread().getContextClassLoader().getResource("validatingClient.wsdl");
    Service service = Service.create(wsdlURL, serviceName);
    Hello proxy = (Hello) service.getPort(portName, Hello.class);
    ((BindingProvider) proxy).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, address);
    HelloResponse hr = proxy.helloRequest("JBoss");
    if (hr == null || hr.getReturn() != 2) {
        return false;
    }
    hr = proxy.helloRequest("number");
    if (hr == null || hr.getReturn() != 2) {
        return false;
    }
    final ClientConfig defClientConfig = (ClientConfig) getAndVerifyDefaultConfiguration(true);
    // then modify default conf to enable default client schema validation
    try {
        modifyDefaultConfiguration(true);
        service = Service.create(wsdlURL, serviceName);
        proxy = (Hello) service.getPort(portName, Hello.class);
        ((BindingProvider) proxy).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, address);
        hr = proxy.helloRequest("JBoss");
        if (hr == null || hr.getReturn() != 2) {
            return false;
        }
        try {
            proxy.helloRequest("number");
            return false;
        } catch (Exception e) {
            return e.getMessage().contains("is not facet-valid with respect to enumeration");
        }
    } finally {
        // -- restore default conf --
        registerClientConfigAndReload(defClientConfig);
    // --
    }
}
Also used : QName(javax.xml.namespace.QName) HelloResponse(org.jboss.test.ws.jaxws.samples.schemavalidation.types.HelloResponse) Service(javax.xml.ws.Service) ClientConfig(org.jboss.wsf.spi.metadata.config.ClientConfig) URL(java.net.URL)

Example 14 with ClientConfig

use of org.jboss.wsf.spi.metadata.config.ClientConfig in project jbossws-cxf by jbossws.

the class CXFClientConfigurerTest method testAddInterceptorsThroughSetConfigProperties.

@Test
public void testAddInterceptorsThroughSetConfigProperties() throws Exception {
    Bus bus = null;
    try {
        bus = BusFactory.newInstance().createBus();
        BusFactory.setThreadDefaultBus(bus);
        Service service = Service.create(this.getClass().getResource("META-INF/TestService.wsdl"), new QName("http://www.openuri.org/2004/04/HelloWorld", "EndpointService"));
        EndpointInterface port = service.getPort(new QName("http://www.openuri.org/2004/04/HelloWorld", "EndpointInterfacePort"), EndpointInterface.class);
        Client client = ClientProxy.getClient(port);
        Map<String, String> properties = new HashMap<String, String>();
        properties.put("A", "1");
        properties.put("B", "2");
        properties.put("C", "3");
        properties.put(Constants.CXF_IN_INTERCEPTORS_PROP, "org.jboss.wsf.stack.cxf.client.configuration.InterceptorA org.jboss.wsf.stack.cxf.client.configuration.InterceptorB");
        properties.put(Constants.CXF_OUT_INTERCEPTORS_PROP, "org.jboss.wsf.stack.cxf.client.configuration.InterceptorC,org.jboss.wsf.stack.cxf.client.configuration.InterceptorD");
        properties.put(Constants.CXF_IN_FAULT_INTERCEPTORS_PROP, "org.jboss.wsf.stack.cxf.client.configuration.InterceptorE,org.jboss.wsf.stack.cxf.client.configuration.InterceptorF");
        properties.put(Constants.CXF_OUT_FAULT_INTERCEPTORS_PROP, "org.jboss.wsf.stack.cxf.client.configuration.InterceptorG org.jboss.wsf.stack.cxf.client.configuration.InterceptorH");
        ClientConfig clientConfig = new ClientConfig("Foo", null, null, properties, null);
        CXFClientConfigurer cfg = new CXFClientConfigurer();
        cfg.setConfigProperties(port, clientConfig);
        assertEquals("1", client.getEndpoint().get("A"));
        assertEquals("2", client.getEndpoint().get("B"));
        assertEquals("3", client.getEndpoint().get("C"));
        List<String> interceptors = toNameList(client.getInInterceptors());
        assertTrue(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorA"));
        assertTrue(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorB"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorC"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorD"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorE"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorF"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorG"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorH"));
        interceptors = toNameList(client.getOutInterceptors());
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorA"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorB"));
        assertTrue(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorC"));
        assertTrue(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorD"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorE"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorF"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorG"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorH"));
        interceptors = toNameList(client.getInFaultInterceptors());
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorA"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorB"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorC"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorD"));
        assertTrue(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorE"));
        assertTrue(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorF"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorG"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorH"));
        interceptors = toNameList(client.getOutFaultInterceptors());
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorA"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorB"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorC"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorD"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorE"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorF"));
        assertTrue(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorG"));
        assertTrue(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorH"));
        ClientProxy.getClient(port).getInInterceptors().add(new InterceptorZ());
        ClientProxy.getClient(port).getInFaultInterceptors().add(new InterceptorY());
        properties = new HashMap<String, String>();
        properties.put("E", "10");
        properties.put("F", "20");
        properties.put("G", "30");
        properties.put(Constants.CXF_IN_INTERCEPTORS_PROP, "org.jboss.wsf.stack.cxf.client.configuration.InterceptorD, FooInterceptor");
        properties.put(Constants.CXF_OUT_INTERCEPTORS_PROP, "org.jboss.wsf.stack.cxf.client.configuration.InterceptorB");
        properties.put(Constants.CXF_IN_FAULT_INTERCEPTORS_PROP, "org.jboss.wsf.stack.cxf.client.configuration.InterceptorA, BarInterceptor");
        properties.put(Constants.CXF_OUT_FAULT_INTERCEPTORS_PROP, "org.jboss.wsf.stack.cxf.client.configuration.InterceptorC");
        clientConfig = new ClientConfig("Foo2", null, null, properties, null);
        cfg.setConfigProperties(port, clientConfig);
        assertEquals(null, client.getEndpoint().get("A"));
        assertEquals(null, client.getEndpoint().get("B"));
        assertEquals(null, client.getEndpoint().get("C"));
        assertEquals(null, client.getEndpoint().get("D"));
        assertEquals("10", client.getEndpoint().get("E"));
        assertEquals("20", client.getEndpoint().get("F"));
        assertEquals("30", client.getEndpoint().get("G"));
        interceptors = toNameList(client.getInInterceptors());
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorA"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorB"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorC"));
        assertTrue(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorD"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorE"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorF"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorG"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorH"));
        assertTrue(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorZ"));
        interceptors = toNameList(client.getOutInterceptors());
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorA"));
        assertTrue(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorB"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorC"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorD"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorE"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorF"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorG"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorH"));
        interceptors = toNameList(client.getInFaultInterceptors());
        assertTrue(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorA"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorB"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorC"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorD"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorE"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorF"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorG"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorH"));
        assertTrue(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorY"));
        assertFalse(interceptors.contains("BarInterceptor"));
        interceptors = toNameList(client.getOutFaultInterceptors());
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorA"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorB"));
        assertTrue(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorC"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorD"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorE"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorF"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorG"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorH"));
        properties = new HashMap<String, String>();
        properties.put(Constants.CXF_IN_INTERCEPTORS_PROP, "");
        properties.put(Constants.CXF_IN_FAULT_INTERCEPTORS_PROP, "");
        clientConfig = new ClientConfig("Foo2", null, null, properties, null);
        cfg.setConfigProperties(port, clientConfig);
        assertEquals(null, client.getEndpoint().get("A"));
        assertEquals(null, client.getEndpoint().get("B"));
        assertEquals(null, client.getEndpoint().get("C"));
        assertEquals(null, client.getEndpoint().get("D"));
        assertEquals(null, client.getEndpoint().get("E"));
        assertEquals(null, client.getEndpoint().get("F"));
        assertEquals(null, client.getEndpoint().get("G"));
        interceptors = toNameList(client.getInInterceptors());
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorA"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorB"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorC"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorD"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorE"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorF"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorG"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorH"));
        assertTrue(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorZ"));
        interceptors = toNameList(client.getOutInterceptors());
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorA"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorB"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorC"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorD"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorE"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorF"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorG"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorH"));
        interceptors = toNameList(client.getInFaultInterceptors());
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorA"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorB"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorC"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorD"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorE"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorF"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorG"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorH"));
        assertTrue(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorY"));
        assertFalse(interceptors.contains("BarInterceptor"));
        interceptors = toNameList(client.getOutFaultInterceptors());
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorA"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorB"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorC"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorD"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorE"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorF"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorG"));
        assertFalse(interceptors.contains("org.jboss.wsf.stack.cxf.client.configuration.InterceptorH"));
    } finally {
        if (bus != null) {
            bus.shutdown(true);
        }
    }
}
Also used : Bus(org.apache.cxf.Bus) HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) Service(javax.xml.ws.Service) Client(org.apache.cxf.endpoint.Client) ClientConfig(org.jboss.wsf.spi.metadata.config.ClientConfig) Test(org.junit.Test)

Example 15 with ClientConfig

use of org.jboss.wsf.spi.metadata.config.ClientConfig in project jbossws-cxf by jbossws.

the class Helper method testDefaultClientConfiguration.

/**
 * This test hacks the current ServerConfig temporarily adding an handler from this testcase deployment
 * into the AS default client configuration, verifies the handler is picked up and finally restores the
 * original default client configuration.
 *
 * @return
 * @throws Exception
 */
public boolean testDefaultClientConfiguration() throws Exception {
    QName serviceName = new QName("http://clientConfig.jaxws.ws.test.jboss.org/", "EndpointImplService");
    URL wsdlURL = new URL(address + "?wsdl");
    final ClientConfig defaultClientConfig = TestUtils.getAndVerifyDefaultClientConfiguration();
    // -- modify default conf --
    try {
        TestUtils.changeDefaultClientConfiguration();
        // --
        Service service = Service.create(wsdlURL, serviceName);
        Endpoint port = (Endpoint) service.getPort(Endpoint.class);
        BindingProvider bp = (BindingProvider) port;
        @SuppressWarnings("rawtypes") List<Handler> hc = bp.getBinding().getHandlerChain();
        hc.add(new UserHandler());
        bp.getBinding().setHandlerChain(hc);
        String resStr = port.echo("Kermit");
        resStr = port.echo("Kermit");
        resStr = port.echo("Kermit");
        return ("Kermit|UserOut|LogOut|endpoint|LogIn|UserIn".equals(resStr));
    } finally {
        // -- restore default conf --
        TestUtils.setClientConfigAndReload(defaultClientConfig);
    // --
    }
}
Also used : QName(javax.xml.namespace.QName) Service(javax.xml.ws.Service) Handler(javax.xml.ws.handler.Handler) BindingProvider(javax.xml.ws.BindingProvider) ClientConfig(org.jboss.wsf.spi.metadata.config.ClientConfig) URL(java.net.URL)

Aggregations

ClientConfig (org.jboss.wsf.spi.metadata.config.ClientConfig)19 Service (javax.xml.ws.Service)7 HashMap (java.util.HashMap)6 UnifiedHandlerChainMetaData (org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerChainMetaData)6 URL (java.net.URL)5 QName (javax.xml.namespace.QName)5 ServerConfig (org.jboss.wsf.spi.management.ServerConfig)5 EndpointConfig (org.jboss.wsf.spi.metadata.config.EndpointConfig)3 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 BindingProvider (javax.xml.ws.BindingProvider)2 Handler (javax.xml.ws.handler.Handler)2 Bus (org.apache.cxf.Bus)2 Client (org.apache.cxf.endpoint.Client)2 UnifiedHandlerMetaData (org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerMetaData)2 LinkedList (java.util.LinkedList)1 SOAPMessage (javax.xml.soap.SOAPMessage)1 Source (javax.xml.transform.Source)1 DOMSource (javax.xml.transform.dom.DOMSource)1 Dispatch (javax.xml.ws.Dispatch)1