use of javax.xml.ws.handler.Handler in project cxf by apache.
the class SOAPHandlerInterceptorTest method testGetUnderstoodHeadersReturnsNull.
@Test
public void testGetUnderstoodHeadersReturnsNull() {
@SuppressWarnings("rawtypes") List<Handler> list = new ArrayList<>();
list.add(new SOAPHandler<SOAPMessageContext>() {
public boolean handleMessage(SOAPMessageContext smc) {
return true;
}
public boolean handleFault(SOAPMessageContext smc) {
return true;
}
public Set<QName> getHeaders() {
return null;
}
public void close(MessageContext messageContext) {
}
});
HandlerChainInvoker invoker = new HandlerChainInvoker(list);
IMocksControl control = createNiceControl();
Binding binding = control.createMock(Binding.class);
expect(binding.getHandlerChain()).andReturn(list).anyTimes();
SoapMessage message = control.createMock(SoapMessage.class);
Exchange exchange = control.createMock(Exchange.class);
expect(message.getExchange()).andReturn(exchange).anyTimes();
expect(message.keySet()).andReturn(new HashSet<>());
expect(exchange.get(HandlerChainInvoker.class)).andReturn(invoker);
control.replay();
SOAPHandlerInterceptor li = new SOAPHandlerInterceptor(binding);
Set<QName> understood = li.getUnderstoodHeaders();
assertNotNull(understood);
assertTrue(understood.isEmpty());
}
use of javax.xml.ws.handler.Handler 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 javax.xml.ws.handler.Handler in project cxf by apache.
the class HandlerChainBuilderTest method testBuilderCallsInitWithNoInitParamValues.
@Test
public void testBuilderCallsInitWithNoInitParamValues() {
List<PortComponentHandlerType> hc = createHandlerChainType();
hc.remove(3);
hc.remove(2);
hc.remove(1);
PortComponentHandlerType h = hc.get(0);
List<ParamValueType> params = h.getInitParam();
ParamValueType p = new ParamValueType();
CString pName = new CString();
pName.setValue("foo");
p.setParamName(pName);
params.add(p);
List<Handler> chain = builder.buildHandlerChainFromConfiguration(hc);
assertEquals(1, chain.size());
TestLogicalHandler tlh = (TestLogicalHandler) chain.get(0);
assertTrue(tlh.initCalled);
Map cfg = tlh.config;
assertNotNull(tlh.config);
assertEquals(1, cfg.keySet().size());
}
use of javax.xml.ws.handler.Handler in project cxf by apache.
the class JavaxAnnotationHandlerChainBuilderTest method testFindHandlerChainAnnotationPerPortServiceBindingNegative.
@Test
public void testFindHandlerChainAnnotationPerPortServiceBindingNegative() {
JavaxHandlerTestImpl handlerTestImpl = new JavaxHandlerTestImpl();
AnnotationHandlerChainBuilder chainBuilder = new AnnotationHandlerChainBuilder();
QName portQName = new QName("namespacedoesntsupportyet", "SoapPortUnknown");
QName serviceQName = new QName("namespacedoesntsupportyet", "SoapServiceUnknown");
String bindingID = "BindingUnknow";
@SuppressWarnings("rawtypes") List<Handler> handlers = chainBuilder.buildHandlerChainFromClass(handlerTestImpl.getClass(), portQName, serviceQName, bindingID);
assertNotNull(handlers);
assertEquals(3, handlers.size());
}
use of javax.xml.ws.handler.Handler in project cxf by apache.
the class JavaxAnnotationHandlerChainBuilderTest method testFindHandlerChainAnnotationPerPortServiceBinding.
@Test
public void testFindHandlerChainAnnotationPerPortServiceBinding() {
JavaxHandlerTestImpl handlerTestImpl = new JavaxHandlerTestImpl();
AnnotationHandlerChainBuilder chainBuilder = new AnnotationHandlerChainBuilder();
QName portQName = new QName("namespacedoesntsupportyet", "SoapPort1");
QName serviceQName = new QName("namespacedoesntsupportyet", "SoapService1");
String bindingID = "http://schemas.xmlsoap.org/wsdl/soap/http";
@SuppressWarnings("rawtypes") List<Handler> handlers = chainBuilder.buildHandlerChainFromClass(handlerTestImpl.getClass(), portQName, serviceQName, bindingID);
assertNotNull(handlers);
assertEquals(5, handlers.size());
}
Aggregations