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);
}
}
use of org.apache.cxf.transport.http.HTTPConduit in project fabric8 by fabric8io.
the class WebClients method configureClientCert.
public static void configureClientCert(WebClient webClient, String clientCertData, File clientCertFile, String clientKeyData, File clientKeyFile, String clientKeyAlgo, char[] clientKeyPassword) {
try {
KeyStore keyStore = createKeyStore(clientCertData, clientCertFile, clientKeyData, clientKeyFile, clientKeyAlgo, clientKeyPassword);
KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
keyManagerFactory.init(keyStore, clientKeyPassword);
KeyManager[] keyManagers = keyManagerFactory.getKeyManagers();
HTTPConduit conduit = WebClient.getConfig(webClient).getHttpConduit();
TLSClientParameters params = conduit.getTlsClientParameters();
if (params == null) {
params = new TLSClientParameters();
conduit.setTlsClientParameters(params);
}
KeyManager[] existingKeyManagers = params.getKeyManagers();
if (existingKeyManagers != null && existingKeyManagers.length > 0) {
List<KeyManager> list = new ArrayList<>();
list.addAll(Arrays.asList(existingKeyManagers));
list.addAll(Arrays.asList(keyManagers));
keyManagers = list.toArray(new KeyManager[list.size()]);
}
params.setKeyManagers(keyManagers);
} catch (Exception e) {
LOG.error("Could not create key manager for " + clientCertFile + " (" + clientKeyFile + ")", e);
}
}
Aggregations