Search in sources :

Example 6 with SchemaReference

use of javax.wsdl.extensions.schema.SchemaReference in project cxf by apache.

the class WSDLGetUtils method updateSchemaImports.

protected void updateSchemaImports(Bus bus, Schema schema, String docBase, Map<String, SchemaReference> doneSchemas, String base, String parentResolved) {
    Collection<List<?>> imports = CastUtils.cast((Collection<?>) schema.getImports().values());
    for (List<?> lst : imports) {
        List<SchemaImport> impLst = CastUtils.cast(lst);
        for (SchemaImport imp : impLst) {
            processSchemaReference(imp, bus, schema, docBase, doneSchemas, base, parentResolved);
        }
    }
    List<SchemaReference> includes = CastUtils.cast(schema.getIncludes());
    for (SchemaReference included : includes) {
        processSchemaReference(included, bus, schema, docBase, doneSchemas, base, parentResolved);
    }
    List<SchemaReference> redefines = CastUtils.cast(schema.getRedefines());
    for (SchemaReference included : redefines) {
        processSchemaReference(included, bus, schema, docBase, doneSchemas, base, parentResolved);
    }
}
Also used : SchemaReference(javax.wsdl.extensions.schema.SchemaReference) SchemaImport(javax.wsdl.extensions.schema.SchemaImport) List(java.util.List)

Example 7 with SchemaReference

use of javax.wsdl.extensions.schema.SchemaReference in project cxf by apache.

the class ServiceWSDLBuilder method buildTypes.

protected void buildTypes(final Collection<SchemaInfo> schemas, final Map<String, SchemaInfo> imports, final Definition def) {
    Types types = def.createTypes();
    for (SchemaInfo schemaInfo : schemas) {
        Schema schemaImpl = getSchemaImplementation(def);
        schemaImpl.setRequired(true);
        schemaImpl.setElementType(WSDLConstants.QNAME_SCHEMA);
        schemaImpl.setElement(schemaInfo.getElement());
        for (XmlSchemaExternal ext : schemaInfo.getSchema().getExternals()) {
            if (ext.getSchema() == null) {
                continue;
            }
            if (ext instanceof XmlSchemaImport) {
                SchemaImport imp = schemaImpl.createImport();
                imp.setNamespaceURI(((XmlSchemaImport) ext).getNamespace());
                imp.setSchemaLocationURI(((XmlSchemaImport) ext).getSchemaLocation());
                Schema schemaImpl2 = getSchemaImplementation(def);
                schemaImpl2.setRequired(true);
                schemaImpl2.setElementType(WSDLConstants.QNAME_SCHEMA);
                schemaImpl2.setDocumentBaseURI(ext.getSchema().getSourceURI());
                try {
                    schemaImpl2.setElement(ext.getSchema().getSchemaDocument().getDocumentElement());
                } catch (XmlSchemaSerializerException e) {
                // ignore
                }
                imp.setReferencedSchema(schemaImpl2);
                schemaImpl.addImport(imp);
            } else if (ext instanceof XmlSchemaInclude) {
                SchemaReference imp = schemaImpl.createInclude();
                imp.setSchemaLocationURI(((XmlSchemaInclude) ext).getSchemaLocation());
                Schema schemaImpl2 = getSchemaImplementation(def);
                schemaImpl2.setRequired(true);
                schemaImpl2.setElementType(WSDLConstants.QNAME_SCHEMA);
                schemaImpl2.setDocumentBaseURI(ext.getSchema().getSourceURI());
                try {
                    schemaImpl2.setElement(ext.getSchema().getSchemaDocument().getDocumentElement());
                } catch (XmlSchemaSerializerException e) {
                // ignore
                }
                imp.setReferencedSchema(schemaImpl2);
                schemaImpl.addInclude(imp);
            } else if (ext instanceof XmlSchemaRedefine) {
                SchemaReference imp = schemaImpl.createRedefine();
                imp.setSchemaLocationURI(((XmlSchemaRedefine) ext).getSchemaLocation());
                Schema schemaImpl2 = getSchemaImplementation(def);
                schemaImpl2.setRequired(true);
                schemaImpl2.setElementType(WSDLConstants.QNAME_SCHEMA);
                schemaImpl2.setDocumentBaseURI(ext.getSchema().getSourceURI());
                try {
                    schemaImpl2.setElement(ext.getSchema().getSchemaDocument().getDocumentElement());
                } catch (XmlSchemaSerializerException e) {
                // ignore
                }
                imp.setReferencedSchema(schemaImpl2);
                schemaImpl.addRedefine(imp);
            }
        }
        types.addExtensibilityElement(schemaImpl);
    }
    def.setTypes(types);
}
Also used : SchemaReference(javax.wsdl.extensions.schema.SchemaReference) Types(javax.wsdl.Types) XmlSchemaRedefine(org.apache.ws.commons.schema.XmlSchemaRedefine) XmlSchemaExternal(org.apache.ws.commons.schema.XmlSchemaExternal) XmlSchemaImport(org.apache.ws.commons.schema.XmlSchemaImport) SchemaImport(javax.wsdl.extensions.schema.SchemaImport) Schema(javax.wsdl.extensions.schema.Schema) XmlSchemaImport(org.apache.ws.commons.schema.XmlSchemaImport) XmlSchemaSerializerException(org.apache.ws.commons.schema.XmlSchemaSerializer.XmlSchemaSerializerException) XmlSchemaInclude(org.apache.ws.commons.schema.XmlSchemaInclude) SchemaInfo(org.apache.cxf.service.model.SchemaInfo)

Aggregations

SchemaReference (javax.wsdl.extensions.schema.SchemaReference)7 URISyntaxException (java.net.URISyntaxException)3 Document (org.w3c.dom.Document)3 URI (java.net.URI)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 Schema (javax.wsdl.extensions.schema.Schema)2 SchemaImport (javax.wsdl.extensions.schema.SchemaImport)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 MalformedURLException (java.net.MalformedURLException)1 List (java.util.List)1 Definition (javax.wsdl.Definition)1 Types (javax.wsdl.Types)1 WSDLException (javax.wsdl.WSDLException)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 DOMSource (javax.xml.transform.dom.DOMSource)1 Bus (org.apache.cxf.Bus)1 Message (org.apache.cxf.message.Message)1 SchemaInfo (org.apache.cxf.service.model.SchemaInfo)1