/** * Unregisters a service endpoint. * * @param path the endpoint path */ public synchronized void unregisterService(String path) { if (delegate == null) { // case where the endpoint is undeployed before it has been activated for (Iterator<EndpointConfiguration> it = configurations.iterator(); it.hasNext(); ) { EndpointConfiguration configuration = it.next(); if (configuration.getServicePath().equals(path)) { it.remove(); return; } } return; } ServletAdapter adapter = delegate.unregisterServletAdapter(path); if (adapter != null) { container.removeEndpoint(adapter); } }
public synchronized void registerService(EndpointConfiguration configuration) { if (delegate == null) { // servlet has not be initialized, delay service registration configurations.add(configuration); return; } Class<?> seiClass = configuration.getSeiClass(); ClassLoader classLoader = seiClass.getClassLoader(); ClassLoader old = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(classLoader); URL wsdlLocation = configuration.getWsdlLocation(); SDDocumentSource primaryWsdl = null; if (wsdlLocation != null) { // WSDL may not be defined for a Java-based endpoint, in which case it will be introspected // from the SEI class primaryWsdl = SDDocumentSource.create(wsdlLocation); } WSBinding binding = BindingImpl.create(BindingID.SOAP11_HTTP); Container endpointContainer = container; List<SDDocumentSource> metadata = null; URL generatedWsdl = configuration.getGeneratedWsdl(); if (generatedWsdl != null) { // create a container wrapper used by Metro to resolve the WSIT configuration endpointContainer = new WsitConfigurationContainer(container, generatedWsdl); // Compile the list of imported schemas so they can be resolved using ?xsd GET requests. // Metro will re-write the WSDL import // so clients can dereference the imports when they obtain the WSDL. metadata = new ArrayList<>(); List<URL> schemas = configuration.getGeneratedSchemas(); if (schemas != null) { for (URL schema : schemas) { metadata.add(SDDocumentSource.create(schema)); } } } String servicePath = configuration.getServicePath(); Invoker invoker = configuration.getInvoker(); QName serviceName = configuration.getServiceName(); QName portName = configuration.getPortName(); // Fetch the handlers loadHandlers(binding, configuration); WSEndpoint<?> wsEndpoint; try { wsEndpoint = WSEndpoint.create( seiClass, false, invoker, serviceName, portName, endpointContainer, binding, primaryWsdl, metadata, null, true); } catch (WebServiceException e) { if (e.getMessage().contains("Not a primary WSDL")) { // workaround for WSDLs without service declarations wsEndpoint = WSEndpoint.create( seiClass, false, invoker, serviceName, portName, endpointContainer, binding, null, metadata, null, true); } else { throw e; } } wsEndpoint.setExecutor(executorService); ServletAdapter adapter = servletAdapterFactory.createAdapter(servicePath, servicePath, wsEndpoint); delegate.registerServletAdapter(adapter, F3Provider.class.getClassLoader()); String mexPath = servicePath + MEX_SUFFIX; ServletAdapter mexAdapter = servletAdapterFactory.createAdapter(mexPath, mexPath, mexEndpoint); delegate.registerServletAdapter(mexAdapter, F3Provider.class.getClassLoader()); } finally { Thread.currentThread().setContextClassLoader(old); } }