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); } } }
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); } } } }
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); }
@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); } }
@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 } }
@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); }
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)); }
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)); }
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)); }
@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); }
@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); }
@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(); }
@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(); }
@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; } }
@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; }
@Override @SuppressWarnings("rawtypes") public void handleMessage(Message message) throws Fault { if (binding != null) { Exchange ex = message.getExchange(); if (ex.get(HandlerChainInvoker.class) == null) { List<Handler> hc = binding.getHandlerChain(); if (hc.size() > 1) { //no need to sort etc if the chain is empty or has one handler only Collections.sort(hc, comparator); //install a new HandlerChainInvoker using the sorted handler chain; //the AbstractJAXWSHandlerInterceptor will be using this invoker //instead of creating a new one ex.put(HandlerChainInvoker.class, new HandlerChainInvoker(hc, isOutbound(message, ex))); } } } }
@Override public void handleMessage(Message message) throws Fault { final Exchange ex = message.getExchange(); HandlerChainInvoker invoker = ex.get(HandlerChainInvoker.class); if (null == invoker) { final org.apache.cxf.endpoint.Endpoint endpoint = ex.getEndpoint(); if (endpoint instanceof JaxWsEndpointImpl) { // JAXWS handlers are not assigned to different endpoint types final JaxWsEndpointImpl ep = (JaxWsEndpointImpl)endpoint; @SuppressWarnings("rawtypes") final List<Handler> handlerChain = ep.getJaxwsBinding().getHandlerChain(); if (handlerChain != null && !handlerChain.isEmpty()) { //save invoker = new JBossWSHandlerChainInvoker(handlerChain, isOutbound(message, ex)); ex.put(HandlerChainInvoker.class, invoker); } } } }
private static void injectServiceAndHandlerResources(Endpoint endpoint) { org.apache.cxf.endpoint.Endpoint ep = endpoint.getAttachment(org.apache.cxf.endpoint.Endpoint.class); if (ep != null) { @SuppressWarnings("rawtypes") List<Handler> chain = ((JaxWsEndpointImpl) ep).getJaxwsBinding().getHandlerChain(); if (chain != null) { for (Handler<?> handler : chain) { if (handler instanceof ConfigDelegateHandler) { handler = ((ConfigDelegateHandler<?>) handler).getDelegate(); } final Reference handlerReference = endpoint.getInstanceProvider().getInstance(handler.getClass().getName()); if (!handlerReference.isInitialized()) { final Object handlerInstance = handlerReference.getValue(); InjectionHelper.callPostConstructMethod(handlerInstance); handlerReference.setInitialized(); } } } } }
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; }
public CertRAClient(String location) { CertRaService certRaService = CertRaServiceFactory.newInstance(); this.port = certRaService.getCertRaPort(); BindingProvider bindingProvider = (BindingProvider) this.port; bindingProvider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, location); Binding binding = bindingProvider.getBinding(); List<Handler> handlerChain = binding.getHandlerChain(); handlerChain.add(new LoggingHandler()); // LoggingHandler makes CXF fail on the attachments. // https://issues.apache.org/jira/browse/CXF-5496 binding.setHandlerChain(handlerChain); this.protocolObjectFactory = new be.e_contract.mycarenet.certra.jaxb.protocol.ObjectFactory(); }
/** * Main constructor. * * @param location * the URL of the eHealth STS web service. */ public EHealthSTSClient(String location) { EHealthSamlStsService service = EHealthSamlStsServiceFactory .newInstance(); QName portQName = new QName("urn:be:ehealth:saml:sts:1.0", "EHealthSamlStsPort"); this.dispatch = service.createDispatch(portQName, Source.class, Service.Mode.PAYLOAD); this.dispatch.getRequestContext().put( Dispatch.ENDPOINT_ADDRESS_PROPERTY, location); Binding binding = dispatch.getBinding(); @SuppressWarnings("rawtypes") List<Handler> handlerChain = binding.getHandlerChain(); this.wsSecuritySOAPHandler = new WSSecuritySOAPHandler(); handlerChain.add(this.wsSecuritySOAPHandler); handlerChain.add(new LoggingHandler()); binding.setHandlerChain(handlerChain); }
/** * Main constructor. * * @param location * the URL of the MyCareNet XKMS web service. */ public XKMSClient(String location) { XMLKeyManagementService service = XKMSServiceFactory.newInstance(); this.port = service.getKeyServiceSoapPort(); BindingProvider bindingProvider = (BindingProvider) this.port; bindingProvider.getRequestContext().put( BindingProvider.ENDPOINT_ADDRESS_PROPERTY, location); Binding binding = bindingProvider.getBinding(); @SuppressWarnings("rawtypes") List<Handler> handlerChain = binding.getHandlerChain(); handlerChain.add(new LoggingHandler()); this.proofOfPossessionSignatureSOAPHandler = new ProofOfPossessionSignatureSOAPHandler(); handlerChain.add(this.proofOfPossessionSignatureSOAPHandler); handlerChain.add(new LoggingHandler()); binding.setHandlerChain(handlerChain); this.objectFactory = new ObjectFactory(); this.xmldsigObjectFactory = new be.e_contract.mycarenet.jaxb.xmldsig.ObjectFactory(); }
/** * Decorates a given JAX-WS port with the required security handlers. * * @param bindingProvider * the JAX-WS port to decorate. * @return the added payload logical JAX-WS handler. */ public PayloadLogicalHandler decorate(BindingProvider bindingProvider) { bindingProvider.getRequestContext().put( BindingProvider.ENDPOINT_ADDRESS_PROPERTY, this.location); Binding binding = bindingProvider.getBinding(); @SuppressWarnings("rawtypes") List<Handler> handlerChain = binding.getHandlerChain(); SecuritySOAPHandler sessionKeySignatureSOAPHandler = new SecuritySOAPHandler( this.sessionKey, this.packageLicenseKey); handlerChain.add(sessionKeySignatureSOAPHandler); handlerChain.add(new LoggingHandler()); PayloadLogicalHandler payloadLogicalHandler = new PayloadLogicalHandler(); handlerChain.add(payloadLogicalHandler); binding.setHandlerChain(handlerChain); return payloadLogicalHandler; }
/** * 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; }
public void setHandlerChain(List<Handler> list) { // handlers cannot be null so a client app can request and manipulate it if (list == null) { handlers = new ArrayList<Handler>(); // non-null, but rather // empty if (log.isDebugEnabled()) { log.debug("setHandlerChain called with a null list. " + "A empty list is created:" + JavaUtils.getObjectIdentity(handlers)); } } else { // Use the handler list provided by the caller. // The JAX-WS runtime nor user should ever modify this list or a ConcurrentModificationException // may occur. // @see org.apache.axis2.jaxws.handler.HandlerChainProcessor which makes a copy of // the handler chain to avoid potential CMEs. if (log.isDebugEnabled()) { log.debug("setHandlerChain called with a list:" + JavaUtils.getObjectIdentity(list)); } this.handlers = list; } }
/** * destroyHandlerInstance calls the handler's annotated PreDestroy method, * if it exists. A handler instance that has been passed through this method SHOULD NOT be used again * * @param handler */ public void destroyHandlerInstance(MessageContext mc, Handler handler) throws LifecycleException, ResourceInjectionException { if (handler == null) { throw ExceptionFactory. makeWebServiceException(Messages.getMessage("destroyHandlerInstanceErr")); } this.instance = handler; ServiceDescription serviceDesc = mc.getEndpointDescription().getServiceDescription(); ResourceInjectionServiceRuntimeDescription injectionDesc = null; if (serviceDesc != null) { injectionDesc = ResourceInjectionServiceRuntimeDescriptionFactory.get(serviceDesc, handler.getClass()); } //Invoke PreDestroy if (injectionDesc != null && injectionDesc.getPreDestroyMethod() != null) { invokePreDestroy(injectionDesc.getPreDestroyMethod()); } }
private void callCloseWithTracker(Handler handler) { currentHandler = handler; currentMethod = "close"; // turn on the tracker property currentMC.put(org.apache.axis2.jaxws.handler.Constants.JAXWS_HANDLER_TRACKER, true); RuntimeException savedEx = null; try { handler.close(currentMC); } catch (RuntimeException t) { savedEx = t; } // turn off the tracker property and reset the static tracker booleans currentMC.put(org.apache.axis2.jaxws.handler.Constants.JAXWS_HANDLER_TRACKER, false); saaj_called = false; soap_headers_adapter_called = false; if (savedEx != null) { throw savedEx; } }
/** * 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()); }
/** * Verify that handler information in a sparse composite on the Port will override any handler chain * annotation on the SEI. */ public void testSEIHandlerChainOverrideOnPort() { QName serviceQN = new QName(namespaceURI, svcLocalPart + uniqueService++); Service service = Service.create(serviceQN); // The SEI has a HandlerChain annotation, but the sparse metadata should override it DescriptionBuilderComposite sparseComposite = new DescriptionBuilderComposite(); HandlerChainsType handlerChainsType = getHandlerChainsType(); sparseComposite.setHandlerChainsType(handlerChainsType); ServiceDelegate.setPortMetadata(sparseComposite); ClientMetadataHandlerChainTestSEIWithHC port = service.getPort(ClientMetadataHandlerChainTestSEIWithHC.class); BindingProvider bindingProvider = (BindingProvider) port; Binding binding = (Binding) bindingProvider.getBinding(); List<Handler> portHandlers = binding.getHandlerChain(); assertEquals(2, portHandlers.size()); assertTrue(containsSparseCompositeHandlers(portHandlers)); }
/** * Verify that handler information in a sparse composite on the Service will override any handler chain * annotation on the SEI. */ public void testSEIHandlerChainOverrideOnService() { QName serviceQN = new QName(namespaceURI, svcLocalPart + uniqueService++); // The SEI has a HandlerChain annotation, but the sparse metadata should override it DescriptionBuilderComposite sparseComposite = new DescriptionBuilderComposite(); HandlerChainsType handlerChainsType = getHandlerChainsType(); sparseComposite.setHandlerChainsType(handlerChainsType); ServiceDelegate.setServiceMetadata(sparseComposite); Service service = Service.create(serviceQN); ClientMetadataHandlerChainTestSEIWithHC port = service.getPort(ClientMetadataHandlerChainTestSEIWithHC.class); BindingProvider bindingProvider = (BindingProvider) port; Binding binding = (Binding) bindingProvider.getBinding(); List<Handler> portHandlers = binding.getHandlerChain(); assertEquals(2, portHandlers.size()); assertTrue(containsSparseCompositeHandlers(portHandlers)); }
/** * Verfiy that given a HandlerChain annotation on the Service and a Port and a sparse composite * on the Port associates the handlers from the sparse composite on the Port. */ public void testGeneratedServiceWithHCPortOverride() { ClientMetadataHandlerChainTestServiceWithHC service = new ClientMetadataHandlerChainTestServiceWithHC(); // Set a HandlerChainsType on the sparse composite for the Port creation; it should override the // HandlerChain annotation on the Service. DescriptionBuilderComposite sparseComposite = new DescriptionBuilderComposite(); HandlerChainsType handlerChainsType = getHandlerChainsType(); sparseComposite.setHandlerChainsType(handlerChainsType); ServiceDelegate.setPortMetadata(sparseComposite); ClientMetadataHandlerChainTestSEI port = service.getPort(ClientMetadataHandlerChainTestSEI.class); BindingProvider bindingProvider = (BindingProvider) port; Binding binding = (Binding) bindingProvider.getBinding(); List<Handler> portHandlers = binding.getHandlerChain(); assertEquals(2, portHandlers.size()); assertTrue(containsSparseCompositeHandlers(portHandlers)); }