SpringBusFactory.setThreadDefaultBus(bus);
URL wsdl = ActionTest.class.getResource("DoubleItAction.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleItSignedTimestampPort");
DoubleItPortType port =
service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(port, PORT);
Client cxfClient = ClientProxy.getClient(port);
SecurityHeaderCacheInterceptor cacheInterceptor =
new SecurityHeaderCacheInterceptor();
cxfClient.getOutInterceptors().add(cacheInterceptor);
// Make two invocations with the same SecurityHeader
port.doubleIt(25);
try {
port.doubleIt(25);
fail("Failure expected on a replayed Timestamp");
} catch (javax.xml.ws.soap.SOAPFaultException ex) {
String error = "A replay attack has been detected";
assertTrue(ex.getMessage().contains(error));
}