assertNotNull("WSDL is null", wsdl);
SOAPService service = new SOAPService(wsdl, serviceName);
assertNotNull("Service is null", service);
Greeter tarpin = service.getPort(tarpinQ, Greeter.class);
assertNotNull("Port is null", tarpin);
// Okay, I'm sick of configuration files.
// This also tests dynamic configuration of the conduit.
Client client = ClientProxy.getClient(tarpin);
HTTPConduit http =
(HTTPConduit) client.getConduit();
HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
httpClientPolicy.setAutoRedirect(true);
// If we set any name, but Edward, Mary, or George,
// and a password of "password" we will get through
// Bethal.
AuthorizationPolicy authPolicy = new AuthorizationPolicy();
authPolicy.setUserName("Betty");
authPolicy.setPassword("password");
http.setClient(httpClientPolicy);
http.setTlsClientParameters(tlsClientParameters);
http.setAuthorization(authPolicy);
// We get redirected from Tarpin, to Gordy, to Bethal.
MyHttpsTrustDecider trustDecider =
new MyHttpsTrustDecider(
new String[] {"Tarpin", "Gordy", "Bethal"});
http.setTrustDecider(trustDecider);
// We actually get our answer from Bethal at the end of the
// redirects.
String answer = tarpin.sayHi();
assertTrue("Trust Decider wasn't called correctly",
3 == trustDecider.wasCalled());
assertTrue("Unexpected answer: " + answer,
"Bonjour from Bethal".equals(answer));
// Limit the redirects to 1, since there are two, this should fail.
http.getClient().setMaxRetransmits(1);
try {
answer = tarpin.sayHi();
fail("Unexpected answer from Tarpin: " + answer);
} catch (Exception e) {
//e.printStackTrace();
}
// Set back to unlimited.
http.getClient().setMaxRetransmits(-1);
// Effectively we will not trust Gordy in the middle.
trustDecider =
new MyHttpsTrustDecider(
new String[] {"Tarpin", "Bethal"});
http.setTrustDecider(trustDecider);
try {
answer = tarpin.sayHi();
fail("Unexpected answer from Tarpin: " + answer);
} catch (Exception e) {
//e.printStackTrace();
assertTrue("Trust Decider wasn't called correctly",
2 == trustDecider.wasCalled());