SpringBusFactory bf = new SpringBusFactory();
Bus bus = bf.createBus();
BasicGreeterService gs = new BasicGreeterService();
final Greeter greeter = gs.getGreeterPort();
updateAddressPort(greeter, PORT);
LoggingInInterceptor in = new LoggingInInterceptor();
LoggingOutInterceptor out = new LoggingOutInterceptor();
bus.getInInterceptors().add(in);
bus.getOutInterceptors().add(out);
LOG.fine("Created greeter client.");
// sayHi - this operation has message policies that are incompatible with
// the endpoint policies
try {
greeter.sayHi();
fail("Did not receive expected Exception.");
} catch (WebServiceException wse) {
SoapFault sf = (SoapFault)wse.getCause();
assertEquals("Server", sf.getFaultCode().getLocalPart());
String text = sf.getMessage();
assertTrue(text.contains("{http://cxf.apache.org/transports/http/configuration}server"));
// assertEquals("INCOMPATIBLE_HTTPSERVERPOLICY_ASSERTIONS", ex.getCode());
}
// greetMe - no operation or message specific policies
assertEquals("CXF", greeter.greetMe("cxf"));
// pingMe - policy attached to binding operation fault should have no effect
try {
greeter.pingMe();
fail("Expected PingMeFault not thrown.");
} catch (PingMeFault ex) {
assertEquals(2, (int)ex.getFaultInfo().getMajor());
assertEquals(1, (int)ex.getFaultInfo().getMinor());
}