Refine search
@SuppressWarnings("unchecked") protected void parseWSDL(String wsdlURL) { try { WSDLManager mgr = bus.getExtension(WSDLManager.class); registerWSDLExtensibilityPlugins(mgr.getExtensionRegistry()); wsdlDefinition = mgr.getDefinition(wsdlURL); parseImports(wsdlDefinition); if (wsdlDefinition.getServices().isEmpty()) { for (Definition def : importedDefinitions) { Set<QName> services = def.getServices().keySet(); for (QName sName : services) { if (!wsdlDefinition.getServices().keySet().contains(sName)) { wsdlDefinition.getServices().put(sName, def.getService(sName)); } } } } } catch (Exception we) { Message msg = new Message("FAIL_TO_CREATE_WSDL_DEFINITION", LOG, wsdlURL, we.getMessage()); throw new WSDLRuntimeException(msg, we); } }
private static Document getWsdlDocument(Bus bus, Definition def) throws WSDLException { WSDLWriter wsdlWriter = bus.getExtension(WSDLManager.class).getWSDLFactory().newWSDLWriter(); def.setExtensionRegistry(bus.getExtension(WSDLManager.class).getExtensionRegistry()); return wsdlWriter.getDocument(def); }
public void parseWSDL(String wsdlUrl) { try { Bus bus = BusFactory.getThreadDefaultBus(); WSDLManager mgr = bus.getExtension(WSDLManager.class); wsdlDefinition = mgr.getDefinition(wsdlUrl); WSDLServiceBuilder builder = new WSDLServiceBuilder(bus); builder.buildMockServices(wsdlDefinition); schemas = mgr.getSchemasForDefinition(wsdlDefinition); //remove this as we're going to be modifying it mgr.removeDefinition(wsdlDefinition); } catch (WSDLException we) { org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message( "FAIL_TO_CREATE_WSDL_DEFINITION", LOG); throw new ToolException(msg, we); } }
private Definition newDefinition(final QName name, String targetNamespace) { Definition d = bus.getExtension(WSDLManager.class).getWSDLFactory().newDefinition(); d.setExtensionRegistry(bus.getExtension(WSDLManager.class).getExtensionRegistry()); d.setQName(name); d.setTargetNamespace(targetNamespace); addNamespace(WSDLConstants.NP_SCHEMA_XSD, WSDLConstants.NS_SCHEMA_XSD, d); return d; }
public Definition createWSDLDefinition(String tns) throws WSDLException, JAXBException { WSDLManager wm = BusFactory.getThreadDefaultBus().getExtension(WSDLManager.class); WSDLFactory wsdlFactory = wm.getWSDLFactory(); Definition wsdlDefinition = wsdlFactory.newDefinition(); wsdlDefinition.setExtensionRegistry(wm.getExtensionRegistry()); wsdlDefinition.setTargetNamespace(tns); wsdlDefinition.addNamespace("wsdl", "http://schemas.xmlsoap.org/wsdl/"); wsdlDefinition.addNamespace(WSDLConstants.NP_SCHEMA_XSD, WSDLConstants.NS_SCHEMA_XSD); wsdlDefinition.addNamespace(WSDLConstants.SOAP11_PREFIX, WSDLConstants.NS_SOAP11); wsdlDefinition.addNamespace("tns", tns); wsdlDefinition.addNamespace(CorbaConstants.NP_WSDL_CORBA, CorbaConstants.NU_WSDL_CORBA); defns.put(tns, wsdlDefinition); return wsdlDefinition; }
public WSDLServiceFactory(Bus b, String url) { setBus(b); wsdlUrl = url; try { // use wsdl manager to parse wsdl or get cached definition definition = getBus().getExtension(WSDLManager.class).getDefinition(url); } catch (WSDLException ex) { throw new ServiceConstructionException(new Message("SERVICE_CREATION_MSG", LOG), ex); } }
&& wsdlDocumentLocation != null && interfaceName == null) { Bus bus = BusFactory.getThreadDefaultBus(); WSDLManager wsdlManager = bus.getExtension(WSDLManager.class); try { Definition def = wsdlManager.getDefinition(wsdlDocumentLocation); interfaceName = def.getService(serviceName).getPort(portName.getLocalPart()).getBinding() .getPortType().getQName(); } catch (Exception e) { throw new WebServiceException(new Message("ERROR_UNMARSHAL_ENDPOINTREFERENCE", LOG).toString(), e);
if (addressing != null) { ExtensionRegistry extensionRegistry = getBus().getExtension(WSDLManager.class).getExtensionRegistry(); try { ExtensibilityElement el = extensionRegistry.createExtension(javax.wsdl.Binding.class,
throw new ToolException(new Message("FOUND_NO_FRONTEND", LOG)); .buildServices(definition, getServiceQName(definition)); serviceList.addAll(services); } else if (definition.getServices().size() > 0) { serviceList = serviceBuilder.buildServices(definition); } else { getBus().getExtension(WSDLManager.class).removeDefinition(definition); } else {
private boolean isEmptywsdl(String wsdlUrl) { Definition definition; try { definition = getBus().getExtension(WSDLManager.class).getDefinition(wsdlUrl); } catch (WSDLException e) { LOG.log(Level.WARNING, "Failed to parse WSDL", e); return true; } if (definition.getPortTypes().isEmpty() && definition.getImports().isEmpty()) { return true; } return false; } }
private void initializePorts() { try { Definition def = bus.getExtension(WSDLManager.class).getDefinition(wsdlURL); javax.wsdl.Service serv = def.getService(serviceName); if (serv == null) { throw new WebServiceException("Could not find service named " + serviceName
protected Definition getDefinition(String url) { if (definition == null) { try { definition = getBus().getExtension(WSDLManager.class).getDefinition(url); } catch (Exception ex) { throw new RuntimeCamelException(ex); Map<QName, ?> services = CastUtils.cast(definition.getServices()); if (services.size() == 0) { throw new IllegalArgumentException("There is no service in the WSDL" + url); Service service = definition.getService(getServiceQName(false)); Map<String, ?> ports = CastUtils.cast(service.getPorts()); if (ports.size() == 0) {
if ("http://schemas.xmlsoap.org/wsdl/".equals(s.getDialect())) { definition = bus.getExtension(WSDLManager.class).getDefinition((Element)s.getAny()); } else if ("http://www.w3.org/2001/XMLSchema".equals(s.getDialect())) { Element schemaElement = (Element)s.getAny(); WSDLManager wsdlManager = bus.getExtension(WSDLManager.class); ExtensibilityElement exElement = wsdlManager.getExtensionRegistry().createExtension(Types.class, schemaName); ((Schema)exElement).setElement(schemaElement); schemas.add((Schema)exElement); definition.getTypes().addExtensibilityElement(schema);
try { if (bus != null) { ClassLoader newLoader = bus.getExtension(ClassLoader.class); if (newLoader != null) { loader = ClassLoaderUtils.setThreadContextClassloader(newLoader); .getProperty(WSDLServiceBuilder.WSDL_DEFINITION, Definition.class); if (def == null) { def = bus.getExtension(WSDLManager.class).getDefinition(wsdlLocation);
private static String findNamespaceHack(EndpointReferenceType ref, Bus bus) { //probably a broken version of Xalan, we'll have to //try a hack to figure out the namespace as xalan //dropped the namespace declaration so there isn't //a way to map the namespace prefix to the real namespace. //This is fixed in xalan 2.7.1, but older versions may //be used if (bus == null) { return ""; } String wsdlLocation = getWSDLLocation(ref); if (StringUtils.isEmpty(wsdlLocation)) { return ""; } if (bus != null) { WSDLManager manager = bus.getExtension(WSDLManager.class); if (manager != null) { try { Definition def = manager.getDefinition(wsdlLocation); return def.getTargetNamespace(); } catch (WSDLException e) { //ignore } } } return ""; }
public QName getServiceName() { if (serviceName == null && serviceNameString != null) { serviceName = QName.valueOf(resolvePropertyPlaceholders(serviceNameString)); } //if not specify the service name and if the wsdlUrl is available, //parse the wsdl to see if only one service in it, if so set the only service //from wsdl to avoid ambiguity if (serviceName == null && getWsdlURL() != null) { // use wsdl manager to parse wsdl or get cached // definition try { Definition definition = getBus().getExtension(WSDLManager.class) .getDefinition(getWsdlURL()); if (definition.getServices().size() == 1) { serviceName = (QName) definition.getServices().keySet() .iterator().next(); } } catch (WSDLException e) { throw new RuntimeException(e); } } return serviceName; }
private void processSchemas(Bus bus) { try { ServiceSchemaInfo info = bus.getExtension(WSDLManager.class) .getSchemasForDefinition(definition); if (info == null) { getSchemas(bus); } else { schemaCollection = info.getSchemaCollection(); } checkTargetNamespace(this.definition.getTargetNamespace()); } catch (Exception ex) { throw new ToolException(ex); } } private Collection<Import> getImports(final Definition wsdlDef) {
public void customize() { if (!context.containsKey(ToolConstants.CFG_BINDING)) { return; } WSDLManager mgr = bus.getExtension(WSDLManager.class); mgr.removeDefinition(wsdlDefinition); cusParser = new CustomizationParser(); cusParser.parse(context); jaxbBindings = cusParser.getJaxbBindings(); handlerChain = cusParser.getHandlerChains(); context.setJaxbBindingFiles(jaxbBindings); context.put(ToolConstants.HANDLER_CHAIN, handlerChain); try { this.wsdlDefinition = buildCustomizedDefinition(); } catch (Exception e) { Message msg = new Message("FAIL_TO_CREATE_WSDL_DEFINITION", LOG, (String)context.get(ToolConstants.CFG_WSDLURL)); throw new RuntimeException(msg.toString(), e); } }
private void getSchemas(Definition def, ServiceInfo serviceInfo) { ServiceSchemaInfo serviceSchemaInfo = null; WSDLManager wsdlManager = bus.getExtension(WSDLManager.class); if (wsdlManager != null) { serviceSchemaInfo = wsdlManager.getSchemasForDefinition(def); } if (serviceSchemaInfo == null) { SchemaUtil schemaUtil = new SchemaUtil(bus, this.schemaList); schemaUtil.getSchemas(def, serviceInfo); serviceSchemaInfo = new ServiceSchemaInfo(); serviceSchemaInfo.setSchemaElementList(this.schemaList); serviceSchemaInfo.setSchemaCollection(serviceInfo.getXmlSchemaCollection()); serviceSchemaInfo.setSchemaInfoList(serviceInfo.getSchemas()); if (wsdlManager != null) { wsdlManager.putSchemasForDefinition(def, serviceSchemaInfo); } } else { serviceInfo.setServiceSchemaInfo(serviceSchemaInfo); schemaList.putAll(serviceSchemaInfo.getSchemaElementList()); } }
protected void parseWSDL(String wsdlURL) throws ToolException { Bus bus = env.get(Bus.class); if (bus == null) { bus = BusFactory.getThreadDefaultBus(); env.put(Bus.class, bus); } WSDLDefinitionBuilder builder = new WSDLDefinitionBuilder(bus); wsdlDefinition = builder.build(wsdlURL); if (env.fullValidateWSDL()) { validate(wsdlDefinition, env, bus); } WSDLManager mgr = bus.getExtension(WSDLManager.class); mgr.removeDefinition(wsdlDefinition); wsdlFactory = mgr.getWSDLFactory(); extReg = mgr.getExtensionRegistry(); wsdlPlugins = builder.getWSDLPlugins(); }