use of org.apache.handlers.AddNumbers in project cxf by apache.
the class Client method main.
public static void main(String[] args) throws Exception {
if (args.length == 0) {
System.err.println("please provide wsdl");
System.exit(0);
}
File wsdl = new File(args[0]);
AddNumbersService service = new AddNumbersService(wsdl.toURI().toURL(), serviceName);
AddNumbers port = (AddNumbers) service.getPort(portName, AddNumbers.class);
// Add client side handlers programmatically
SmallNumberHandler sh = new SmallNumberHandler();
List<Handler> newHandlerChain = new ArrayList<>();
newHandlerChain.add(sh);
((BindingProvider) port).getBinding().setHandlerChain(newHandlerChain);
try {
int number1 = 10;
int number2 = 20;
System.out.printf("Invoking addNumbers(%d, %d)\n", number1, number2);
int result = port.addNumbers(number1, number2);
System.out.printf("The result of adding %d and %d is %d.\n\n", number1, number2, result);
number1 = 3;
number2 = 5;
System.out.printf("Invoking addNumbers(%d, %d)\n", number1, number2);
result = port.addNumbers(number1, number2);
System.out.printf("The result of adding %d and %d is %d.\n\n", number1, number2, result);
number1 = -10;
System.out.printf("Invoking addNumbers(%d, %d)\n", number1, number2);
result = port.addNumbers(number1, number2);
System.out.printf("The result of adding %d and %d is %d.\n", number1, number2, result);
} catch (AddNumbersFault ex) {
System.out.printf("Caught AddNumbersFault: %s\n", ex.getFaultInfo().getMessage());
}
System.exit(0);
}
use of org.apache.handlers.AddNumbers in project cxf by apache.
the class HandlerInvocationUsingAddNumbersTest method testHandlerPostConstruct.
@Test
public void testHandlerPostConstruct() throws Exception {
URL wsdl = getClass().getResource("/wsdl/addNumbers.wsdl");
AddNumbersServiceWithAnnotation service = new AddNumbersServiceWithAnnotation(wsdl, serviceName);
AddNumbers port = service.getPort(portName, AddNumbers.class);
setAddress(port, addNumbersAddress);
@SuppressWarnings("rawtypes") List<Handler> handlerChain = ((BindingProvider) port).getBinding().getHandlerChain();
SmallNumberHandler h = (SmallNumberHandler) handlerChain.get(0);
assertTrue(h.isPostConstructInvoked());
}
use of org.apache.handlers.AddNumbers in project cxf by apache.
the class HandlerInvocationUsingAddNumbersTest method testAddHandlerProgrammaticallyClientSide.
@Test
public void testAddHandlerProgrammaticallyClientSide() throws Exception {
URL wsdl = getClass().getResource("/wsdl/addNumbers.wsdl");
AddNumbersService service = new AddNumbersService(wsdl, serviceName);
AddNumbers port = service.getPort(portName, AddNumbers.class);
setAddress(port, addNumbersAddress);
SmallNumberHandler sh = new SmallNumberHandler();
addHandlersProgrammatically((BindingProvider) port, sh);
int result = port.addNumbers(10, 20);
assertEquals(200, result);
int result1 = port.addNumbers(5, 6);
assertEquals(11, result1);
}
use of org.apache.handlers.AddNumbers in project cxf by apache.
the class SpringConfiguredHandlerTest method testSpringConfiguresHandlers.
@Test
public void testSpringConfiguresHandlers() throws Exception {
AddNumbers addNumbers = getApplicationContext().getBean("cxfHandlerTestClientEndpoint", AddNumbers.class);
int r = addNumbers.addNumbers(10, 15);
assertEquals(1015, r);
addNumbers = getApplicationContext().getBean("cxfHandlerTestClientEndpointNoHandler", AddNumbers.class);
r = addNumbers.addNumbers(10, 15);
assertEquals(115, r);
addNumbers = getApplicationContext().getBean("cxfHandlerTestClientServer", AddNumbers.class);
r = addNumbers.addNumbers(10, 15);
assertEquals(1015, r);
}
use of org.apache.handlers.AddNumbers in project cxf by apache.
the class SpringConfiguredNoAutoRewriteSoapAddressTest method testWsdlAddress.
@Test
public void testWsdlAddress() throws Exception {
AddNumbers addNumbers = getApplicationContext().getBean("cxfHandlerTestClientEndpoint", AddNumbers.class);
int r = addNumbers.addNumbers(10, 15);
assertEquals(1015, r);
List<String> serviceUrls = findAllServiceUrlsFromWsdl("localhost", port);
assertEquals(1, serviceUrls.size());
assertEquals("http://localhost:" + port + "/SpringEndpoint", serviceUrls.get(0));
String version = System.getProperty("java.version");
if (version.startsWith("1.8")) {
// Just skip the test as "127.0.0.1" doesn't work in JDK8
return;
}
serviceUrls = findAllServiceUrlsFromWsdl("127.0.0.1", port);
assertEquals(1, serviceUrls.size());
assertEquals("http://localhost:" + port + "/SpringEndpoint", serviceUrls.get(0));
}
Aggregations