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);
}
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));
}
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;
}
}
Aggregations