Search in sources :

Example 11 with Import

use of javax.wsdl.Import in project cxf by apache.

the class CorbaObjectReferenceHelper method populateEprInfo.

public static void populateEprInfo(EprMetaData info) {
    if (!info.isValid()) {
        return;
    }
    Binding match = info.getBinding();
    Definition wsdlDef = info.getCandidateWsdlDef();
    Collection<Service> services = CastUtils.cast(wsdlDef.getServices().values());
    for (Service serv : services) {
        Collection<Port> ports = CastUtils.cast(serv.getPorts().values());
        for (Port pt : ports) {
            if (pt.getBinding().equals(match)) {
                info.setPortName(pt.getName());
                info.setServiceQName(serv.getQName());
                break;
            }
        }
    }
    if (info.getServiceQName() == null) {
        Iterator<?> importLists = wsdlDef.getImports().values().iterator();
        while (info.getServiceQName() == null && importLists.hasNext()) {
            List<?> imports = (List<?>) importLists.next();
            for (java.lang.Object imp : imports) {
                if (imp instanceof Import) {
                    Definition importDef = ((Import) imp).getDefinition();
                    LOG.log(Level.FINE, "following wsdl import " + importDef.getDocumentBaseURI());
                    info.setCandidateWsdlDef(importDef);
                    populateEprInfo(info);
                    if (info.getServiceQName() != null) {
                        break;
                    }
                }
            }
        }
    }
}
Also used : Binding(javax.wsdl.Binding) Import(javax.wsdl.Import) Port(javax.wsdl.Port) Definition(javax.wsdl.Definition) Service(javax.wsdl.Service) List(java.util.List)

Example 12 with Import

use of javax.wsdl.Import in project cxf by apache.

the class CorbaObjectReferenceHelper method getBindingForTypeId.

public static EprMetaData getBindingForTypeId(String repId, Definition wsdlDef) {
    LOG.log(Level.FINE, "RepositoryId " + repId + ", wsdl namespace " + wsdlDef.getTargetNamespace());
    EprMetaData ret = new EprMetaData();
    Collection<Binding> bindings = CastUtils.cast(wsdlDef.getBindings().values());
    for (Binding b : bindings) {
        List<?> extElements = b.getExtensibilityElements();
        // Get the list of all extensibility elements
        for (Iterator<?> extIter = extElements.iterator(); extIter.hasNext(); ) {
            java.lang.Object element = extIter.next();
            // Find a binding type so we can check against its repository ID
            if (element instanceof BindingType) {
                BindingType type = (BindingType) element;
                if (repId.equals(type.getRepositoryID())) {
                    ret.setCandidateWsdlDef(wsdlDef);
                    ret.setBinding(b);
                    return ret;
                }
            }
        }
    }
    if (!ret.isValid()) {
        // recursivly check imports
        Iterator<?> importLists = wsdlDef.getImports().values().iterator();
        while (importLists.hasNext()) {
            List<?> imports = (List<?>) importLists.next();
            for (java.lang.Object imp : imports) {
                if (imp instanceof Import) {
                    Definition importDef = ((Import) imp).getDefinition();
                    LOG.log(Level.INFO, "Following import " + importDef.getDocumentBaseURI());
                    ret = getBindingForTypeId(repId, importDef);
                    if (ret.isValid()) {
                        return ret;
                    }
                }
            }
        }
    }
    return ret;
}
Also used : Binding(javax.wsdl.Binding) Import(javax.wsdl.Import) BindingType(org.apache.cxf.binding.corba.wsdl.BindingType) Definition(javax.wsdl.Definition) List(java.util.List)

Example 13 with Import

use of javax.wsdl.Import in project cxf by apache.

the class WSDLRefValidator method parseImports.

private void parseImports(Definition def) {
    for (Import impt : getImports(def)) {
        if (!importedDefinitions.contains(impt.getDefinition())) {
            importedDefinitions.add(impt.getDefinition());
            parseImports(impt.getDefinition());
        }
    }
}
Also used : Import(javax.wsdl.Import)

Example 14 with Import

use of javax.wsdl.Import in project cxf by apache.

the class WSDLASTVisitor method getLogicalDefinition.

// Gets the logical definition for a file - an import will be added for the
// schema types if -T is used and a separate schema file generated.
// if -n is used an import will be added for the schema types and no types generated.
private Definition getLogicalDefinition(String schemaFilename, Writer schemaWriter) throws WSDLException, JAXBException, Exception {
    Definition def = manager.createWSDLDefinition(targetNamespace);
    // checks for -T option.
    if (schemaFilename != null) {
        writeSchemaDefinition(definition, schemaWriter);
        manager.addWSDLSchemaImport(def, schema.getTargetNamespace(), schemaFilename);
    } else {
        // checks for -n option
        if (importSchemaFilename == null) {
            Types types = definition.getTypes();
            def.setTypes(types);
        } else {
            manager.addWSDLSchemaImport(def, schema.getTargetNamespace(), importSchemaFilename);
        }
    }
    Collection<PortType> portTypes = CastUtils.cast(definition.getAllPortTypes().values());
    for (PortType port : portTypes) {
        def.addPortType(port);
    }
    Collection<Message> messages = CastUtils.cast(definition.getMessages().values());
    for (Message msg : messages) {
        def.addMessage(msg);
    }
    Collection<String> namespaces = CastUtils.cast(definition.getNamespaces().values());
    for (String namespace : namespaces) {
        String prefix = definition.getPrefix(namespace);
        if (!"corba".equals(prefix)) {
            def.addNamespace(prefix, namespace);
        } else {
            def.removeNamespace(prefix);
        }
    }
    Collection<Import> imports = CastUtils.cast(definition.getImports().values());
    for (Import importType : imports) {
        def.addImport(importType);
    }
    def.setDocumentationElement(definition.getDocumentationElement());
    def.setDocumentBaseURI(definition.getDocumentBaseURI());
    return def;
}
Also used : Types(javax.wsdl.Types) Import(javax.wsdl.Import) Message(javax.wsdl.Message) Definition(javax.wsdl.Definition) PortType(javax.wsdl.PortType)

Example 15 with Import

use of javax.wsdl.Import in project cxf by apache.

the class WSDLSchemaManager method addWSDLDefinitionImport.

public void addWSDLDefinitionImport(Definition rootDefn, Definition defn, String prefix, File file) {
    if (rootDefn.getImports().get(defn.getTargetNamespace()) == null && !".wsdl".equals(file.getName())) {
        // Only import if not already done to prevent multiple imports of the same file
        // in the WSDL. Also watch out for empty fileNames, which by this point in the
        // code would show up as ".wsdl".
        Import importDefn = rootDefn.createImport();
        if (!ignoreImports) {
            importDefn.setLocationURI(file.toURI().toString());
        }
        importDefn.setNamespaceURI(defn.getTargetNamespace());
        rootDefn.addImport(importDefn);
    }
    if (!rootDefn.getNamespaces().values().contains(defn.getTargetNamespace())) {
        rootDefn.addNamespace(prefix, defn.getTargetNamespace());
    }
    if (!importedDefns.containsKey(file)) {
        importedDefns.put(file, defn);
    }
}
Also used : XmlSchemaImport(org.apache.ws.commons.schema.XmlSchemaImport) SchemaImport(javax.wsdl.extensions.schema.SchemaImport) Import(javax.wsdl.Import)

Aggregations

Import (javax.wsdl.Import)18 List (java.util.List)9 Definition (javax.wsdl.Definition)8 ArrayList (java.util.ArrayList)6 SchemaImport (javax.wsdl.extensions.schema.SchemaImport)5 Binding (javax.wsdl.Binding)4 PortType (javax.wsdl.PortType)4 Collection (java.util.Collection)3 Map (java.util.Map)3 Message (javax.wsdl.Message)3 Port (javax.wsdl.Port)3 Types (javax.wsdl.Types)3 HashSet (java.util.HashSet)2 Iterator (java.util.Iterator)2 Service (javax.wsdl.Service)2 WSDLException (javax.wsdl.WSDLException)2 ExtensibilityElement (javax.wsdl.extensions.ExtensibilityElement)2 Schema (javax.wsdl.extensions.schema.Schema)2 SOAPBinding (javax.wsdl.extensions.soap.SOAPBinding)2 WSDLWriter (javax.wsdl.xml.WSDLWriter)2