當前位置: 首頁>>代碼示例>>Java>>正文


Java Handler類代碼示例

本文整理匯總了Java中javax.xml.ws.handler.Handler的典型用法代碼示例。如果您正苦於以下問題:Java Handler類的具體用法?Java Handler怎麽用?Java Handler使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Handler類屬於javax.xml.ws.handler包,在下文中一共展示了Handler類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: registerUnderstoodHeaders

import javax.xml.ws.handler.Handler; //導入依賴的package包/類
private void registerUnderstoodHeaders(MessageContext request,
                                       List<Handler> handlerList) {
  if (handlerList != null && handlerList.size() > 0) {
    Set<QName> understoodHeaders = new HashSet<QName>();
    
    // Add the headers from each of the SOAP handlers to the collection
    for (Handler handler : handlerList) {
      if(handler instanceof SOAPHandler){
        SOAPHandler soapHandler = (SOAPHandler)handler;
        Set<QName> headers = soapHandler.getHeaders();
        if (headers != null && headers.size() > 0) {
          understoodHeaders.addAll(headers);
        }
      }
    }
    
    // Put the understood header qnames on the request context where it can
    // be found during response processing.
    if (understoodHeaders != null && understoodHeaders.size() > 0) {
      if (log.isDebugEnabled()) {
        log.debug("Adding understood header QName collection to message context " + understoodHeaders);
      }
      request.setProperty("client.UnderstoodHeaders", understoodHeaders);
    }
  }
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:27,代碼來源:InvocationControllerImpl.java

示例2: setUpProcessor

import javax.xml.ws.handler.Handler; //導入依賴的package包/類
void setUpProcessor() {
    if (handlers == null) {
            // Take a snapshot, User may change chain after invocation, Same chain
            // should be used for the entire MEP
            handlers = new ArrayList<Handler>();
            WSBinding binding = getBinding();
            List<LogicalHandler> logicalSnapShot= ((BindingImpl) binding).getHandlerConfig().getLogicalHandlers();
            if (!logicalSnapShot.isEmpty()) {
                handlers.addAll(logicalSnapShot);
                if (binding.getSOAPVersion() == null) {
                    processor = new XMLHandlerProcessor(this, binding,
                            handlers);
                } else {
                    processor = new SOAPHandlerProcessor(true, this, binding,
                            handlers);
                }
            }
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:20,代碼來源:ClientLogicalHandlerTube.java

示例3: dispose

import javax.xml.ws.handler.Handler; //導入依賴的package包/類
public synchronized void dispose() {
    if (disposed) {
        return;
    }
    disposed = true;

    masterTubeline.preDestroy();

    for (Handler handler : binding.getHandlerChain()) {
        for (Method method : handler.getClass().getMethods()) {
            if (method.getAnnotation(PreDestroy.class) == null) {
                continue;
            }
            try {
                method.invoke(handler);
            } catch (Exception e) {
                logger.log(Level.WARNING, HandlerMessages.HANDLER_PREDESTROY_IGNORE(e.getMessage()), e);
            }
            break;
        }
    }
    closeManagedObjectManager();
    LazyMOMProvider.INSTANCE.unregisterEndpoint(this);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:25,代碼來源:WSEndpointImpl.java

示例4: setup

import javax.xml.ws.handler.Handler; //導入依賴的package包/類
@Before
public void setup() throws Exception
{
   if (port11 == null) {
      URL wsdlURL = new URL(baseURL + "/soap11?wsdl");
      QName serviceName = new QName("http://org.jboss.test.ws/jbws2278", "TestService");

      Service service = Service.create(wsdlURL, serviceName);
      port11 = service.getPort(new QName("http://org.jboss.test.ws/jbws2278", "TestEndpointSoap11Port"), TestEndpoint.class);
      port12 = service.getPort(new QName("http://org.jboss.test.ws/jbws2278", "TestEndpointSoap12Port"), TestEndpoint.class);

      @SuppressWarnings("rawtypes")
      List<Handler> handlerChain11 = new ArrayList<Handler>();
      handlerChain11.add(new TestHandler(SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE, SOAPConstants.SOAP_1_1_CONTENT_TYPE));
      ((BindingProvider)port11).getBinding().setHandlerChain(handlerChain11);

      @SuppressWarnings("rawtypes")
      List<Handler> handlerChain12 = new ArrayList<Handler>();
      handlerChain12.add(new TestHandler(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE, SOAPConstants.SOAP_1_2_CONTENT_TYPE));
      ((BindingProvider)port12).getBinding().setHandlerChain(handlerChain12);
   }
}
 
開發者ID:jbossws,項目名稱:jbossws-cxf,代碼行數:23,代碼來源:JBWS2278TestCase.java

示例5: testAddingIncomptiableHandler

import javax.xml.ws.handler.Handler; //導入依賴的package包/類
@Test
@RunAsClient
public void testAddingIncomptiableHandler() throws Exception
{
   try
   {
      Dispatch<Source> source = createDispatchSource();
      @SuppressWarnings("rawtypes")
      List<Handler> handlers = new ArrayList<Handler>();
      handlers.add(new SOAPHandler());
      source.getBinding().setHandlerChain(handlers);
      fail("WebServiceException is not thrown");
   }
   catch (WebServiceException e)
   {
      //expected and do nothing
   }
}
 
開發者ID:jbossws,項目名稱:jbossws-cxf,代碼行數:19,代碼來源:JAXWS2976TestCase.java

示例6: testClientAccess

import javax.xml.ws.handler.Handler; //導入依賴的package包/類
@Test
@RunAsClient
public void testClientAccess() throws Exception
{
   URL wsdlURL = new URL(baseURL + "?wsdl");
   QName qname = new QName("http://org.jboss.ws/jaxws/binding", "SOAPEndpointService");
   Service service = Service.create(wsdlURL, qname);
   SOAPEndpoint port = service.getPort(SOAPEndpoint.class);

   BindingProvider provider = (BindingProvider)port;
   @SuppressWarnings("rawtypes")
   List<Handler> handlerChain = new ArrayList<Handler>();
   handlerChain.addAll(provider.getBinding().getHandlerChain());
   handlerChain.add(new ClientHandler());
   handlerChain.add(new ClientHandler2());
   provider.getBinding().setHandlerChain(handlerChain);

   String nsURI = port.namespace();
   assertEquals(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE + ":" + SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE, nsURI);
}
 
開發者ID:jbossws,項目名稱:jbossws-cxf,代碼行數:21,代碼來源:SOAPBindingTestCase.java

示例7: testCustomClientConfigurationFromFile

import javax.xml.ws.handler.Handler; //導入依賴的package包/類
public boolean testCustomClientConfigurationFromFile() throws Exception
{
   QName serviceName = new QName("http://clientConfig.jaxws.ws.test.jboss.org/", "EndpointImplService");
   URL wsdlURL = new URL(address + "?wsdl");

   Service service = Service.create(wsdlURL, serviceName);
   Endpoint port = (Endpoint)service.getPort(Endpoint.class);

   BindingProvider bp = (BindingProvider)port;
   @SuppressWarnings("rawtypes")
   List<Handler> hc = bp.getBinding().getHandlerChain();
   hc.add(new UserHandler());
   bp.getBinding().setHandlerChain(hc);

   ClientConfigUtil.setConfigHandlers(bp, "META-INF/jaxws-client-config.xml", "Custom Client Config");

   String resStr = port.echo("Kermit");
   resStr = port.echo("Kermit");
   resStr = port.echo("Kermit");
   return ("Kermit|RoutOut|CustomOut|UserOut|LogOut|endpoint|LogIn|UserIn|CustomIn|RoutIn".equals(resStr));
}
 
開發者ID:jbossws,項目名稱:jbossws-cxf,代碼行數:22,代碼來源:Helper.java

示例8: testCustomClientConfigurationOnDispatchFromFile

import javax.xml.ws.handler.Handler; //導入依賴的package包/類
public boolean testCustomClientConfigurationOnDispatchFromFile() throws Exception
{
   final String reqString = "<ns1:echo xmlns:ns1=\"http://clientConfig.jaxws.ws.test.jboss.org/\"><arg0>Kermit</arg0></ns1:echo>";
   QName serviceName = new QName("http://clientConfig.jaxws.ws.test.jboss.org/", "EndpointImplService");
   QName portName = new QName("http://clientConfig.jaxws.ws.test.jboss.org/", "EndpointPort");
   URL wsdlURL = new URL(address + "?wsdl");

   Service service = Service.create(wsdlURL, serviceName);
   Dispatch<Source> dispatch = service.createDispatch(portName, Source.class, Mode.PAYLOAD);

   BindingProvider bp = (BindingProvider)dispatch;
   @SuppressWarnings("rawtypes")
   List<Handler> hc = bp.getBinding().getHandlerChain();
   hc.add(new UserHandler());
   bp.getBinding().setHandlerChain(hc);

   ClientConfigUtil.setConfigHandlers(bp, "META-INF/jaxws-client-config.xml", "Custom Client Config");

   Source resSource = dispatch.invoke(new DOMSource(DOMUtils.parse(reqString)));
   resSource = dispatch.invoke(new DOMSource(DOMUtils.parse(reqString)));
   resSource = dispatch.invoke(new DOMSource(DOMUtils.parse(reqString)));
   String resStr = DOMUtils.getTextContent(DOMUtils.sourceToElement(resSource).getElementsByTagName("return").item(0));
   return ("Kermit|RoutOut|CustomOut|UserOut|LogOut|endpoint|LogIn|UserIn|CustomIn|RoutIn".equals(resStr));
}
 
開發者ID:jbossws,項目名稱:jbossws-cxf,代碼行數:25,代碼來源:Helper.java

示例9: testCustomClientConfigurationFromFileUsingFeatureOnDispatch

import javax.xml.ws.handler.Handler; //導入依賴的package包/類
public boolean testCustomClientConfigurationFromFileUsingFeatureOnDispatch() throws Exception
{
   final String reqString = "<ns1:echo xmlns:ns1=\"http://clientConfig.jaxws.ws.test.jboss.org/\"><arg0>Kermit</arg0></ns1:echo>";
   QName serviceName = new QName("http://clientConfig.jaxws.ws.test.jboss.org/", "EndpointImplService");
   QName portName = new QName("http://clientConfig.jaxws.ws.test.jboss.org/", "EndpointPort");
   URL wsdlURL = new URL(address + "?wsdl");

   Service service = Service.create(wsdlURL, serviceName);
   Dispatch<Source> dispatch = service.createDispatch(portName, Source.class, Mode.PAYLOAD,
         new ClientConfigFeature("META-INF/jaxws-client-config.xml", "Custom Client Config"));

   BindingProvider bp = (BindingProvider)dispatch;
   @SuppressWarnings("rawtypes")
   List<Handler> hc = bp.getBinding().getHandlerChain();
   hc.add(new UserHandler());
   bp.getBinding().setHandlerChain(hc);

   Source resSource = dispatch.invoke(new DOMSource(DOMUtils.parse(reqString)));
   resSource = dispatch.invoke(new DOMSource(DOMUtils.parse(reqString)));
   String resStr = DOMUtils.getTextContent(DOMUtils.sourceToElement(resSource).getElementsByTagName("return").item(0));
   return ("Kermit|RoutOut|CustomOut|UserOut|LogOut|endpoint|LogIn|UserIn|CustomIn|RoutIn".equals(resStr));
}
 
開發者ID:jbossws,項目名稱:jbossws-cxf,代碼行數:23,代碼來源:Helper.java

示例10: testSOAP12ClientAccess

import javax.xml.ws.handler.Handler; //導入依賴的package包/類
@Test
@RunAsClient
public void testSOAP12ClientAccess() throws Exception
{
   URL wsdlURL = new URL(baseURL + "/soap12?wsdl");
   QName qname = new QName("http://org.jboss.ws/jaxws/jbws2419", "SOAP12EndpointBeanService");
   Service service = Service.create(wsdlURL, qname);
   SOAP12Endpoint port = service.getPort(SOAP12Endpoint.class);

   BindingProvider provider = (BindingProvider)port;
   @SuppressWarnings("rawtypes")
   List<Handler> handlerChain = new ArrayList<Handler>();
   handlerChain.addAll(provider.getBinding().getHandlerChain());
   handlerChain.add(new SOAP12ClientHandler());
   provider.getBinding().setHandlerChain(handlerChain);
   ((SOAPBinding)provider.getBinding()).setMTOMEnabled(true);

   DataHandler response = port.namespace(new DataHandler("Jimbo","text/plain"));
   Object messg = getContent(response);
   assertEquals("Hello Jimbo", messg);
}
 
開發者ID:jbossws,項目名稱:jbossws-cxf,代碼行數:22,代碼來源:JBWS2419TestCase.java

示例11: testSOAP11ClientAccess

import javax.xml.ws.handler.Handler; //導入依賴的package包/類
@Test
@RunAsClient
public void testSOAP11ClientAccess() throws Exception
{
   URL wsdlURL = new URL(baseURL + "/soap11?wsdl");
   QName qname = new QName("http://org.jboss.ws/jaxws/jbws2419", "SOAP11EndpointBeanService");
   Service service = Service.create(wsdlURL, qname);
   SOAP11Endpoint port = service.getPort(SOAP11Endpoint.class);

   BindingProvider provider = (BindingProvider)port;
   @SuppressWarnings("rawtypes")
   List<Handler> handlerChain = new ArrayList<Handler>();
   handlerChain.addAll(provider.getBinding().getHandlerChain());
   handlerChain.add(new SOAP11ClientHandler());
   provider.getBinding().setHandlerChain(handlerChain);
   ((SOAPBinding)provider.getBinding()).setMTOMEnabled(true);

   DataHandler response = port.namespace(new DataHandler("Jimbo","text/plain"));
   Object messg = getContent(response);
   assertEquals("Hello Jimbo", messg);
}
 
開發者ID:jbossws,項目名稱:jbossws-cxf,代碼行數:22,代碼來源:JBWS2419TestCase.java

示例12: testDynamicHandlerChain

import javax.xml.ws.handler.Handler; //導入依賴的package包/類
@Test
@RunAsClient
public void testDynamicHandlerChain() throws Exception
{
   QName serviceName = new QName(targetNS, "EndpointImplService");
   URL wsdlURL = new URL(baseURL + "/TestService?wsdl");

   Service service = Service.create(wsdlURL, serviceName);
   Endpoint port = service.getPort(Endpoint.class);

   BindingProvider bindingProvider = (BindingProvider)port;
   @SuppressWarnings("rawtypes")
   List<Handler> handlerChain = new ArrayList<Handler>();
   handlerChain.add(new LogHandler());
   handlerChain.add(new AuthorizationHandler());
   handlerChain.add(new RoutingHandler());
   handlerChain.add(new ClientMimeHandler());
   bindingProvider.getBinding().setHandlerChain(handlerChain);

   String resStr = port.echo("Kermit");
   assertEquals("Kermit|LogOut|AuthOut|RoutOut|RoutIn|AuthIn|LogIn|endpoint|LogOut|AuthOut|RoutOut|RoutIn|AuthIn|LogIn", resStr);
   assertCookies();
}
 
開發者ID:jbossws,項目名稱:jbossws-cxf,代碼行數:24,代碼來源:HandlerChainTestCase.java

示例13: testAttachmentResponse

import javax.xml.ws.handler.Handler; //導入依賴的package包/類
@Test
@RunAsClient
public void testAttachmentResponse() throws Exception
{
   QName serviceName = new QName("http://org.jboss.test.ws/jbws1283", "JBWS1283Service");
   URL wsdlURL = new URL(baseURL + "/jaxws-jbws1283/JBWS1283Service/JBWS1283EndpointImpl?wsdl");

   Service service = Service.create(wsdlURL, serviceName);
   JBWS1283Endpoint port = service.getPort(JBWS1283Endpoint.class);
   
   // Add a client-side handler that verifes existence of the attachment
   BindingProvider bindingProvider = (BindingProvider)port;
   @SuppressWarnings("rawtypes")
   List<Handler> handlerChain = new ArrayList<Handler>();
   handlerChain.add(new VerifyAttachmentHandler());
   bindingProvider.getBinding().setHandlerChain(handlerChain);

   port.requestAttachmentData();
}
 
開發者ID:jbossws,項目名稱:jbossws-cxf,代碼行數:20,代碼來源:JBWS1283TestCase.java

示例14: getHandlerChain

import javax.xml.ws.handler.Handler; //導入依賴的package包/類
@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;
   }
}
 
開發者ID:jbossws,項目名稱:jbossws-cxf,代碼行數:17,代碼來源:CXFHandlerResolverImpl.java

示例15: sortHandlers

import javax.xml.ws.handler.Handler; //導入依賴的package包/類
@SuppressWarnings("rawtypes")
public List<Handler> sortHandlers(List<Handler> handlers) {

   final int size = handlers.size();
   List<Handler> logicalHandlers = new ArrayList<Handler>(size);
   List<Handler> protocolHandlers = new ArrayList<Handler>(Math.min(10, size));

   for (Handler handler : handlers) {
      if (handler instanceof LogicalHandler) {
         logicalHandlers.add(handler);
      } else {
         protocolHandlers.add(handler);
      }
   }

   if (!protocolHandlers.isEmpty()) {
      logicalHandlers.addAll(protocolHandlers);
   }
   return logicalHandlers;
}
 
開發者ID:jbossws,項目名稱:jbossws-cxf,代碼行數:21,代碼來源:CXFHandlerResolverImpl.java


注:本文中的javax.xml.ws.handler.Handler類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。