Java 类javax.xml.ws.handler.PortInfo 实例源码

项目:jbossws-cxf    文件:CXFHandlerResolverImpl.java   
@SuppressWarnings("rawtypes")
public List<Handler> getHandlerChain(PortInfo portInfo)
{
   synchronized (handlerMap)
   {
      List<Handler> handlerChain = handlerMap.get(portInfo);
      if (handlerChain == null) {
         QName portQName = portInfo.getPortName();
         QName serviceQName = portInfo.getServiceName();
         String bindingId = portInfo.getBindingID();
         handlerChain = createHandlerChain(portInfo, portQName, serviceQName, bindingId);
         handlerMap.put(portInfo, handlerChain);
      }
      return handlerChain;
   }
}
项目:sentenial-ws-client    文件:WsHelper.java   
public <I> I buildWsClient(T wsServiceImplementation, Class<I> ifaceImplementationClass, final List<Handler>extraHandlers, Map<String,Object> ctxSettings){

        final WsSettings settings = WsSettingsLoader.loadSettings();

        wsServiceImplementation.setHandlerResolver(new HandlerResolver() {
            @Override
            public List<Handler> getHandlerChain(PortInfo portInfo) {
                final List<Handler> handlerList = new ArrayList<Handler>();
                handlerList.add(new AuthHandler(settings.getUsername(), settings.getPassword()));
        handlerList.addAll(extraHandlers);
                return handlerList;
            }
        });

        final I serviceIface = wsServiceImplementation.getPort(ifaceImplementationClass);
        final BindingProvider bindingProvider = (BindingProvider) serviceIface;

        final Map<String, Object> req_ctx = bindingProvider.getRequestContext();
        req_ctx.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, settings.getWsUrl());
    req_ctx.putAll(ctxSettings);
        bindingProvider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, settings.getWsUrl());

        return serviceIface;
    }
项目:wso2-axis2    文件:ClientMetadataHandlerChainTest.java   
/**
 *  Test creating a service without a sparse composite.  This verifies pre-existing default
 *  behavior.
 */
public void testServiceAndPortNoComposite() {
    QName serviceQName = new QName(namespaceURI, svcLocalPart);
    QName portQName = new QName(namespaceURI, portLocalPart);

    Service service = Service.create(serviceQName);
    HandlerResolver resolver = service.getHandlerResolver();
    assertNotNull(resolver);
    PortInfo pi = new DummyPortInfo();
    List<Handler> list = resolver.getHandlerChain(pi);
    assertEquals(0, list.size());

    ClientMetadataHandlerChainTestSEI port = service.getPort(portQName, ClientMetadataHandlerChainTestSEI.class);
    // Verify that ports created under the service have no handlers from the sparse composite
    BindingProvider bindingProvider = (BindingProvider) port;
    Binding binding = (Binding) bindingProvider.getBinding();
    List<Handler> portHandlers = binding.getHandlerChain();
    assertEquals(0, portHandlers.size());
}
项目:wso2-axis2    文件:RoleBasedMustUndertandTests.java   
/**
 * Validate that handler information can NOT be cached on the client.  That is because the client
 * can specify handler information per instance of a service delegate.  Those service
 * delegates could share a ServiceDescription, but since each service delegate could specify
 * unique handler information, we can't use common handler information stored on the
 * ServiceDescription 
 */
public void testCachingOnClient() {
    ServiceDescription serviceDesc = DescriptionFactory.createServiceDescription(RoleBasedMUServiceImpl.class);
    HandlerResolverImpl handlerResolver1 = new HandlerResolverImpl(serviceDesc, "sd1");
    HandlerResolverImpl handlerResolver2 = new HandlerResolverImpl(serviceDesc, "sd2");

    EndpointDescription epDesc = serviceDesc.getEndpointDescriptions()[0];
    PortInfo portInfo = epDesc.getPortInfo();

    List<String> roles1 = handlerResolver1.getRoles(portInfo);
    List<String> roles2 = handlerResolver2.getRoles(portInfo);
    assertNotNull(roles1);
    assertNotNull(roles2);
    assertTrue(roles1 != roles2);

}
项目:wso2-axis2    文件:HandlerResolverTest.java   
/**
 *  Test that setting the handler chain type on a sparse composite, but not 
 *  specifying that composite during construction of the HandlerResolver (i.e. no
 *  Delegate key specified) results in no hanlders returned from this resolver. 
 */
public void testHandlerResolverNoKey() {
    QName serviceQName = new QName(namespaceURI, svcLocalPart);
    // Create a composite with a JAXB Handler Config 
    DescriptionBuilderComposite sparseComposite = new DescriptionBuilderComposite();

    HandlerChainsType handlerChainsType = getHandlerChainsType();
    sparseComposite.setHandlerChainsType(handlerChainsType);
    Object serviceDelegateKey = "CompositeKey";

    ServiceDescription serviceDesc = 
        DescriptionFactory.createServiceDescription(null, serviceQName, HandlerResolverTestService.class, sparseComposite, serviceDelegateKey);
    HandlerResolver resolver = new HandlerResolverImpl(serviceDesc);
    assertNotNull(resolver);
    PortInfo pi = new DummyPortInfo();
    List<Handler> list = resolver.getHandlerChain(pi);
    assertEquals(0, list.size());
}
项目:wso2-axis2    文件:HandlerResolverTest.java   
/**
 * The sparse composite has handler config information for the key that the HandlerResolver
 * is created with, so that handler resolver contains those handlers.  However, the 
 * portInfo specified on the getHandlerChain does NOT match the QName in the config file
 * so no handlers should be returned.
 */
public void testHandlerResolverInvalidPortInfo() {
    QName serviceQName = new QName(namespaceURI, svcLocalPart);
    QName portQName = new QName(namespaceURI, portWrongLocalPart);
    // Create a composite with a JAXB Handler Config 
    DescriptionBuilderComposite sparseComposite = new DescriptionBuilderComposite();

    HandlerChainsType handlerChainsType = getHandlerChainsType();
    sparseComposite.setHandlerChainsType(handlerChainsType);
    Object serviceDelegateKey = "CompositeKey";

    // The getHandlerChain will do handler lifecycle management as well, so there needs to be
    // and EnpdointDescription (representing the Port) under the ServiceDescription
    ServiceDescription serviceDesc = 
        DescriptionFactory.createServiceDescription(null, serviceQName, HandlerResolverTestService.class, sparseComposite, serviceDelegateKey);
    EndpointDescription endpointDesc = 
        DescriptionFactory.updateEndpoint(serviceDesc, HandlerResolverTestSEI.class, portQName, DescriptionFactory.UpdateType.GET_PORT);
    HandlerResolver resolver = new HandlerResolverImpl(serviceDesc, serviceDelegateKey);
    assertNotNull(resolver);
    PortInfo pi = new DummyPortInfo();
    List<Handler> list = resolver.getHandlerChain(pi);
    assertEquals(0, list.size());
}
项目:wso2-axis2    文件:HandlerResolverTest.java   
/**
 * The sparse composite has handler config information for the key that the HandlerResolver
 * is created with, so that handler resolver contains those handlers.  
 */
public void testHandlerResolverValidPortInfo() {
    QName serviceQName = new QName(namespaceURI, svcLocalPart);
    QName portQName = new QName(namespaceURI, portLocalPart);
    // Create a composite with a JAXB Handler Config 
    DescriptionBuilderComposite sparseComposite = new DescriptionBuilderComposite();

    HandlerChainsType handlerChainsType = getHandlerChainsType();
    sparseComposite.setHandlerChainsType(handlerChainsType);
    Object serviceDelegateKey = "CompositeKey";

    // The getHandlerChain will do handler lifecycle management as well, so there needs to be
    // and EnpdointDescription (representing the Port) under the ServiceDescription
    ServiceDescription serviceDesc = 
        DescriptionFactory.createServiceDescription(null, serviceQName, HandlerResolverTestService.class, sparseComposite, serviceDelegateKey);
    EndpointDescription endpointDesc = 
        DescriptionFactory.updateEndpoint(serviceDesc, HandlerResolverTestSEI.class, portQName, DescriptionFactory.UpdateType.GET_PORT);
    HandlerResolver resolver = new HandlerResolverImpl(serviceDesc, serviceDelegateKey);
    assertNotNull(resolver);
    PortInfo pi = new DummyPortInfo();
    List<Handler> list = resolver.getHandlerChain(pi);
    assertEquals(2, list.size());

}
项目:spring-boot-integration-example    文件:JaxWsClient.java   
/**
 * Sends the specified content file to the WebService
 * 
 * @param name The name of the content to be stored
 * @param content The content to be stored
 * @return The message that tthe server sent back
 */
public String storeContent(String name, DataHandler content) {
    ContentStoreHttpPortService service = new ContentStoreHttpPortService();

    service.setHandlerResolver(new HandlerResolver() {
        @Override
        public List<Handler> getHandlerChain(PortInfo portInfo) {
            List<Handler> handlerList = new ArrayList<>();
            handlerList.add(wsSecurityHandler);
            return handlerList;
        }
    });

    ContentStoreHttpPort contentStorePort = service.getContentStoreHttpPortSoap11();
    SOAPBinding binding = (SOAPBinding) ((BindingProvider) contentStorePort).getBinding();
    binding.setMTOMEnabled(true);

    StoreContentRequest request = objectFactory.createStoreContentRequest();
    request.setName(name);
    request.setContent(content);

    StoreContentResponse response = contentStorePort.storeContent(request);
    return response.getMessage();
}
项目:spring-boot-integration-example    文件:JaxWsClient.java   
/**
 * Loads the content with the specified name from the WebService
 * 
 * @param name The name of the content
 * @return The loaded content
 * @throws IOException If an IO error occurs
 */
public DataHandler loadContent(String name) throws IOException {
    ContentStoreHttpPortService service = new ContentStoreHttpPortService();

    service.setHandlerResolver(new HandlerResolver() {
        @Override
        public List<Handler> getHandlerChain(PortInfo portInfo) {
            List<Handler> handlerList = new ArrayList<>();
            handlerList.add(wsSecurityHandler);
            return handlerList;
        }
    });

    ContentStoreHttpPort loadContentPort = service.getContentStoreHttpPortSoap11();
    SOAPBinding binding = (SOAPBinding) ((BindingProvider) loadContentPort).getBinding();
    binding.setMTOMEnabled(true);

    LoadContentRequest request = objectFactory.createLoadContentRequest();
    request.setName(name);
    LoadContentResponse response = loadContentPort.loadContent(request);
    DataHandler content = response.getContent();
    return content;
}
项目:elexis-3-base    文件:WsClientUtil.java   
public static void addWsSecurityAndHttpConfigWithClientCert(Service ss, final String username,
    final String password, final String p12, final String jks, final String passwordP12,
    final String passwordJks){

    String url = WsClientConfig.getDocboxServiceUrl();
    final boolean clientcert = url.contains("ihe");

    ss.setHandlerResolver(new HandlerResolver() {
        @SuppressWarnings("rawtypes")
        public List<Handler> getHandlerChain(PortInfo portInfo){
            List<Handler> handlerList = new ArrayList<Handler>();
            handlerList.add(new SecurityHandler(username, password, clientcert, p12, jks,
                passwordP12, passwordJks));
            return handlerList;
        }
    });
}
项目:oscm    文件:ClientVersionHandler.java   
/**
 * This method adds a version SOAP Handler into the handler chain of a web
 * service. The version SOAP Handler is responsible to add a version
 * information in the header of the outbound SOAP message.
 * 
 * @param service
 *            set HandlerResolver for service by invoking service
 *            <code>setHandlerResolver</code> method.
 * @return service with handler chain for handling version information.
 */
public Service addVersionInformationToClient(Service service) {
    service.setHandlerResolver(new HandlerResolver() {
        @SuppressWarnings("rawtypes")
        @Override
        public List<Handler> getHandlerChain(PortInfo portInfo) {
            List<Handler> handlerList = new ArrayList<Handler>();
            handlerList.add(new VersionHandler(version));
            return handlerList;
        }
    });
    return service;
}
项目:OpenJSharp    文件:HandlerChainsModel.java   
public HandlerAnnotationInfo getHandlersForPortInfo(PortInfo info){

        HandlerAnnotationInfo handlerInfo = new HandlerAnnotationInfo();
        List<Handler> handlerClassList = new ArrayList<Handler>();
        Set<String> roles = new HashSet<String>();

        for(HandlerChainType hchain : handlerChains) {
            boolean hchainMatched = false;
            if((!hchain.isConstraintSet()) ||
                    JAXWSUtils.matchQNames(info.getServiceName(), hchain.getServiceNamePattern()) ||
                    JAXWSUtils.matchQNames(info.getPortName(), hchain.getPortNamePattern()) ||
                    hchain.getProtocolBindings().contains(info.getBindingID()) ){
                hchainMatched = true;

            }
            if(hchainMatched) {
                for(HandlerType handler : hchain.getHandlers()) {
                    try {
                        Handler handlerClass = (Handler) loadClass(annotatedClass.getClassLoader(),
                                handler.getHandlerClass()).newInstance();
                        callHandlerPostConstruct(handlerClass);
                        handlerClassList.add(handlerClass);
                    } catch (InstantiationException ie){
                        throw new RuntimeException(ie);
                    } catch (IllegalAccessException e) {
                        throw new RuntimeException(e);
                    }

                    roles.addAll(handler.getSoapRoles());
                }

            }
        }

        handlerInfo.setHandlers(handlerClassList);
        handlerInfo.setRoles(roles);
        return handlerInfo;

    }
项目:OpenJSharp    文件:PortInfoImpl.java   
/**
 * Object.equals is overridden here so that PortInfo objects
 * can be compared when using them as keys in the map in
 * HandlerResolverImpl. This method relies on the equals()
 * methods of java.lang.String and javax.xml.namespace.QName.
 *
 * @param obj The PortInfo object to test for equality.
 * @return True if they match, and false if they do not or
 * if the object passed in is not a PortInfo.
 */
public boolean equals(Object obj) {
    if (obj instanceof PortInfo) {
        PortInfo info = (PortInfo) obj;
        if (bindingId.toString().equals(info.getBindingID()) &&
            portName.equals(info.getPortName()) &&
            serviceName.equals(info.getServiceName())) {
            return true;
        }
    }
    return false;
}
项目:OpenJSharp    文件:HandlerConfigurator.java   
HandlerResolver getResolver() {
    return new HandlerResolver() {
        public List<Handler> getHandlerChain(PortInfo portInfo) {
            return new ArrayList<Handler>(
                handlerModel.getHandlersForPortInfo(portInfo).getHandlers());
        }
    };
}
项目:openjdk-jdk10    文件:HandlerChainsModel.java   
public HandlerAnnotationInfo getHandlersForPortInfo(PortInfo info){

        HandlerAnnotationInfo handlerInfo = new HandlerAnnotationInfo();
        List<Handler> handlerClassList = new ArrayList<Handler>();
        Set<String> roles = new HashSet<String>();

        for(HandlerChainType hchain : handlerChains) {
            boolean hchainMatched = false;
            if((!hchain.isConstraintSet()) ||
                    JAXWSUtils.matchQNames(info.getServiceName(), hchain.getServiceNamePattern()) ||
                    JAXWSUtils.matchQNames(info.getPortName(), hchain.getPortNamePattern()) ||
                    hchain.getProtocolBindings().contains(info.getBindingID()) ){
                hchainMatched = true;

            }
            if(hchainMatched) {
                for(HandlerType handler : hchain.getHandlers()) {
                    try {
                        Handler handlerClass = (Handler) loadClass(annotatedClass.getClassLoader(),
                                handler.getHandlerClass()).newInstance();
                        callHandlerPostConstruct(handlerClass);
                        handlerClassList.add(handlerClass);
                    } catch (InstantiationException ie){
                        throw new RuntimeException(ie);
                    } catch (IllegalAccessException e) {
                        throw new RuntimeException(e);
                    }

                    roles.addAll(handler.getSoapRoles());
                }

            }
        }

        handlerInfo.setHandlers(handlerClassList);
        handlerInfo.setRoles(roles);
        return handlerInfo;

    }
项目:openjdk-jdk10    文件:PortInfoImpl.java   
/**
 * Object.equals is overridden here so that PortInfo objects
 * can be compared when using them as keys in the map in
 * HandlerResolverImpl. This method relies on the equals()
 * methods of java.lang.String and javax.xml.namespace.QName.
 *
 * @param obj The PortInfo object to test for equality.
 * @return True if they match, and false if they do not or
 * if the object passed in is not a PortInfo.
 */
public boolean equals(Object obj) {
    if (obj instanceof PortInfo) {
        PortInfo info = (PortInfo) obj;
        if (bindingId.toString().equals(info.getBindingID()) &&
            portName.equals(info.getPortName()) &&
            serviceName.equals(info.getServiceName())) {
            return true;
        }
    }
    return false;
}
项目:openjdk-jdk10    文件:HandlerConfigurator.java   
HandlerResolver getResolver() {
    return new HandlerResolver() {
        public List<Handler> getHandlerChain(PortInfo portInfo) {
            return new ArrayList<Handler>(
                handlerModel.getHandlersForPortInfo(portInfo).getHandlers());
        }
    };
}
项目:openjdk9    文件:HandlerChainsModel.java   
public HandlerAnnotationInfo getHandlersForPortInfo(PortInfo info){

        HandlerAnnotationInfo handlerInfo = new HandlerAnnotationInfo();
        List<Handler> handlerClassList = new ArrayList<Handler>();
        Set<String> roles = new HashSet<String>();

        for(HandlerChainType hchain : handlerChains) {
            boolean hchainMatched = false;
            if((!hchain.isConstraintSet()) ||
                    JAXWSUtils.matchQNames(info.getServiceName(), hchain.getServiceNamePattern()) ||
                    JAXWSUtils.matchQNames(info.getPortName(), hchain.getPortNamePattern()) ||
                    hchain.getProtocolBindings().contains(info.getBindingID()) ){
                hchainMatched = true;

            }
            if(hchainMatched) {
                for(HandlerType handler : hchain.getHandlers()) {
                    try {
                        Handler handlerClass = (Handler) loadClass(annotatedClass.getClassLoader(),
                                handler.getHandlerClass()).newInstance();
                        callHandlerPostConstruct(handlerClass);
                        handlerClassList.add(handlerClass);
                    } catch (InstantiationException ie){
                        throw new RuntimeException(ie);
                    } catch (IllegalAccessException e) {
                        throw new RuntimeException(e);
                    }

                    roles.addAll(handler.getSoapRoles());
                }

            }
        }

        handlerInfo.setHandlers(handlerClassList);
        handlerInfo.setRoles(roles);
        return handlerInfo;

    }
项目:openjdk9    文件:PortInfoImpl.java   
/**
 * Object.equals is overridden here so that PortInfo objects
 * can be compared when using them as keys in the map in
 * HandlerResolverImpl. This method relies on the equals()
 * methods of java.lang.String and javax.xml.namespace.QName.
 *
 * @param obj The PortInfo object to test for equality.
 * @return True if they match, and false if they do not or
 * if the object passed in is not a PortInfo.
 */
public boolean equals(Object obj) {
    if (obj instanceof PortInfo) {
        PortInfo info = (PortInfo) obj;
        if (bindingId.toString().equals(info.getBindingID()) &&
            portName.equals(info.getPortName()) &&
            serviceName.equals(info.getServiceName())) {
            return true;
        }
    }
    return false;
}
项目:openjdk9    文件:HandlerConfigurator.java   
HandlerResolver getResolver() {
    return new HandlerResolver() {
        public List<Handler> getHandlerChain(PortInfo portInfo) {
            return new ArrayList<Handler>(
                handlerModel.getHandlersForPortInfo(portInfo).getHandlers());
        }
    };
}
项目:roles-auths-client    文件:AbstractRiClient.java   
protected HandlerResolver createHandlerResolver(XRoadClientConfig config, RovaServiceDetails details) {
    headerHandler = new HeaderHandler(config, details);
    return new HandlerResolver() {
        @Override
        public List<Handler> getHandlerChain(PortInfo portInfo) {
            List<Handler> handlers = new ArrayList<>();
            handlers.add(headerHandler);
            return handlers;
        }
    };
}
项目:document-management-system    文件:AuthHandlerResolver.java   
@SuppressWarnings("rawtypes")
public List<Handler> getHandlerChain(PortInfo portInfo) {
    List<Handler> handlerChain = new ArrayList<Handler>();
    HeaderHandler hh = new HeaderHandler(username, password);
    handlerChain.add(hh);
    return handlerChain;
}
项目:lookaside_java-1.8.0-openjdk    文件:HandlerChainsModel.java   
public HandlerAnnotationInfo getHandlersForPortInfo(PortInfo info){

        HandlerAnnotationInfo handlerInfo = new HandlerAnnotationInfo();
        List<Handler> handlerClassList = new ArrayList<Handler>();
        Set<String> roles = new HashSet<String>();

        for(HandlerChainType hchain : handlerChains) {
            boolean hchainMatched = false;
            if((!hchain.isConstraintSet()) ||
                    JAXWSUtils.matchQNames(info.getServiceName(), hchain.getServiceNamePattern()) ||
                    JAXWSUtils.matchQNames(info.getPortName(), hchain.getPortNamePattern()) ||
                    hchain.getProtocolBindings().contains(info.getBindingID()) ){
                hchainMatched = true;

            }
            if(hchainMatched) {
                for(HandlerType handler : hchain.getHandlers()) {
                    try {
                        Handler handlerClass = (Handler) loadClass(annotatedClass.getClassLoader(),
                                handler.getHandlerClass()).newInstance();
                        callHandlerPostConstruct(handlerClass);
                        handlerClassList.add(handlerClass);
                    } catch (InstantiationException ie){
                        throw new RuntimeException(ie);
                    } catch (IllegalAccessException e) {
                        throw new RuntimeException(e);
                    }

                    roles.addAll(handler.getSoapRoles());
                }

            }
        }

        handlerInfo.setHandlers(handlerClassList);
        handlerInfo.setRoles(roles);
        return handlerInfo;

    }
项目:lookaside_java-1.8.0-openjdk    文件:PortInfoImpl.java   
/**
 * Object.equals is overridden here so that PortInfo objects
 * can be compared when using them as keys in the map in
 * HandlerResolverImpl. This method relies on the equals()
 * methods of java.lang.String and javax.xml.namespace.QName.
 *
 * @param obj The PortInfo object to test for equality.
 * @return True if they match, and false if they do not or
 * if the object passed in is not a PortInfo.
 */
public boolean equals(Object obj) {
    if (obj instanceof PortInfo) {
        PortInfo info = (PortInfo) obj;
        if (bindingId.toString().equals(info.getBindingID()) &&
            portName.equals(info.getPortName()) &&
            serviceName.equals(info.getServiceName())) {
            return true;
        }
    }
    return false;
}
项目:lookaside_java-1.8.0-openjdk    文件:HandlerConfigurator.java   
HandlerResolver getResolver() {
    return new HandlerResolver() {
        public List<Handler> getHandlerChain(PortInfo portInfo) {
            return new ArrayList<Handler>(
                handlerModel.getHandlersForPortInfo(portInfo).getHandlers());
        }
    };
}
项目:greek-vat-data    文件:HeaderHandlerResolver.java   
public List<Handler> getHandlerChain(PortInfo portInfo) {
    List<Handler> handlerChain = new ArrayList<Handler>();
    HeaderHandler hh = new HeaderHandler(userName, password);
    handlerChain.add(hh);

    return handlerChain;
}
项目:OntologyBasedInormationExtractor    文件:AwsHandlerResolver.java   
@SuppressWarnings("unchecked")
public List<Handler> getHandlerChain(PortInfo portInfo) {
    List<Handler> handlerChain = new ArrayList<Handler>();

    QName serviceQName = portInfo.getServiceName();
    if(serviceQName.getLocalPart().equals("AWSECommerceService")) {
        handlerChain.add(new AwsHandler(awsSecretKey));
    }

    return handlerChain;
}
项目:development    文件:ClientVersionHandler.java   
/**
 * This method adds a version SOAP Handler into the handler chain of a web
 * service. The version SOAP Handler is responsible to add a version
 * information in the header of the outbound SOAP message.
 * 
 * @param service
 *            set HandlerResolver for service by invoking service
 *            <code>setHandlerResolver</code> method.
 * @return service with handler chain for handling version information.
 */
public Service addVersionInformationToClient(Service service) {
    service.setHandlerResolver(new HandlerResolver() {
        @SuppressWarnings("rawtypes")
        @Override
        public List<Handler> getHandlerChain(PortInfo portInfo) {
            List<Handler> handlerList = new ArrayList<Handler>();
            handlerList.add(new VersionHandler(version));
            return handlerList;
        }
    });
    return service;
}
项目:jbossws-cxf    文件:HandlerChainClient.java   
public String testService1(String reqStr) throws Exception
{
   PortInfo info = new PortInfo()
   {
      @Override
      public String getBindingID()
      {
         return "http://schemas.xmlsoap.org/wsdl/soap/http";
      }

      @Override
      public QName getPortName()
      {
         return null;
      }

      @Override
      public QName getServiceName()
      {
         return null;
      }
   };

   HandlerResolver resolver = service1.getHandlerResolver();
   @SuppressWarnings("rawtypes")
   List<Handler> handlerChain = resolver.getHandlerChain(info);
   if("[LogHandler, AuthorizationHandler, RoutingHandler, MimeHandler]".equals(handlerChain.toString()) == false)
      throw new IllegalStateException("Unexpected resolver handlers: " + handlerChain);

   Endpoint port = service1.getPort(Endpoint.class);
   return port.echo(reqStr);
}
项目:jbossws-cxf    文件:CXFHandlerResolverImpl.java   
@SuppressWarnings("rawtypes")
protected List<Handler> createHandlerChain(PortInfo portInfo, QName portQName, QName serviceQName, String bindingID) {
   List<Handler> chain = new ArrayList<Handler>();
   InputStream is = getInputStream();
   try {

      if (is == null) {
         throw MESSAGES.handlerConfigFileNotFound(handlerFile);
      }

      Element el = DOMUtils.parse(is, Holder.builder);
      if (!ParserConstants.JAVAEE_NS.equals(el.getNamespaceURI()) 
            || !ParserConstants.HANDLER_CHAINS.equals(el.getLocalName())) {
         throw MESSAGES.differentElementExpected(handlerFile, "{" + ParserConstants.JAVAEE_NS + "}"
               + ParserConstants.HANDLER_CHAINS, "{" + el.getNamespaceURI() + "}" + el.getLocalName());
      }
      Node node = el.getFirstChild();
      while (node != null) {
         if (node instanceof Element) {
            el = (Element)node;
            if (!el.getNamespaceURI().equals(ParserConstants.JAVAEE_NS) 
                  || !el.getLocalName().equals(ParserConstants.HANDLER_CHAIN)) {
               throw MESSAGES.differentElementExpected(handlerFile, "{" + ParserConstants.JAVAEE_NS + "}"
                     + ParserConstants.HANDLER_CHAIN, "{" + el.getNamespaceURI() + "}" + el.getLocalName());
            }
            processHandlerChainElement(el, chain, portQName, serviceQName, bindingID);
         }
         node = node.getNextSibling();
      }
   } catch (WebServiceException e) {
      throw e;
   } catch (Exception e) {
      throw MESSAGES.noHandlerChainFound(handlerFile, e);
   }
   assert chain != null;
   return sortHandlers(chain);
}
项目:BingAds-Java-SDK    文件:ServiceClient.java   
/**
 * Creates an object implementing the service interface that needs to be called.
 *
 * @return the service object implementing the service interface
 */
public T getService() {
    authorizationData.validate();

    WebService webServiceAnnotation = serviceInterface.getAnnotation(WebService.class);

    final String ns = webServiceAnnotation.targetNamespace();

    final Map<String, String> headers = new HashMap<String, String>();

    headers.put("CustomerAccountId", Long.toString(authorizationData.getAccountId()));

    headers.put("CustomerId", Long.toString(authorizationData.getCustomerId()));

    headers.put("DeveloperToken", authorizationData.getDeveloperToken());

    refreshOAuthTokensIfNeeded();

    this.authorizationData.getAuthentication().addHeaders(new HeadersImpl() {
        @Override
        public void addHeader(String name, String value) {
            headers.put(name, value);
        }
    });

    service.setHandlerResolver(new HandlerResolver() {
        @Override
        public List<Handler> getHandlerChain(PortInfo portInfo) {
            List<Handler> handlerList = new ArrayList<Handler>();
            handlerList.add(new HeaderHandler(ns, headers));
            handlerList.add(MessageHandler.getInstance());
            return handlerList;
        }
    });

    T port = serviceFactory.createProxyFromService(service, environment, serviceInterface);

    return port;
}
项目:infobip-open-jdk-8    文件:HandlerChainsModel.java   
public HandlerAnnotationInfo getHandlersForPortInfo(PortInfo info){

        HandlerAnnotationInfo handlerInfo = new HandlerAnnotationInfo();
        List<Handler> handlerClassList = new ArrayList<Handler>();
        Set<String> roles = new HashSet<String>();

        for(HandlerChainType hchain : handlerChains) {
            boolean hchainMatched = false;
            if((!hchain.isConstraintSet()) ||
                    JAXWSUtils.matchQNames(info.getServiceName(), hchain.getServiceNamePattern()) ||
                    JAXWSUtils.matchQNames(info.getPortName(), hchain.getPortNamePattern()) ||
                    hchain.getProtocolBindings().contains(info.getBindingID()) ){
                hchainMatched = true;

            }
            if(hchainMatched) {
                for(HandlerType handler : hchain.getHandlers()) {
                    try {
                        Handler handlerClass = (Handler) loadClass(annotatedClass.getClassLoader(),
                                handler.getHandlerClass()).newInstance();
                        callHandlerPostConstruct(handlerClass);
                        handlerClassList.add(handlerClass);
                    } catch (InstantiationException ie){
                        throw new RuntimeException(ie);
                    } catch (IllegalAccessException e) {
                        throw new RuntimeException(e);
                    }

                    roles.addAll(handler.getSoapRoles());
                }

            }
        }

        handlerInfo.setHandlers(handlerClassList);
        handlerInfo.setRoles(roles);
        return handlerInfo;

    }
项目:infobip-open-jdk-8    文件:PortInfoImpl.java   
/**
 * Object.equals is overridden here so that PortInfo objects
 * can be compared when using them as keys in the map in
 * HandlerResolverImpl. This method relies on the equals()
 * methods of java.lang.String and javax.xml.namespace.QName.
 *
 * @param obj The PortInfo object to test for equality.
 * @return True if they match, and false if they do not or
 * if the object passed in is not a PortInfo.
 */
public boolean equals(Object obj) {
    if (obj instanceof PortInfo) {
        PortInfo info = (PortInfo) obj;
        if (bindingId.toString().equals(info.getBindingID()) &&
            portName.equals(info.getPortName()) &&
            serviceName.equals(info.getServiceName())) {
            return true;
        }
    }
    return false;
}
项目:infobip-open-jdk-8    文件:HandlerConfigurator.java   
HandlerResolver getResolver() {
    return new HandlerResolver() {
        public List<Handler> getHandlerChain(PortInfo portInfo) {
            return new ArrayList<Handler>(
                handlerModel.getHandlersForPortInfo(portInfo).getHandlers());
        }
    };
}
项目:jax-ws    文件:JAXWSProviderClientHandlerResolver.java   
@SuppressWarnings("rawtypes")
   @Override
   public List<Handler> getHandlerChain(PortInfo arg0) {
List<Handler> handlerChain = new ArrayList<Handler>();
handlerChain.add(new SOAPMessageLoggingHandler());

return handlerChain;
   }
项目:jax-ws    文件:AppConfig.java   
private HandlerResolver handlerResolver() {
    return new HandlerResolver() {

        @SuppressWarnings("rawtypes")
        @Override
        public List<Handler> getHandlerChain(PortInfo arg0) {
            List<Handler> handlerChain = new ArrayList<Handler>();
            handlerChain.add(new SOAPMessageLoggingHandler());

            return handlerChain;
        }
    };
}
项目:jax-ws    文件:CalculatorClient.java   
@SuppressWarnings("rawtypes")
   @Override
   public List<Handler> getHandlerChain(PortInfo portInfo) {
List<Handler> handlerChain = new ArrayList<Handler>();
handlerChain.add(new SOAPMessageLoggingHandler());

return handlerChain;
   }
项目:cwEnsaiosWeb    文件:PDQClientExample.java   
@Override
@SuppressWarnings("rawtypes")
public List<Handler> getHandlerChain(PortInfo arg0) {
    List<Handler> handlerList = new ArrayList<Handler>();
    handlerList.add(handler);
    return handlerList;
}
项目:cwEnsaiosWeb    文件:PIXClientExample.java   
@Override
@SuppressWarnings("rawtypes")
public List<Handler> getHandlerChain(PortInfo arg0) {
    List<Handler> handlerList = new ArrayList<Handler>();
    handlerList.add(handler);
    return handlerList;
}
项目:OLD-OpenJDK8    文件:HandlerChainsModel.java   
public HandlerAnnotationInfo getHandlersForPortInfo(PortInfo info){

        HandlerAnnotationInfo handlerInfo = new HandlerAnnotationInfo();
        List<Handler> handlerClassList = new ArrayList<Handler>();
        Set<String> roles = new HashSet<String>();

        for(HandlerChainType hchain : handlerChains) {
            boolean hchainMatched = false;
            if((!hchain.isConstraintSet()) ||
                    JAXWSUtils.matchQNames(info.getServiceName(), hchain.getServiceNamePattern()) ||
                    JAXWSUtils.matchQNames(info.getPortName(), hchain.getPortNamePattern()) ||
                    hchain.getProtocolBindings().contains(info.getBindingID()) ){
                hchainMatched = true;

            }
            if(hchainMatched) {
                for(HandlerType handler : hchain.getHandlers()) {
                    try {
                        Handler handlerClass = (Handler) loadClass(annotatedClass.getClassLoader(),
                                handler.getHandlerClass()).newInstance();
                        callHandlerPostConstruct(handlerClass);
                        handlerClassList.add(handlerClass);
                    } catch (InstantiationException ie){
                        throw new RuntimeException(ie);
                    } catch (IllegalAccessException e) {
                        throw new RuntimeException(e);
                    }

                    roles.addAll(handler.getSoapRoles());
                }

            }
        }

        handlerInfo.setHandlers(handlerClassList);
        handlerInfo.setRoles(roles);
        return handlerInfo;

    }