Search in sources :

Example 1 with UnknownExtensibilityElement

use of javax.wsdl.extensions.UnknownExtensibilityElement in project tdi-studio-se by Talend.

the class ComponentBuilder method createSchemaFromTypes.

protected Vector<XmlSchema> createSchemaFromTypes(List<Definition> wsdlDefinitions) throws WSDLException {
    Vector<XmlSchema> schemas = new Vector<XmlSchema>();
    Set<String> imports = new HashSet<String>();
    org.w3c.dom.Element schemaElementt = null;
    Map importElement = null;
    List includeElement = null;
    for (Definition def : wsdlDefinitions) {
        if (def.getTypes() != null) {
            Vector schemaExtElem = findExtensibilityElement(def.getTypes().getExtensibilityElements(), "schema");
            for (int i = 0; i < schemaExtElem.size(); i++) {
                ExtensibilityElement schemaElement = (ExtensibilityElement) schemaExtElem.elementAt(i);
                if (schemaElement != null && schemaElement instanceof UnknownExtensibilityElement) {
                    schemaElementt = ((UnknownExtensibilityElement) schemaElement).getElement();
                    String documentBase = ((javax.wsdl.extensions.schema.Schema) schemaElement).getDocumentBaseURI();
                    XmlSchema schema = createschemafromtype(schemaElementt, def, documentBase);
                    if (schema != null) {
                        schemas.add(schema);
                        if (schema.getTargetNamespace() != null) {
                            schemaNames.add(schema.getTargetNamespace());
                        }
                    }
                    importElement = ((javax.wsdl.extensions.schema.Schema) schemaElement).getImports();
                    if (importElement != null && importElement.size() > 0) {
                        findImportSchema(def, schemas, importElement, imports);
                    }
                }
                if (schemaElement != null && schemaElement instanceof javax.wsdl.extensions.schema.Schema) {
                    schemaElementt = ((javax.wsdl.extensions.schema.Schema) schemaElement).getElement();
                    String documentBase = ((javax.wsdl.extensions.schema.Schema) schemaElement).getDocumentBaseURI();
                    Boolean isHaveImport = false;
                    importElement = ((javax.wsdl.extensions.schema.Schema) schemaElement).getImports();
                    if (importElement != null && importElement.size() > 0) {
                        Iterator keyIterator = importElement.keySet().iterator();
                        // }
                        if (importElement.size() > 0) {
                            isHaveImport = true;
                        }
                    // validateImportUrlPath(importElement);
                    }
                    XmlSchema schema = createschemafromtype(schemaElementt, def, documentBase);
                    if (schema != null) {
                        schemas.add(schema);
                        if (schema.getTargetNamespace() != null) {
                            schemaNames.add(schema.getTargetNamespace());
                        }
                    }
                    if (isHaveImport) {
                        findImportSchema(def, schemas, importElement, imports);
                    }
                }
            }
        }
    }
    return schemas;
}
Also used : XmlSchema(org.apache.ws.commons.schema.XmlSchema) Definition(javax.wsdl.Definition) UnknownExtensibilityElement(javax.wsdl.extensions.UnknownExtensibilityElement) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) XmlSchema(org.apache.ws.commons.schema.XmlSchema) UnknownExtensibilityElement(javax.wsdl.extensions.UnknownExtensibilityElement) Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList) Vector(java.util.Vector) Map(java.util.Map) HashSet(java.util.HashSet)

Example 2 with UnknownExtensibilityElement

use of javax.wsdl.extensions.UnknownExtensibilityElement in project tomee by apache.

the class CommonsSchemaLoader method addImportsFromDefinition.

private void addImportsFromDefinition(Definition definition) throws OpenEJBException {
    Types types = definition.getTypes();
    if (types != null) {
        for (Object extensibilityElement : types.getExtensibilityElements()) {
            if (extensibilityElement instanceof Schema) {
                Schema unknownExtensibilityElement = (Schema) extensibilityElement;
                QName elementType = unknownExtensibilityElement.getElementType();
                if (new QName("http://www.w3.org/2001/XMLSchema", "schema").equals(elementType)) {
                    Element element = unknownExtensibilityElement.getElement();
                    xmlSchemaCollection.read(element);
                }
            } else if (extensibilityElement instanceof UnknownExtensibilityElement) {
                //This is allegedly obsolete as of axis-wsdl4j-1.2-RC3.jar which includes the Schema extension above.
                //The change notes imply that imported schemas should end up in Schema elements.  They don't, so this is still needed.
                UnknownExtensibilityElement unknownExtensibilityElement = (UnknownExtensibilityElement) extensibilityElement;
                Element element = unknownExtensibilityElement.getElement();
                String elementNamespace = element.getNamespaceURI();
                String elementLocalName = element.getNodeName();
                if ("http://www.w3.org/2001/XMLSchema".equals(elementNamespace) && "schema".equals(elementLocalName)) {
                    xmlSchemaCollection.read(element);
                }
            }
        }
    }
    //noinspection unchecked
    Map<String, List<Import>> imports = definition.getImports();
    if (imports != null) {
        for (Map.Entry<String, List<Import>> entry : imports.entrySet()) {
            String namespaceURI = entry.getKey();
            List<Import> importList = entry.getValue();
            for (Import anImport : importList) {
                //according to the 1.1 jwsdl mr shcema imports are supposed to show up here,
                //but according to the 1.0 spec there is supposed to be no Definition.
                Definition importedDef = anImport.getDefinition();
                if (importedDef != null) {
                    addImportsFromDefinition(importedDef);
                } else {
                    log.warn("Missing definition in import for namespace " + namespaceURI);
                }
            }
        }
    }
}
Also used : Types(javax.wsdl.Types) Import(javax.wsdl.Import) QName(javax.xml.namespace.QName) Schema(javax.wsdl.extensions.schema.Schema) UnknownExtensibilityElement(javax.wsdl.extensions.UnknownExtensibilityElement) Element(org.w3c.dom.Element) Definition(javax.wsdl.Definition) UnknownExtensibilityElement(javax.wsdl.extensions.UnknownExtensibilityElement) ArrayList(java.util.ArrayList) List(java.util.List) Map(java.util.Map)

Aggregations

ArrayList (java.util.ArrayList)2 List (java.util.List)2 Map (java.util.Map)2 Definition (javax.wsdl.Definition)2 UnknownExtensibilityElement (javax.wsdl.extensions.UnknownExtensibilityElement)2 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 Vector (java.util.Vector)1 Import (javax.wsdl.Import)1 Types (javax.wsdl.Types)1 ExtensibilityElement (javax.wsdl.extensions.ExtensibilityElement)1 Schema (javax.wsdl.extensions.schema.Schema)1 QName (javax.xml.namespace.QName)1 XmlSchema (org.apache.ws.commons.schema.XmlSchema)1 Element (org.w3c.dom.Element)1