Search in sources :

Example 6 with Handler

use of javax.xml.ws.handler.Handler in project narayana by jbosstm.

the class TestClient method init.

/**
 * Initialise the servlet.
 *
 * @param config The servlet configuration.
 */
public void init(final ServletConfig config) throws ServletException {
    try {
        URL wsdlLocation = new URL("http://" + getLocalHost() + ":8080/txbridge-inbound-tests-service/TestServiceImpl?wsdl");
        QName serviceName = new QName("http://client.inbound.tests.txbridge.jbossts.jboss.org/", "TestServiceImplService");
        Service service = Service.create(wsdlLocation, serviceName);
        testService = service.getPort(TestService.class);
        BindingProvider bindingProvider = (BindingProvider) testService;
        List<Handler> handlers = new ArrayList<Handler>(1);
        handlers.add(new JaxWSHeaderContextProcessor());
        bindingProvider.getBinding().setHandlerChain(handlers);
        context = config.getServletContext();
    } catch (Exception e) {
        throw new ServletException(e);
    }
}
Also used : ServletException(javax.servlet.ServletException) JaxWSHeaderContextProcessor(com.arjuna.mw.wst11.client.JaxWSHeaderContextProcessor) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) Service(javax.xml.ws.Service) Handler(javax.xml.ws.handler.Handler) BindingProvider(javax.xml.ws.BindingProvider) URL(java.net.URL) ServletException(javax.servlet.ServletException) TransactionRolledBackException(com.arjuna.wst.TransactionRolledBackException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException)

Example 7 with Handler

use of javax.xml.ws.handler.Handler in project narayana by jbosstm.

the class InteropClient method getParticipantPort.

// don't think we ever need this as we get a registration port from the endpoint ref returned by
// the activation port request
public static ParticipantPortType getParticipantPort(MAP map, String action) {
    Sc007Service service = getSc007Service();
    ParticipantPortType port = service.getPort(ParticipantPortType.class, new AddressingFeature(true, true));
    BindingProvider bindingProvider = (BindingProvider) port;
    String to = map.getTo();
    List<Handler> customHandlerChain = new ArrayList<Handler>();
    /*
         * we need to add the coordination context handler in the case where we are passing a
         * coordination context via a header element
         */
    customHandlerChain.add(new CoordinationContextHandler());
    /*
         * we no longer have to add the JaxWS WSAddressingClientHandler because we can specify the WSAddressing feature
		customHandlerChain.add(new WSAddressingClientHandler());
         */
    bindingProvider.getBinding().setHandlerChain(customHandlerChain);
    Map<String, Object> requestContext = bindingProvider.getRequestContext();
    map.setAction(action);
    map.setFrom(getInitiator());
    AddressingHelper.configureRequestContext(requestContext, map, to, action);
    return port;
}
Also used : AddressingFeature(javax.xml.ws.soap.AddressingFeature) ParticipantPortType(com.jboss.transaction.wstf.webservices.sc007.generated.ParticipantPortType) CoordinationContextHandler(com.jboss.transaction.wstf.webservices.handlers.CoordinationContextHandler) ArrayList(java.util.ArrayList) CoordinationContextHandler(com.jboss.transaction.wstf.webservices.handlers.CoordinationContextHandler) Handler(javax.xml.ws.handler.Handler) BindingProvider(javax.xml.ws.BindingProvider) Sc007Service(com.jboss.transaction.wstf.webservices.sc007.generated.Sc007Service)

Example 8 with Handler

use of javax.xml.ws.handler.Handler in project nimbus by nimbus-org.

the class WsPortFactoryService method startService.

public void startService() throws Exception {
    if (wsServiceFactoryName == null) {
        throw new IllegalArgumentException("WsServiceFactoryName must be specified.");
    }
    if (portAliasProp == null) {
        throw new IllegalArgumentException("portAliasProp must be specified.");
    }
    if (handlerServiceNames != null) {
        for (int i = 0; i < handlerServiceNames.length; i++) {
            try {
                Handler handler = (Handler) ServiceManagerFactory.getServiceObject(handlerServiceNames[i]);
                handlerList.add(handler);
            } catch (ClassCastException e) {
                throw new IllegalArgumentException(handlerServiceNames[i] + " is not instanceof Handler." + e);
            }
        }
    }
    WsServiceFactory wsServiceFactory = (WsServiceFactory) ServiceManagerFactory.getServiceObject(wsServiceFactoryName);
    nameSpace = wsServiceFactory.getNameSpace();
    wsService = wsServiceFactory.getService();
}
Also used : Handler(javax.xml.ws.handler.Handler)

Example 9 with Handler

use of javax.xml.ws.handler.Handler in project scout.rt by eclipse.

the class PortProducer method proxyHandler.

/**
 * Proxies the given {@link Handler} to run on behalf of a {@link RunContext}, if the handler is annotated with
 * {@link RunWithRunContext}.
 */
protected Handler<? extends MessageContext> proxyHandler(final Handler<? extends MessageContext> handler) {
    final RunWithRunContext handleWithRunContext = handler.getClass().getAnnotation(RunWithRunContext.class);
    if (handleWithRunContext == null) {
        return handler;
    }
    final RunContextProducer runContextProducer = BEANS.get(handleWithRunContext.value());
    return (Handler<?>) Proxy.newProxyInstance(handler.getClass().getClassLoader(), handler.getClass().getInterfaces(), new InvocationHandler() {

        @Override
        public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
            if (PROXIED_HANDLER_METHODS.contains(method)) {
                return runContextProducer.produce(Subject.getSubject(AccessController.getContext())).call(new Callable<Object>() {

                    @Override
                    public Object call() throws Exception {
                        return method.invoke(handler, args);
                    }
                }, DefaultExceptionTranslator.class);
            } else {
                return method.invoke(handler, args);
            }
        }
    });
}
Also used : RunWithRunContext(org.eclipse.scout.rt.platform.context.RunWithRunContext) Handler(javax.xml.ws.handler.Handler) InvocationHandler(java.lang.reflect.InvocationHandler) RunContextProducer(org.eclipse.scout.rt.platform.context.RunContextProducer) Method(java.lang.reflect.Method) InvocationHandler(java.lang.reflect.InvocationHandler) WebServiceException(javax.xml.ws.WebServiceException)

Example 10 with Handler

use of javax.xml.ws.handler.Handler in project scout.rt by eclipse.

the class ServicePool method proxyHandler.

/**
 * Proxies the given {@link Handler} to run on behalf of a {@link RunContext}, if the handler is annotated with
 * {@link RunWithRunContext}.
 */
protected Handler<? extends MessageContext> proxyHandler(final Handler<? extends MessageContext> handler) {
    final RunWithRunContext handleWithRunContext = handler.getClass().getAnnotation(RunWithRunContext.class);
    if (handleWithRunContext == null) {
        return handler;
    }
    final RunContextProducer runContextProducer = BEANS.get(handleWithRunContext.value());
    return (Handler<?>) Proxy.newProxyInstance(handler.getClass().getClassLoader(), handler.getClass().getInterfaces(), new InvocationHandler() {

        @Override
        public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
            if (PROXIED_HANDLER_METHODS.contains(method)) {
                return runContextProducer.produce(Subject.getSubject(AccessController.getContext())).call(new Callable<Object>() {

                    @Override
                    public Object call() throws Exception {
                        return method.invoke(handler, args);
                    }
                }, DefaultExceptionTranslator.class);
            } else {
                return method.invoke(handler, args);
            }
        }
    });
}
Also used : RunWithRunContext(org.eclipse.scout.rt.platform.context.RunWithRunContext) Handler(javax.xml.ws.handler.Handler) InvocationHandler(java.lang.reflect.InvocationHandler) RunContextProducer(org.eclipse.scout.rt.platform.context.RunContextProducer) Method(java.lang.reflect.Method) InvocationHandler(java.lang.reflect.InvocationHandler) WebServiceException(javax.xml.ws.WebServiceException)

Aggregations

Handler (javax.xml.ws.handler.Handler)100 QName (javax.xml.namespace.QName)47 ArrayList (java.util.ArrayList)46 BindingProvider (javax.xml.ws.BindingProvider)36 URL (java.net.URL)32 Service (javax.xml.ws.Service)29 Test (org.junit.Test)29 LogicalHandler (javax.xml.ws.handler.LogicalHandler)24 Binding (javax.xml.ws.Binding)11 WebServiceException (javax.xml.ws.WebServiceException)11 MessageContext (javax.xml.ws.handler.MessageContext)9 SOAPHandler (javax.xml.ws.handler.soap.SOAPHandler)9 Exchange (org.apache.cxf.message.Exchange)9 IOException (java.io.IOException)8 SOAPMessageContext (javax.xml.ws.handler.soap.SOAPMessageContext)7 HandlerChainInvoker (org.apache.cxf.jaxws.handler.HandlerChainInvoker)7 DataHandler (javax.activation.DataHandler)6 InitialContext (javax.naming.InitialContext)6 Source (javax.xml.transform.Source)6 DOMSource (javax.xml.transform.dom.DOMSource)6