use of javax.xml.ws.handler.Handler in project cxf by apache.
the class JakartaAnnotationHandlerChainBuilderTest method testFindHandlerChainAnnotationPerPortServiceBindingNegative.
@Test
public void testFindHandlerChainAnnotationPerPortServiceBindingNegative() {
JakartaHandlerTestImpl handlerTestImpl = new JakartaHandlerTestImpl();
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 LogicalHandlerInterceptorTest method testInterceptSuccess.
@Test
public void testInterceptSuccess() {
List<LogicalHandler<?>> list = new ArrayList<>();
list.add(new LogicalHandler<LogicalMessageContext>() {
public void close(MessageContext arg0) {
}
public boolean handleFault(LogicalMessageContext arg0) {
return true;
}
public boolean handleMessage(LogicalMessageContext arg0) {
return true;
}
});
@SuppressWarnings("rawtypes") List<Handler> hList = CastUtils.cast(list);
expect(binding.getHandlerChain()).andReturn(hList).anyTimes();
expect(invoker.getLogicalHandlers()).andReturn(list);
expect(message.getExchange()).andReturn(exchange).anyTimes();
expect(message.get(Message.REQUESTOR_ROLE)).andReturn(Boolean.TRUE).anyTimes();
expect(message.keySet()).andReturn(new TreeSet<String>()).anyTimes();
expect(exchange.get(HandlerChainInvoker.class)).andReturn(invoker);
expect(exchange.getOutMessage()).andReturn(message);
expect(invoker.invokeLogicalHandlers(eq(true), isA(LogicalMessageContext.class))).andReturn(true);
control.replay();
LogicalHandlerInInterceptor li = new LogicalHandlerInInterceptor(binding);
assertEquals("unexpected phase", "pre-protocol-frontend", li.getPhase());
li.handleMessage(message);
control.verify();
}
use of javax.xml.ws.handler.Handler in project cxf by apache.
the class LogicalHandlerInterceptorTest method xtestReturnFalseClientSide.
// JAX-WS spec: If handler returns false, for a request-response MEP, if the message
// direction is reversed during processing of a request message then the message
// becomes a response message.
// NOTE: commented out as this has been covered by other tests.
@Test
@org.junit.Ignore
public void xtestReturnFalseClientSide() throws Exception {
@SuppressWarnings("rawtypes") List<Handler> list = new ArrayList<>();
list.add(new LogicalHandler<LogicalMessageContext>() {
public void close(MessageContext arg0) {
}
public boolean handleFault(LogicalMessageContext messageContext) {
return true;
}
public boolean handleMessage(LogicalMessageContext messageContext) {
LogicalMessage msg = messageContext.getMessage();
AddNumbersResponse resp = new AddNumbersResponse();
resp.setReturn(11);
msg.setPayload(resp, null);
return false;
}
});
HandlerChainInvoker invoker1 = new HandlerChainInvoker(list);
IMocksControl control1 = createNiceControl();
Binding binding1 = control1.createMock(Binding.class);
@SuppressWarnings("rawtypes") List<Handler> hList = CastUtils.cast(list);
expect(binding1.getHandlerChain()).andReturn(hList).anyTimes();
Exchange exchange1 = control1.createMock(Exchange.class);
expect(exchange1.get(HandlerChainInvoker.class)).andReturn(invoker1).anyTimes();
Message outMessage = new MessageImpl();
outMessage.setExchange(exchange1);
InterceptorChain chain = control1.createMock(InterceptorChain.class);
outMessage.setInterceptorChain(chain);
chain.abort();
EasyMock.expectLastCall();
MessageObserver observer = control1.createMock(MessageObserver.class);
expect(exchange1.get(MessageObserver.class)).andReturn(observer).anyTimes();
observer.onMessage(isA(Message.class));
EasyMock.expectLastCall();
control1.replay();
LogicalHandlerInInterceptor li = new LogicalHandlerInInterceptor(binding1);
li.handleMessage(outMessage);
control1.verify();
}
use of javax.xml.ws.handler.Handler in project cxf by apache.
the class HandlerInvocationUsingAddNumbersTest method testHandlerInjectingResource.
@Test
public void testHandlerInjectingResource() throws Exception {
// When CXF is deployed in a servlet container, ServletContextResourceResolver is used to resolve
// Servlet context resources.
Bus bus = BusFactory.getDefaultBus();
ResourceManager resourceManager = bus.getExtension(ResourceManager.class);
assertNotNull(resourceManager);
resourceManager.addResourceResolver(new TestResourceResolver());
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);
assertEquals("injectedValue", h.getInjectedString());
}
use of javax.xml.ws.handler.Handler in project quickstart by wildfly.
the class WSATSimpleServletClient method doGet.
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
/*
* Add client handler chain
*/
BindingProvider bindingProvider = (BindingProvider) client;
@SuppressWarnings("rawtypes") List<Handler> handlers = new ArrayList<>(1);
handlers.add(new JaxWSHeaderContextProcessor());
bindingProvider.getBinding().setHandlerChain(handlers);
/*
* Lookup the DNS name of the server from the environment and set the endpoint address on the client.
*/
String openshift = System.getenv("OPENSHIFT_APP_DNS");
if (openshift != null) {
bindingProvider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://" + openshift + "/RestaurantServiceAT");
}
resp.setContentType("text/html");
PrintWriter out = resp.getWriter();
out.write("<h1>Quickstart: This example demonstrates the deployment of a WS-AT (WS-AtomicTransaction) enabled JAX-WS Web service bundled in a war archive for deployment to *Red Hat JBoss Enterprise Application Platform*.</h1>");
System.out.println("[CLIENT] Creating a new WS-AT User Transaction");
UserTransaction ut = UserTransactionFactory.userTransaction();
try {
System.out.println("[CLIENT] Beginning Atomic Transaction (All calls to Web services that support WS-AT wil be included in this transaction)");
ut.begin();
System.out.println("[CLIENT] invoking makeBooking() on WS");
client.makeBooking();
System.out.println("[CLIENT] committing Atomic Transaction (This will cause the AT to complete successfully)");
ut.commit();
out.write("<p><b>Transaction succeeded!</b></p>");
} catch (Exception e) {
e.printStackTrace();
out.write("<p><b>Transaction failed with the following error:</b></p>");
out.write("<p><blockquote>");
out.write(e.toString());
out.write("</blockquote></p>");
} finally {
rollbackIfActive(ut);
client.reset();
out.write("<p><i>Go to your JBoss EAP Server console or log to see the detailed result of the transaction.</i></p>");
}
}
Aggregations