Search in sources :

Example 1 with ClientConfigurer

use of org.jboss.ws.api.configuration.ClientConfigurer in project jbossws-cxf by jbossws.

the class Helper method testGZIPServerSideOnlyInterceptorOnClient.

public boolean testGZIPServerSideOnlyInterceptorOnClient() throws Exception {
    Bus bus = BusFactory.newInstance().createBus();
    try {
        BusFactory.setThreadDefaultBus(bus);
        HelloWorld port = getPort();
        Client client = ClientProxy.getClient(port);
        HTTPConduit conduit = (HTTPConduit) client.getConduit();
        HTTPClientPolicy policy = conduit.getClient();
        // enable Accept gzip, otherwise the server will not try to reply using gzip
        policy.setAcceptEncoding("gzip;q=1.0, identity; q=0.5, *;q=0");
        // add interceptor for decoding gzip message
        ClientConfigurer configurer = ClientConfigUtil.resolveClientConfigurer();
        configurer.setConfigProperties(port, "jaxws-client-config.xml", "Interceptor Client Config");
        return ("foo".equals(port.echo("foo")));
    } finally {
        bus.shutdown(true);
    }
}
Also used : HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) Bus(org.apache.cxf.Bus) HTTPClientPolicy(org.apache.cxf.transports.http.configuration.HTTPClientPolicy) ClientConfigurer(org.jboss.ws.api.configuration.ClientConfigurer) Client(org.apache.cxf.endpoint.Client)

Example 2 with ClientConfigurer

use of org.jboss.ws.api.configuration.ClientConfigurer in project jbossws-cxf by jbossws.

the class Helper method testConfigurationChange.

public boolean testConfigurationChange() throws Exception {
    Service service = Service.create(new URL(address + "?wsdl"), serviceName);
    Endpoint port = (Endpoint) service.getPort(Endpoint.class);
    org.apache.cxf.endpoint.Endpoint ep = ClientProxy.getClient(port).getEndpoint();
    assert (ep.get("propA") == null);
    assert (ep.get("propB") == null);
    ep.put("propZ", "valueZ");
    ClientConfigurer configurer = ClientConfigUtil.resolveClientConfigurer();
    configurer.setConfigProperties(port, "META-INF/jaxws-client-config.xml", "Custom Client Config");
    if (!ep.get("propA").equals("fileValueA") || !ep.get("propB").equals("fileValueB") || !ep.get("propZ").equals("valueZ")) {
        return false;
    }
    port.echo("Kermit");
    configurer.setConfigProperties(port, "META-INF/jaxws-client-config.xml", "Another Client Config");
    return (ep.get("propA") == null && ep.get("propB") == null && ep.get("propC").equals("fileValueC") && ep.get("propZ").equals("valueZ"));
}
Also used : Service(javax.xml.ws.Service) ClientConfigurer(org.jboss.ws.api.configuration.ClientConfigurer) URL(java.net.URL)

Example 3 with ClientConfigurer

use of org.jboss.ws.api.configuration.ClientConfigurer in project jbossws-cxf by jbossws.

the class FastInfosetTestCase method internalTestInfosetUsingFeatureProperties.

private void internalTestInfosetUsingFeatureProperties(URL wsdlURL, QName serviceName, QName portQName) throws Exception {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    ByteArrayOutputStream in = new ByteArrayOutputStream();
    PrintWriter pwIn = new PrintWriter(in);
    PrintWriter pwOut = new PrintWriter(out);
    Bus bus = BusFactory.newInstance().createBus();
    BusFactory.setThreadDefaultBus(bus);
    try {
        bus.getInInterceptors().add(new LoggingInInterceptor(pwIn));
        bus.getOutInterceptors().add(new LoggingOutInterceptor(pwOut));
        Service service = Service.create(wsdlURL, serviceName, new UseThreadBusFeature());
        HelloWorld port = (HelloWorld) service.getPort(portQName, HelloWorld.class);
        ClientConfigurer configurer = ClientConfigUtil.resolveClientConfigurer();
        configurer.setConfigProperties(port, "META-INF/jaxws-client-config.xml", "Custom Client Config");
        assertEquals("helloworld", port.echo("helloworld"));
        assertTrue("request is expected fastinfoset", out.toString().indexOf("application/fastinfoset") > -1);
        assertTrue("response is expected fastinfoset", in.toString().indexOf("application/fastinfoset") > -1);
    } finally {
        bus.shutdown(true);
        pwOut.close();
        pwIn.close();
    }
}
Also used : Bus(org.apache.cxf.Bus) UseThreadBusFeature(org.jboss.wsf.stack.cxf.client.UseThreadBusFeature) LoggingOutInterceptor(org.apache.cxf.interceptor.LoggingOutInterceptor) LoggingInInterceptor(org.apache.cxf.interceptor.LoggingInInterceptor) Service(javax.xml.ws.Service) ClientConfigurer(org.jboss.ws.api.configuration.ClientConfigurer) ByteArrayOutputStream(java.io.ByteArrayOutputStream) PrintWriter(java.io.PrintWriter)

Example 4 with ClientConfigurer

use of org.jboss.ws.api.configuration.ClientConfigurer in project jbossws-cxf by jbossws.

the class WSReliableMessagingWithAPITestCase method testWithFeatureProperty.

@Test
@RunAsClient
@WrapThreadContextClassLoader
public void testWithFeatureProperty() throws Exception {
    final Bus bus = BusFactory.newInstance().createBus();
    BusFactory.setThreadDefaultBus(bus);
    try {
        QName serviceName = new QName("http://www.jboss.org/jbossws/ws-extensions/wsrm", "SimpleService");
        URL wsdlURL = getResourceURL("jaxws/samples/wsrm/WEB-INF/wsdl/SimpleService.wsdl");
        Service service = Service.create(wsdlURL, serviceName);
        SimpleService proxy = (SimpleService) service.getPort(SimpleService.class);
        ClientConfigurer configurer = ClientConfigUtil.resolveClientConfigurer();
        configurer.setConfigProperties(proxy, "META-INF/jaxws-client-config.xml", "Custom Client Config");
        ((BindingProvider) proxy).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, baseURL + "/jaxws-samples-wsrm-api/SimpleService");
        // request response call
        assertEquals("Hello World!", proxy.echo("Hello World!"));
        // one way call
        proxy.ping();
    } finally {
        bus.shutdown(true);
    }
}
Also used : Bus(org.apache.cxf.Bus) QName(javax.xml.namespace.QName) SimpleService(org.jboss.test.ws.jaxws.samples.wsrm.generated.SimpleService) Service(javax.xml.ws.Service) SimpleService(org.jboss.test.ws.jaxws.samples.wsrm.generated.SimpleService) ClientConfigurer(org.jboss.ws.api.configuration.ClientConfigurer) URL(java.net.URL) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test) JBossWSTest(org.jboss.wsf.test.JBossWSTest) WrapThreadContextClassLoader(org.jboss.wsf.test.WrapThreadContextClassLoader)

Example 5 with ClientConfigurer

use of org.jboss.ws.api.configuration.ClientConfigurer in project jbossws-cxf by jbossws.

the class Helper method testConfigurationChange.

public boolean testConfigurationChange() throws Exception {
    QName serviceName = new QName("http://clientConfig.jaxws.ws.test.jboss.org/", "EndpointImplService");
    URL wsdlURL = new URL(address + "?wsdl");
    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);
    ClientConfigurer configurer = ClientConfigUtil.resolveClientConfigurer();
    configurer.setConfigHandlers(bp, "META-INF/jaxws-client-config.xml", "Custom Client Config");
    String resStr = port.echo("Kermit");
    resStr = port.echo("Kermit");
    resStr = port.echo("Kermit");
    if (!"Kermit|RoutOut|CustomOut|UserOut|LogOut|endpoint|LogIn|UserIn|CustomIn|RoutIn".equals(resStr)) {
        return false;
    }
    configurer.setConfigHandlers(bp, "META-INF/jaxws-client-config.xml", "Another Client Config");
    resStr = port.echo("Kermit");
    resStr = port.echo("Kermit");
    resStr = port.echo("Kermit");
    return ("Kermit|RoutOut|UserOut|endpoint|UserIn|RoutIn".equals(resStr));
}
Also used : QName(javax.xml.namespace.QName) Service(javax.xml.ws.Service) Handler(javax.xml.ws.handler.Handler) ClientConfigurer(org.jboss.ws.api.configuration.ClientConfigurer) BindingProvider(javax.xml.ws.BindingProvider) URL(java.net.URL)

Aggregations

ClientConfigurer (org.jboss.ws.api.configuration.ClientConfigurer)8 Service (javax.xml.ws.Service)6 URL (java.net.URL)5 Bus (org.apache.cxf.Bus)4 QName (javax.xml.namespace.QName)3 BindingProvider (javax.xml.ws.BindingProvider)2 Handler (javax.xml.ws.handler.Handler)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 PrintWriter (java.io.PrintWriter)1 SOAPMessage (javax.xml.soap.SOAPMessage)1 Source (javax.xml.transform.Source)1 DOMSource (javax.xml.transform.dom.DOMSource)1 Client (org.apache.cxf.endpoint.Client)1 LoggingInInterceptor (org.apache.cxf.interceptor.LoggingInInterceptor)1 LoggingOutInterceptor (org.apache.cxf.interceptor.LoggingOutInterceptor)1 HTTPConduit (org.apache.cxf.transport.http.HTTPConduit)1 HTTPClientPolicy (org.apache.cxf.transports.http.configuration.HTTPClientPolicy)1 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)1 SimpleService (org.jboss.test.ws.jaxws.samples.wsrm.generated.SimpleService)1 UseThreadBusFeature (org.jboss.wsf.stack.cxf.client.UseThreadBusFeature)1