use of org.apache.cxf.transports.http.configuration.HTTPClientPolicy in project cu-kfs by CU-CommunityApps.
the class PaymentWorksWebServiceCallsServiceImpl method disableRequestChunkingIfNecessary.
private void disableRequestChunkingIfNecessary(Client client, Invocation.Builder requestBuilder) {
if (client instanceof org.apache.cxf.jaxrs.client.spec.ClientImpl) {
LOG.info("disableRequestChunkingIfNecessary: Explicitly disabling chunking because KFS is using a JAX-RS client of CXF type " + client.getClass().getName());
ClientConfiguration cxfConfig = WebClient.getConfig(requestBuilder);
HTTPConduit conduit = cxfConfig.getHttpConduit();
HTTPClientPolicy clientPolicy = conduit.getClient();
clientPolicy.setAllowChunking(false);
} else {
LOG.info("disableRequestChunkingIfNecessary: There is no need to explicitly disable chunking for a JAX-RS client of type " + client.getClass().getName());
}
}
use of org.apache.cxf.transports.http.configuration.HTTPClientPolicy in project jbossws-cxf by jbossws.
the class Helper method testFailureGZIPServerSideOnlyInterceptorOnClient.
public boolean testFailureGZIPServerSideOnlyInterceptorOnClient() throws Exception {
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");
try {
port.echo("foo");
return false;
} catch (Exception e) {
// expected exception, as the client is not able to decode gzip message
return true;
}
}
use of org.apache.cxf.transports.http.configuration.HTTPClientPolicy in project jbossws-cxf by jbossws.
the class HTTPConduitTestCase method testWrapperWithMap.
@Test
@RunAsClient
public void testWrapperWithMap() throws Exception {
Bus bus = BusFactory.newInstance().createBus();
BusFactory.setThreadDefaultBus(bus);
try {
Map<String, Object> map = new HashMap<String, Object>();
map.put(Constants.CXF_CLIENT_ALLOW_CHUNKING, true);
map.put(Constants.CXF_CLIENT_CHUNKING_THRESHOLD, 8192);
map.put(Constants.CXF_CLIENT_CONNECTION_TIMEOUT, 16384L);
map.put(Constants.CXF_CLIENT_RECEIVE_TIMEOUT, 163840L);
map.put(Constants.CXF_TLS_CLIENT_DISABLE_CN_CHECK, true);
replaceWrapper(map, bus);
URL wsdlURL = new URL(baseURL + "/ServiceOne" + "?wsdl");
Service service = Service.create(wsdlURL, new QName("http://org.jboss.ws.jaxws.cxf/httpConduit", "ServiceOne"));
EndpointOne port = service.getPort(new QName("http://org.jboss.ws.jaxws.cxf/httpConduit", "EndpointOnePort"), EndpointOne.class);
HTTPConduit conduit = (HTTPConduit) ClientProxy.getClient(port).getConduit();
HTTPClientPolicy client = conduit.getClient();
assertNotNull(client);
assertEquals(true, client.isAllowChunking());
assertEquals(8192, client.getChunkingThreshold());
assertEquals(16384, client.getConnectionTimeout());
assertEquals(163840, client.getReceiveTimeout());
assertEquals(true, conduit.getTlsClientParameters().isDisableCNCheck());
assertEquals("Foo", port.echo("Foo"));
} finally {
bus.shutdown(true);
}
}
use of org.apache.cxf.transports.http.configuration.HTTPClientPolicy in project jbossws-cxf by jbossws.
the class HTTPProxyTestCaseForked method testHttpProxyUsingHTTPClientPolicy.
@Test
@RunAsClient
public void testHttpProxyUsingHTTPClientPolicy() throws Exception {
if (checkNativeLibraries()) {
initProxyServer();
} else {
return;
}
final String testHost = "unreachable-testHttpProxyUsingHTTPClientPolicy";
HelloWorld port = getPort(getResourceURL("jaxws/cxf/httpproxy/HelloWorldService.wsdl"), testHost);
final String hi = "Hi!";
// first try without setting up the proxy -> request fails because the host is not known/reachable
try {
port.echo(hi);
fail("Exception expected");
} catch (Exception e) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
e.printStackTrace(new PrintStream(baos));
assertTrue(baos.toString().contains(testHost));
}
// then setup the proxy, but provide no authentication/authorization info -> request fails because of HTTP 407
Client client = ClientProxy.getClient(port);
HTTPConduit conduit = (HTTPConduit) client.getConduit();
HTTPClientPolicy clientPolicy = conduit.getClient();
clientPolicy.setProxyServerType(ProxyServerType.HTTP);
clientPolicy.setProxyServer(getServerHost());
clientPolicy.setProxyServerPort(proxyPort);
try {
port.echo(hi);
fail("Exception expected");
} catch (Exception e) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
e.printStackTrace(new PrintStream(baos));
assertTrue(baos.toString().contains("407: Proxy Authentication Required"));
}
// finally setup authorization info too
ProxyAuthorizationPolicy authPolicy = new ProxyAuthorizationPolicy();
authPolicy.setAuthorizationType("Basic");
authPolicy.setUserName(PROXY_USER);
authPolicy.setPassword(PROXY_PWD);
conduit.setProxyAuthorization(authPolicy);
assertEquals(hi, port.echo(hi));
}
use of org.apache.cxf.transports.http.configuration.HTTPClientPolicy 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);
}
}
Aggregations