use of org.apache.cxf.transport.http.HTTPConduit 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);
}
}
use of org.apache.cxf.transport.http.HTTPConduit in project jbossws-cxf by jbossws.
the class SOAPConnectionImpl method get.
@Override
public SOAPMessage get(Object addressObject) throws SOAPException {
checkClosed();
String address = getAddress(addressObject);
ConduitInitiator ci = getConduitInitiator(address);
// create a new Message and Exchange
EndpointInfo info = new EndpointInfo();
info.setAddress(address);
Message outMessage = new MessageImpl();
Exchange exch = new ExchangeImpl();
outMessage.setExchange(exch);
// sent GET request
try {
// TODO verify bus
final Conduit c = ci.getConduit(info, BusFactory.getThreadDefaultBus(false));
if (c instanceof HTTPConduit) {
((HTTPConduit) c).getClient().setAutoRedirect(true);
}
outMessage.put(Message.HTTP_REQUEST_METHOD, "GET");
c.prepare(outMessage);
c.setMessageObserver(createMessageObserver(c));
c.close(outMessage);
} catch (Exception ex) {
throw MESSAGES.getRequestCouldNotBeSent(ex);
}
// read SOAPMessage
return readSoapMessage(exch);
}
use of org.apache.cxf.transport.http.HTTPConduit in project jbossws-cxf by jbossws.
the class AddressingTestCase method testDecoupledEndpointForLongLastingProcessingOfInvocations.
/**
* This shows the usage of decoupled-endpoint for getting back response on a new http connection.
* The CXF client basically creates a destination listening at the provided decoupled endpoint address, using the
* configured http transport factory. The client gets back a HTTP 202 accept response message immediately after
* the call to the server, then once the actual response comes back to the decoupled endpoint, the client is
* notified and returns control to the application code.
*
* @throws Exception
*/
@Test
@RunAsClient
public void testDecoupledEndpointForLongLastingProcessingOfInvocations() throws Exception {
final Bus bus = BusFactory.newInstance().createBus();
BusFactory.setThreadDefaultBus(bus);
try {
// construct proxy
QName serviceName = new QName("http://www.jboss.org/jbossws/ws-extensions/wsaddressing", "AddressingService");
URL wsdlURL = new URL(baseURL + "/jaxws-samples-wsa/AddressingService?wsdl");
Service service = Service.create(wsdlURL, serviceName, new UseThreadBusFeature());
ServiceIface proxy = (ServiceIface) service.getPort(ServiceIface.class);
Client client = ClientProxy.getClient(proxy);
HTTPConduit conduit = (HTTPConduit) client.getConduit();
HTTPClientPolicy policy = conduit.getClient();
// set low connection and receive timeouts to ensure the http client can't keep the connection open till the response is received
// 5 secs
policy.setConnectionTimeout(5000);
// 10 secs
policy.setReceiveTimeout(10000);
try {
// this takes at least 30 secs
proxy.sayHello("Sleepy");
fail("Timeout exception expected");
} catch (WebServiceException e) {
assertTrue(e.getCause() instanceof SocketTimeoutException);
}
policy.setDecoupledEndpoint("http://" + getServerHost() + ":18181/jaxws-samples-wsa/decoupled-endpoint");
// this takes at least 30 secs... but now the client doesn't time out
String response = proxy.sayHello("Sleepy");
assertEquals("Hello Sleepy!", response);
} finally {
bus.shutdown(true);
}
}
use of org.apache.cxf.transport.http.HTTPConduit in project fabric8 by fabric8io.
the class WebClients method disableSslChecks.
public static void disableSslChecks(WebClient webClient) {
HTTPConduit conduit = WebClient.getConfig(webClient).getHttpConduit();
TLSClientParameters params = conduit.getTlsClientParameters();
if (params == null) {
params = new TLSClientParameters();
conduit.setTlsClientParameters(params);
}
params.setTrustManagers(new TrustManager[] { new TrustEverythingSSLTrustManager() });
params.setDisableCNCheck(true);
}
use of org.apache.cxf.transport.http.HTTPConduit in project fabric8 by fabric8io.
the class WebClients method configureUserAndPassword.
public static void configureUserAndPassword(WebClient webClient, String username, String password) {
if (Strings.isNotBlank(username) && Strings.isNotBlank(password)) {
HTTPConduit conduit = WebClient.getConfig(webClient).getHttpConduit();
conduit.getAuthorization().setUserName(username);
conduit.getAuthorization().setPassword(password);
}
}
Aggregations