Search in sources :

Example 76 with Handler

use of javax.xml.ws.handler.Handler in project cloudstack by apache.

the class VmwareClient method pbmConnect.

private void pbmConnect(String url, String cookieValue) throws Exception {
    URI uri = new URI(url);
    String pbmurl = "https://" + uri.getHost() + "/pbm";
    String[] tokens = cookieValue.split("=");
    String extractedCookie = tokens[1];
    HandlerResolver soapHandlerResolver = new HandlerResolver() {

        @Override
        public List<Handler> getHandlerChain(PortInfo portInfo) {
            VcenterSessionHandler VcSessionHandler = new VcenterSessionHandler(extractedCookie);
            List<Handler> handlerChain = new ArrayList<Handler>();
            handlerChain.add((Handler) VcSessionHandler);
            return handlerChain;
        }
    };
    pbmService.setHandlerResolver(soapHandlerResolver);
    pbmSvcInstRef.setType(PBM_SERVICE_INSTANCE_TYPE);
    pbmSvcInstRef.setValue(PBM_SERVICE_INSTANCE_VALUE);
    pbmPort = pbmService.getPbmPort();
    Map<String, Object> pbmCtxt = ((BindingProvider) pbmPort).getRequestContext();
    pbmCtxt.put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true);
    pbmCtxt.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, pbmurl);
}
Also used : PortInfo(javax.xml.ws.handler.PortInfo) HandlerResolver(javax.xml.ws.handler.HandlerResolver) ArrayList(java.util.ArrayList) Handler(javax.xml.ws.handler.Handler) BindingProvider(javax.xml.ws.BindingProvider) URI(java.net.URI)

Example 77 with Handler

use of javax.xml.ws.handler.Handler in project tomee by apache.

the class HandlerResolverImplTest method testPortMatching.

public void testPortMatching() throws Exception {
    final HandlerChains handlerChains = readHandlerChains("/handlers_port.xml");
    assertEquals(3, handlerChains.getHandlerChain().size());
    final List<HandlerChainInfo> handlerChainInfos = ConfigurationFactory.toHandlerChainInfo(handlerChains);
    final List<HandlerChainData> handlerChainDatas = WsBuilder.toHandlerChainData(handlerChainInfos, getClass().getClassLoader());
    final HandlerResolverImpl resolver = new HandlerResolverImpl(handlerChainDatas, null, new InitialContext());
    List<Handler> handlers = null;
    handlers = resolver.getHandlerChain(new TestPortInfo(null, null, null));
    assertEquals(0, handlers.size());
    final QName portName1 = new QName("http://java.sun.com/xml/ns/javaee", "Bar");
    handlers = resolver.getHandlerChain(new TestPortInfo(null, portName1, null));
    assertEquals(1, handlers.size());
    final QName portName2 = new QName("http://java.sun.com/xml/ns/javaee", "Foo");
    handlers = resolver.getHandlerChain(new TestPortInfo(null, portName2, null));
    assertEquals(2, handlers.size());
    final QName portName3 = new QName("http://java.sun.com/xml/ns/javaee", "FooBar");
    handlers = resolver.getHandlerChain(new TestPortInfo(null, portName3, null));
    assertEquals(1, handlers.size());
    final QName portName4 = new QName("http://java.sun.com/xml/ns/javaee", "BarFoo");
    handlers = resolver.getHandlerChain(new TestPortInfo(null, portName4, null));
    assertEquals(0, handlers.size());
}
Also used : HandlerChainInfo(org.apache.openejb.assembler.classic.HandlerChainInfo) QName(javax.xml.namespace.QName) Handler(javax.xml.ws.handler.Handler) HandlerChains(org.apache.openejb.jee.HandlerChains) InitialContext(javax.naming.InitialContext)

Example 78 with Handler

use of javax.xml.ws.handler.Handler in project tomee by apache.

the class HandlerResolverImplTest method testBindingMatching.

public void testBindingMatching() throws Exception {
    final HandlerChains handlerChains = readHandlerChains("/handlers_bindings.xml");
    assertEquals(3, handlerChains.getHandlerChain().size());
    final List<HandlerChainInfo> handlerChainInfos = ConfigurationFactory.toHandlerChainInfo(handlerChains);
    final List<HandlerChainData> handlerChainDatas = WsBuilder.toHandlerChainData(handlerChainInfos, getClass().getClassLoader());
    final HandlerResolverImpl resolver = new HandlerResolverImpl(handlerChainDatas, null, new InitialContext());
    List<Handler> handlers = null;
    handlers = resolver.getHandlerChain(new TestPortInfo(null, null, null));
    assertEquals(0, handlers.size());
    handlers = resolver.getHandlerChain(new TestPortInfo("##SOAP12_HTTP", null, null));
    assertEquals(0, handlers.size());
    handlers = resolver.getHandlerChain(new TestPortInfo("##SOAP11_HTTP", null, null));
    assertEquals(2, handlers.size());
    handlers = resolver.getHandlerChain(new TestPortInfo("##SOAP11_HTTP_MTOM", null, null));
    assertEquals(1, handlers.size());
}
Also used : HandlerChainInfo(org.apache.openejb.assembler.classic.HandlerChainInfo) Handler(javax.xml.ws.handler.Handler) HandlerChains(org.apache.openejb.jee.HandlerChains) InitialContext(javax.naming.InitialContext)

Example 79 with Handler

use of javax.xml.ws.handler.Handler in project tomee by apache.

the class HandlerResolverImplTest method testMixedMatching.

public void testMixedMatching() throws Exception {
    final HandlerChains handlerChains = readHandlerChains("/handlers_mixed.xml");
    assertEquals(3, handlerChains.getHandlerChain().size());
    final List<HandlerChainInfo> handlerChainInfos = ConfigurationFactory.toHandlerChainInfo(handlerChains);
    final List<HandlerChainData> handlerChainDatas = WsBuilder.toHandlerChainData(handlerChainInfos, getClass().getClassLoader());
    final HandlerResolverImpl resolver = new HandlerResolverImpl(handlerChainDatas, null, new InitialContext());
    List<Handler> handlers = null;
    handlers = resolver.getHandlerChain(new TestPortInfo(null, null, null));
    assertEquals(0, handlers.size());
    final QName serviceName1 = new QName("http://java.sun.com/xml/ns/javaee", "Bar");
    final QName portName1 = new QName("http://java.sun.com/xml/ns/javaee", "FooBar");
    final String binding1 = "##XML_HTTP";
    handlers = resolver.getHandlerChain(new TestPortInfo(binding1, portName1, serviceName1));
    assertEquals(3, handlers.size());
    final String binding2 = "##SOAP11_HTTP";
    handlers = resolver.getHandlerChain(new TestPortInfo(binding2, portName1, serviceName1));
    assertEquals(2, handlers.size());
    final QName serviceName2 = new QName("http://java.sun.com/xml/ns/javaee", "Baaz");
    final QName portName2 = new QName("http://java.sun.com/xml/ns/javaee", "Baaz");
    handlers = resolver.getHandlerChain(new TestPortInfo(binding1, portName2, serviceName2));
    assertEquals(1, handlers.size());
}
Also used : HandlerChainInfo(org.apache.openejb.assembler.classic.HandlerChainInfo) QName(javax.xml.namespace.QName) Handler(javax.xml.ws.handler.Handler) HandlerChains(org.apache.openejb.jee.HandlerChains) InitialContext(javax.naming.InitialContext)

Example 80 with Handler

use of javax.xml.ws.handler.Handler in project tomee by apache.

the class CxfEndpoint method initHandlers.

/**
 * Set appropriate handlers for the port/service/bindings.
 */
protected void initHandlers() throws Exception {
    PortInfoImpl portInfo = new PortInfoImpl(implInfo.getBindingType(), serviceFactory.getEndpointName(), service.getName());
    handlerResolver = new HandlerResolverImpl(port.getHandlerChains(), port.getInjections(), context);
    List<Handler> chain = handlerResolver.getHandlerChain(portInfo);
    getBinding().setHandlerChain(chain);
}
Also used : HandlerResolverImpl(org.apache.openejb.core.webservices.HandlerResolverImpl) Handler(javax.xml.ws.handler.Handler) PortInfoImpl(org.apache.cxf.jaxws.handler.PortInfoImpl)

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