Search in sources :

Example 1 with GZIPInInterceptor

use of org.apache.cxf.transport.common.gzip.GZIPInInterceptor in project cxf by apache.

the class DirectDispatchClientTest method invokeService.

private void invokeService(boolean isDirectDispatch) {
    BusFactory.setThreadDefaultBus(staticBus);
    Service service = Service.create(serviceName);
    service.addPort(localPortName, "http://schemas.xmlsoap.org/soap/", "local://Greeter");
    Greeter greeter = service.getPort(localPortName, Greeter.class);
    if (isDirectDispatch) {
        Client client = ClientProxy.getClient(greeter);
        client.getOutInterceptors().add(new GZIPOutInterceptor(50));
        client.getInInterceptors().add(new GZIPInInterceptor());
        InvocationHandler handler = Proxy.getInvocationHandler(greeter);
        BindingProvider bp = null;
        if (handler instanceof BindingProvider) {
            bp = (BindingProvider) handler;
            Map<String, Object> requestContext = bp.getRequestContext();
            requestContext.put(LocalConduit.DIRECT_DISPATCH, true);
        }
    }
    String reply = greeter.greetMe("test");
    assertEquals("Hello test", reply);
    reply = greeter.sayHi();
    assertNotNull("no response received from service", reply);
    assertEquals("Bonjour", reply);
}
Also used : GZIPOutInterceptor(org.apache.cxf.transport.common.gzip.GZIPOutInterceptor) Greeter(org.apache.hello_world_soap_http.Greeter) Service(javax.xml.ws.Service) GZIPInInterceptor(org.apache.cxf.transport.common.gzip.GZIPInInterceptor) BindingProvider(javax.xml.ws.BindingProvider) Client(org.apache.cxf.endpoint.Client) InvocationHandler(java.lang.reflect.InvocationHandler)

Example 2 with GZIPInInterceptor

use of org.apache.cxf.transport.common.gzip.GZIPInInterceptor in project cxf by apache.

the class Server method run.

protected void run() {
    URL url = getClass().getResource("fault-stack-trace.xml");
    if (url != null) {
        System.setProperty("cxf.config.file.url", url.toString());
    }
    Object implementor;
    String address;
    implementor = new AsyncGreeter();
    address = "http://localhost:" + PORT + "/SoapContext/AsyncSoapPort";
    eps.add(Endpoint.publish(address, implementor));
    implementor = new AsyncEchoProvider();
    address = "http://localhost:" + PORT + "/SoapContext/AsyncEchoProvider";
    eps.add(Endpoint.publish(address, implementor));
    implementor = new GreeterImplMultiPort();
    address = "http://localhost:" + PORT + "/MultiPort/GreeterPort";
    eps.add(Endpoint.publish(address, implementor));
    implementor = new DocLitBareGreeterMultiPort();
    address = "http://localhost:" + PORT + "/MultiPort/DocBarePort";
    eps.add(Endpoint.publish(address, implementor));
    implementor = new GreeterImpl();
    address = "http://localhost:" + PORT + "/SoapContext/SoapPort";
    Endpoint ep = Endpoint.publish(address, implementor);
    eps.add(ep);
    implementor = new GreeterImpl();
    address = "http://localhost:" + PORT + "/SoapContext/SoapPortWithGzip";
    Endpoint ep2 = Endpoint.publish(address, implementor);
    ((EndpointImpl) ep2).getService().getInInterceptors().add(new GZIPInInterceptor());
    ((EndpointImpl) ep2).getService().getOutInterceptors().add(new GZIPOutInterceptor());
    eps.add(ep2);
    implementor = new RefGreeterImpl();
    address = "http://localhost:" + PORT + "/SoapContext/SoapPort2";
    eps.add(Endpoint.publish(address, implementor));
    // publish port with soap12 binding
    address = "http://localhost:" + PORT + "/SoapContext/SoapPort";
    EndpointImpl e = (EndpointImpl) Endpoint.create(javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_BINDING, new Greeter12Impl());
    e.publish(address);
    eps.add(e);
    implementor = new DocLitBareGreeterImpl();
    address = "http://localhost:" + BARE_PORT + "/SoapContext/SoapPort";
    eps.add(Endpoint.publish(address, implementor));
    implementor = new GreeterImplBogus();
    address = "http://localhost:" + BOGUS_REAL_PORT + "/SoapContext/SoapPort";
    eps.add(Endpoint.publish(address, implementor));
}
Also used : EndpointImpl(org.apache.cxf.jaxws.EndpointImpl) GZIPInInterceptor(org.apache.cxf.transport.common.gzip.GZIPInInterceptor) URL(java.net.URL) GZIPOutInterceptor(org.apache.cxf.transport.common.gzip.GZIPOutInterceptor) Endpoint(javax.xml.ws.Endpoint) GreeterImpl(org.apache.hello_world_soap_http.GreeterImpl) BaseGreeterImpl(org.apache.hello_world_soap_http.BaseGreeterImpl) DocLitBareGreeterImpl(org.apache.hello_world_soap_http.DocLitBareGreeterImpl) DocLitBareGreeterImpl(org.apache.hello_world_soap_http.DocLitBareGreeterImpl)

Example 3 with GZIPInInterceptor

use of org.apache.cxf.transport.common.gzip.GZIPInInterceptor in project syncope by apache.

the class SyncopeClient method getService.

/**
 * Creates an instance of the given service class, with configured content type and authentication.
 *
 * @param <T> any service class
 * @param serviceClass service class reference
 * @return service instance of the given reference class
 */
public <T> T getService(final Class<T> serviceClass) {
    synchronized (restClientFactory) {
        restClientFactory.setServiceClass(serviceClass);
        T serviceInstance = restClientFactory.create(serviceClass);
        Client client = WebClient.client(serviceInstance);
        client.type(mediaType).accept(mediaType);
        ClientConfiguration config = WebClient.getConfig(client);
        config.getRequestContext().put(HEADER_SPLIT_PROPERTY, true);
        config.getRequestContext().put(URLConnectionHTTPConduit.HTTPURL_CONNECTION_METHOD_REFLECTION, true);
        if (useCompression) {
            config.getInInterceptors().add(new GZIPInInterceptor());
            config.getOutInterceptors().add(new GZIPOutInterceptor());
        }
        return serviceInstance;
    }
}
Also used : GZIPOutInterceptor(org.apache.cxf.transport.common.gzip.GZIPOutInterceptor) GZIPInInterceptor(org.apache.cxf.transport.common.gzip.GZIPInInterceptor) WebClient(org.apache.cxf.jaxrs.client.WebClient) Client(org.apache.cxf.jaxrs.client.Client) ClientConfiguration(org.apache.cxf.jaxrs.client.ClientConfiguration)

Aggregations

GZIPInInterceptor (org.apache.cxf.transport.common.gzip.GZIPInInterceptor)3 GZIPOutInterceptor (org.apache.cxf.transport.common.gzip.GZIPOutInterceptor)3 InvocationHandler (java.lang.reflect.InvocationHandler)1 URL (java.net.URL)1 BindingProvider (javax.xml.ws.BindingProvider)1 Endpoint (javax.xml.ws.Endpoint)1 Service (javax.xml.ws.Service)1 Client (org.apache.cxf.endpoint.Client)1 Client (org.apache.cxf.jaxrs.client.Client)1 ClientConfiguration (org.apache.cxf.jaxrs.client.ClientConfiguration)1 WebClient (org.apache.cxf.jaxrs.client.WebClient)1 EndpointImpl (org.apache.cxf.jaxws.EndpointImpl)1 BaseGreeterImpl (org.apache.hello_world_soap_http.BaseGreeterImpl)1 DocLitBareGreeterImpl (org.apache.hello_world_soap_http.DocLitBareGreeterImpl)1 Greeter (org.apache.hello_world_soap_http.Greeter)1 GreeterImpl (org.apache.hello_world_soap_http.GreeterImpl)1