Search in sources :

Example 1 with Schema

use of javax.wsdl.extensions.schema.Schema in project Activiti by Activiti.

the class WSDLImporter method compileModel.

private S2JJAXBModel compileModel(Types types, SchemaCompiler compiler, Element rootTypes) {
    Schema schema = (Schema) types.getExtensibilityElements().get(0);
    compiler.parseSchema(schema.getDocumentBaseURI() + "#types1", rootTypes);
    S2JJAXBModel intermediateModel = compiler.bind();
    return intermediateModel;
}
Also used : Schema(javax.wsdl.extensions.schema.Schema) S2JJAXBModel(com.sun.tools.xjc.api.S2JJAXBModel)

Example 2 with Schema

use of javax.wsdl.extensions.schema.Schema in project Activiti by Activiti.

the class CxfWSDLImporter method compileModel.

protected S2JJAXBModel compileModel(Types types, SchemaCompiler compiler, org.w3c.dom.Element rootTypes) {
    Schema schema = (Schema) types.getExtensibilityElements().get(0);
    compiler.parseSchema(schema.getDocumentBaseURI() + "#types1", rootTypes);
    S2JJAXBModel intermediateModel = compiler.bind();
    return intermediateModel;
}
Also used : Schema(javax.wsdl.extensions.schema.Schema) S2JJAXBModel(com.sun.tools.xjc.api.S2JJAXBModel)

Example 3 with Schema

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

the class AllTypeDialog method initSimpleType.

private void initSimpleType() throws WSDLException, URISyntaxException {
    String url = URLValue;
    XmlSchemaCollection schemaCollection = new XmlSchemaCollection();
    WSDLFactory wsdlFactory = WSDLFactory.newInstance();
    WSDLReader newWSDLReader = wsdlFactory.newWSDLReader();
    newWSDLReader.setFeature(com.ibm.wsdl.Constants.FEATURE_VERBOSE, false);
    URI wsdlURI = new URI(url);
    Definition definition = newWSDLReader.readWSDL(url);
    java.util.List<ExtensibilityElement> extensibilityElements = definition.getTypes().getExtensibilityElements();
    String tmpTNName = "";
    int tmpCount = 0;
    for (ExtensibilityElement el : extensibilityElements) {
        if (el instanceof Schema) {
            Schema schema = (Schema) el;
            // for bug 8674
            // set base uri for relative path in schemaLocation.
            schemaCollection.setBaseUri(schema.getDocumentBaseURI());
            if (schema.getElement().getAttributeNode("targetNamespace") == null) {
                tmpTNName = schema.getDocumentBaseURI() + "#type" + tmpCount;
                schemaCollection.read(schema.getElement(), tmpTNName);
                tmpCount++;
            } else {
                schemaCollection.read(schema.getElement());
            }
        }
    }
    Map namespaces = definition.getNamespaces();
    // System.out.println(namespaces);
    XmlSchema[] schemas = schemaCollection.getXmlSchemas();
    java.util.List<String> labelList = new ArrayList<String>();
    for (int i = 0; i < schemas.length; i++) {
        XmlSchema schema = schemas[i];
        XmlSchemaObjectTable types = schema.getSchemaTypes();
        Iterator it = types.getValues();
        while (it.hasNext()) {
            XmlSchemaType type = (XmlSchemaType) it.next();
            if (type instanceof XmlSchemaSimpleType) {
                XmlSchemaSimpleType t = (XmlSchemaSimpleType) type;
                String label = "simpletype:" + t.getName();
                if (!labelList.contains(label)) {
                    labelList.add(label);
                    labelAndNameSpaceMap.put(label, t.getQName().toString());
                }
            }
        }
    }
    allXMLSimpleTypeName = new String[labelList.size()];
    for (int i = 0; i < labelList.size(); i++) {
        allXMLSimpleTypeName[i] = labelList.get(i);
    }
}
Also used : XmlSchemaObjectTable(org.apache.ws.commons.schema.XmlSchemaObjectTable) XmlSchema(org.apache.ws.commons.schema.XmlSchema) Schema(javax.wsdl.extensions.schema.Schema) Definition(javax.wsdl.Definition) ArrayList(java.util.ArrayList) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType) XmlSchemaCollection(org.apache.ws.commons.schema.XmlSchemaCollection) URI(java.net.URI) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) WSDLFactory(javax.wsdl.factory.WSDLFactory) XmlSchema(org.apache.ws.commons.schema.XmlSchema) XmlSchemaSimpleType(org.apache.ws.commons.schema.XmlSchemaSimpleType) Iterator(java.util.Iterator) Map(java.util.Map) HashMap(java.util.HashMap) WSDLReader(javax.wsdl.xml.WSDLReader)

Example 4 with Schema

use of javax.wsdl.extensions.schema.Schema 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

Schema (javax.wsdl.extensions.schema.Schema)4 S2JJAXBModel (com.sun.tools.xjc.api.S2JJAXBModel)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 Definition (javax.wsdl.Definition)2 URI (java.net.URI)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Import (javax.wsdl.Import)1 Types (javax.wsdl.Types)1 ExtensibilityElement (javax.wsdl.extensions.ExtensibilityElement)1 UnknownExtensibilityElement (javax.wsdl.extensions.UnknownExtensibilityElement)1 WSDLFactory (javax.wsdl.factory.WSDLFactory)1 WSDLReader (javax.wsdl.xml.WSDLReader)1 QName (javax.xml.namespace.QName)1 XmlSchema (org.apache.ws.commons.schema.XmlSchema)1 XmlSchemaCollection (org.apache.ws.commons.schema.XmlSchemaCollection)1 XmlSchemaObjectTable (org.apache.ws.commons.schema.XmlSchemaObjectTable)1 XmlSchemaSimpleType (org.apache.ws.commons.schema.XmlSchemaSimpleType)1