Search in sources :

Example 56 with Handler

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

the class TestServiceATClient method getClientWithManuallyAddedHandler.

public static TestServiceAT getClientWithManuallyAddedHandler() throws MalformedURLException {
    TestServiceATClient client = new TestServiceATClient();
    Service service = Service.create(new URL(WSDL_URL), SERVICE_NAME);
    client.testService = service.getPort(PORT_NAME, TestServiceAT.class);
    BindingProvider bindingProvider = (BindingProvider) client.testService;
    @SuppressWarnings("rawtypes") List<Handler> handlers = new ArrayList<Handler>(1);
    handlers.add(new JaxWSHeaderContextProcessor());
    bindingProvider.getBinding().setHandlerChain(handlers);
    return client;
}
Also used : JaxWSHeaderContextProcessor(com.arjuna.mw.wst11.client.JaxWSHeaderContextProcessor) ArrayList(java.util.ArrayList) Service(javax.xml.ws.Service) Handler(javax.xml.ws.handler.Handler) BindingProvider(javax.xml.ws.BindingProvider) URL(java.net.URL)

Example 57 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 {
        Context ic = new InitialContext();
        userTransaction = (UserTransaction) ic.lookup("java:comp/UserTransaction");
        URL wsdlLocation = new URL("http://" + getLocalHost() + ":8080/txbridge-outbound-tests-service/TestServiceImpl?wsdl");
        QName serviceName = new QName("http://client.outbound.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>(2);
        handlers.add(new JaxWSTxOutboundBridgeHandler());
        handlers.add(new JaxWSHeaderContextProcessor());
        bindingProvider.getBinding().setHandlerChain(handlers);
        context = config.getServletContext();
    } catch (Exception e) {
        throw new ServletException(e);
    }
}
Also used : Context(javax.naming.Context) InitialContext(javax.naming.InitialContext) ServletContext(javax.servlet.ServletContext) JaxWSHeaderContextProcessor(com.arjuna.mw.wst11.client.JaxWSHeaderContextProcessor) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) Service(javax.xml.ws.Service) JaxWSTxOutboundBridgeHandler(org.jboss.jbossts.txbridge.outbound.JaxWSTxOutboundBridgeHandler) Handler(javax.xml.ws.handler.Handler) BindingProvider(javax.xml.ws.BindingProvider) JaxWSTxOutboundBridgeHandler(org.jboss.jbossts.txbridge.outbound.JaxWSTxOutboundBridgeHandler) InitialContext(javax.naming.InitialContext) URL(java.net.URL) ServletException(javax.servlet.ServletException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) RollbackException(com.arjuna.ats.jta.exceptions.RollbackException) ServletException(javax.servlet.ServletException)

Example 58 with Handler

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

the class TestATClient method getServiceWithManualHandlers.

private CommonTestService getServiceWithManualHandlers(boolean isWSATService) {
    CommonTestService testService;
    if (isWSATService) {
        Service service = Service.create(wsatServiceWsdlLocation, wsatServiceName);
        testService = service.getPort(TestATService.class);
    } else {
        Service service = Service.create(simpleServiceWsdlLocation, simpleServiceName);
        testService = service.getPort(TestNonATService.class);
    }
    BindingProvider bindingProvider = (BindingProvider) testService;
    List<Handler> handlers = new ArrayList<Handler>(2);
    handlers.add(new JaxWSTxOutboundBridgeHandler());
    handlers.add(new JaxWSHeaderContextProcessor());
    bindingProvider.getBinding().setHandlerChain(handlers);
    return testService;
}
Also used : JaxWSHeaderContextProcessor(com.arjuna.mw.wst11.client.JaxWSHeaderContextProcessor) ArrayList(java.util.ArrayList) Service(javax.xml.ws.Service) JaxWSTxOutboundBridgeHandler(org.jboss.jbossts.txbridge.outbound.JaxWSTxOutboundBridgeHandler) Handler(javax.xml.ws.handler.Handler) BindingProvider(javax.xml.ws.BindingProvider) JaxWSTxOutboundBridgeHandler(org.jboss.jbossts.txbridge.outbound.JaxWSTxOutboundBridgeHandler)

Example 59 with Handler

use of javax.xml.ws.handler.Handler in project csb-sdk by aliyun.

the class BindingInterceptor method before.

/* packaged */
List<Handler> before(Object proxy) throws JAXBException {
    // 拦截器BindingInterceptor方法调用:before()!");
    if (!(proxy instanceof BindingProvider)) {
        throw new WSClientException("proxy is not a legal soap client, can not do the interceptor");
    }
    // put security info into http request headers for over-proxy invocation
    setSecrectHeaders((BindingProvider) proxy, wsparams);
    // skip this soap header logic
    if (HEADERS_INSOAP) {
        shh = new SOAPHeaderHandler(wsparams);
        BindingProvider bp = (BindingProvider) proxy;
        handlers = bp.getBinding().getHandlerChain();
        List<Handler> newHandlers = new ArrayList<Handler>();
        if (handlers != null) {
            newHandlers.addAll(handlers);
        }
        newHandlers.add(shh);
        // tip, must set the handleList again, or the handler will not
        // run!!!
        bp.getBinding().setHandlerChain(newHandlers);
    }
    return handlers;
}
Also used : ArrayList(java.util.ArrayList) Handler(javax.xml.ws.handler.Handler) BindingProvider(javax.xml.ws.BindingProvider) WSClientException(com.alibaba.csb.ws.sdk.WSClientException)

Example 60 with Handler

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

the class WsPortFactoryService method getPort.

public Object getPort(String portAlias) throws PortException {
    String portNameClassName = portAliasProp.getProperty(portAlias);
    String[] names = portNameClassName.split(SEPARATOR);
    if (names.length < 2) {
        return new PortException("port name or endpoint interface name is illegal : " + portNameClassName);
    }
    try {
        Class endpointInterface = Class.forName(names[ENDPOINT_INTERFACE_NAME]);
        QName portQN = new QName(nameSpace, names[PORT_NAME]);
        Object port = wsService.getPort(portQN, endpointInterface);
        if ((handlerList != null && handlerList.size() > 0) && (port instanceof BindingProvider)) {
            BindingProvider bindingProvider = ((BindingProvider) port);
            bindingProvider.getRequestContext().putAll(requestContext);
            Binding binding = bindingProvider.getBinding();
            List list = binding.getHandlerChain();
            for (int i = 0; i < handlerList.size(); i++) {
                Handler handler = (Handler) handlerList.get(i);
                list.add(handler);
            }
            binding.setHandlerChain(list);
        }
        return endpointInterface.cast(port);
    } catch (Exception e) {
        throw new PortException(e);
    }
}
Also used : Binding(javax.xml.ws.Binding) QName(javax.xml.namespace.QName) Handler(javax.xml.ws.handler.Handler) ArrayList(java.util.ArrayList) List(java.util.List) BindingProvider(javax.xml.ws.BindingProvider)

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