use of javax.xml.ws.Binding in project cxf by apache.
the class WSSecurityClientTest method testTimestampSignEncrypt.
@Test
public void testTimestampSignEncrypt() throws Exception {
Bus b = new SpringBusFactory().createBus("org/apache/cxf/systest/ws/security/client.xml");
BusFactory.setDefaultBus(b);
final javax.xml.ws.Service svc = javax.xml.ws.Service.create(WSDL_LOC, GREETER_SERVICE_QNAME);
final Greeter greeter = svc.getPort(TIMESTAMP_SIGN_ENCRYPT_PORT_QNAME, Greeter.class);
updateAddressPort(greeter, test.getPort());
// Add a No-Op JAX-WS SoapHandler to the dispatch chain to
// verify that the SoapHandlerInterceptor can peacefully co-exist
// with the explicitly configured SAAJOutInterceptor
//
@SuppressWarnings("rawtypes") List<Handler> handlerChain = new ArrayList<>();
Binding binding = ((BindingProvider) greeter).getBinding();
TestOutHandler handler = new TestOutHandler();
handlerChain.add(handler);
binding.setHandlerChain(handlerChain);
greeter.sayHi();
assertTrue("expected Handler.handleMessage() to be called", handler.handleMessageCalledOutbound);
assertFalse("expected Handler.handleFault() not to be called", handler.handleFaultCalledOutbound);
((java.io.Closeable) greeter).close();
b.shutdown(true);
BusFactory.setDefaultBus(getStaticBus());
}
use of javax.xml.ws.Binding in project cxf by apache.
the class JMSTestMtom method startServers.
@BeforeClass
public static void startServers() throws Exception {
broker = new EmbeddedJMSBrokerLauncher();
broker.startInProcess();
bus = BusFactory.getDefaultBus();
broker.updateWsdl(bus, "testutils/jms_test_mtom.wsdl");
Object mtom = new JMSMTOMImpl();
EndpointImpl ep = (EndpointImpl) Endpoint.publish("jms:jndi:dynamicQueues/test.cxf.jmstransport.queue&receiveTimeout=10000", mtom);
Binding binding = ep.getBinding();
((SOAPBinding) binding).setMTOMEnabled(true);
}
use of javax.xml.ws.Binding in project uavstack by uavorg.
the class JaxWSHookIT method getPort.
/**
* this is for Client Stub Programming
*
* @param t
* @param s
* @param args
* @return
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
public <T> T getPort(T t, Service s, Object[] args) {
if (JDKProxyInvokeUtil.isJDKProxy(t)) {
return t;
}
Class<T> clz = null;
if (Class.class.isAssignableFrom(args[0].getClass())) {
clz = (Class<T>) args[0];
} else if (Class.class.isAssignableFrom(args[1].getClass())) {
clz = (Class<T>) args[1];
}
if (clz == null) {
return t;
}
Binding binding = ((BindingProvider) t).getBinding();
List<Handler> handlerChain = binding.getHandlerChain();
handlerChain.add(this.handler);
binding.setHandlerChain(handlerChain);
final String wsdlLocation = getServiceURL(s);
T tProxy = JDKProxyInvokeUtil.newProxyInstance(clz.getClassLoader(), new Class[] { clz }, new JDKProxyInvokeHandler<T>(t, new ClientStubProcessor(wsdlLocation.toString(), this.handler)));
return tProxy;
}
use of javax.xml.ws.Binding in project uavstack by uavorg.
the class JaxWSCxfHookIT method create.
@SuppressWarnings({ "unchecked", "rawtypes" })
public <T> T create(T t, ClientFactoryBean clientFactoryBean) {
Binding binding = ((BindingProvider) t).getBinding();
List<Handler> handlerChain = binding.getHandlerChain();
handlerChain.add(this.handler);
binding.setHandlerChain(handlerChain);
String wsdlLocation = clientFactoryBean.getAddress();
T tProxy = JDKProxyInvokeUtil.newProxyInstance(clientFactoryBean.getServiceClass().getClassLoader(), new Class[] { clientFactoryBean.getServiceClass() }, new JDKProxyInvokeHandler<T>(t, new ClientStubProcessor(wsdlLocation.toString(), this.handler)));
return tProxy;
}
use of javax.xml.ws.Binding in project tomee by apache.
the class EjbInterceptor method intercept.
@AroundInvoke
public Object intercept(InvocationContext context) throws Exception {
Endpoint endpoint = this.exchange.get(Endpoint.class);
Service service = endpoint.getService();
Binding binding = ((JaxWsEndpointImpl) endpoint).getJaxwsBinding();
this.exchange.put(InvocationContext.class, context);
if (binding.getHandlerChain() == null || binding.getHandlerChain().isEmpty()) {
// no handlers so let's just directly invoke the bean
log.debug("No handlers found.");
EjbMethodInvoker invoker = (EjbMethodInvoker) service.getInvoker();
return invoker.directEjbInvoke(this.exchange, this.method, this.params);
} else {
// have handlers so have to run handlers now and redo data binding
// as handlers can change the soap message
log.debug("Handlers found.");
Message inMessage = exchange.getInMessage();
PhaseInterceptorChain chain = new PhaseInterceptorChain(bus.getExtension(PhaseManager.class).getInPhases());
chain.setFaultObserver(endpoint.getOutFaultObserver());
/*
* Since we have to re-do data binding and the XMLStreamReader
* contents are already consumed by prior data binding step
* we have to reinitialize the XMLStreamReader from the SOAPMessage
* created by SAAJInInterceptor.
*/
if (inMessage instanceof SoapMessage) {
try {
reserialize((SoapMessage) inMessage);
} catch (Exception e) {
throw new ServerRuntimeException("Failed to reserialize soap message", e);
}
} else {
// TODO: how to handle XML/HTTP binding?
}
this.exchange.setOutMessage(null);
// install default interceptors
chain.add(new ServiceInvokerInterceptor());
// chain.add(new OutgoingChainInterceptor()); // it is already in the enclosing chain, if we add it there we are in the tx so we write the message in the tx!
// See http://cwiki.apache.org/CXF20DOC/interceptors.html
// install Holder and Wrapper interceptors
chain.add(new WrapperClassInInterceptor());
chain.add(new HolderInInterceptor());
// install interceptors for handler processing
chain.add(new MustUnderstandInterceptor());
chain.add(new LogicalHandlerInInterceptor(binding));
chain.add(new SOAPHandlerInterceptor(binding));
// install data binding interceptors - todo: check we need it
copyDataBindingInterceptors(chain, inMessage.getInterceptorChain());
InterceptorChain oldChain = inMessage.getInterceptorChain();
inMessage.setInterceptorChain(chain);
try {
chain.doIntercept(inMessage);
} finally {
inMessage.setInterceptorChain(oldChain);
}
// TODO: the result should be deserialized from SOAPMessage
Object result = getResult();
return result;
}
}
Aggregations