Search in sources :

Example 6 with Import

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

the class ServiceWSDLBuilder method build.

/**
 * Create the WSDL Definition object and return it. This function respects the
 * setting of {@link #setUseSchemaImports(boolean)}.
 * @param imports A set of schema imports to either reference as imports or read and
 * then inline.
 * @return the WSDL definition
 * @throws WSDLException
 */
public Definition build(Map<String, SchemaInfo> imports) throws WSDLException {
    Definition definition = null;
    try {
        definition = services.get(0).getProperty(WSDLServiceBuilder.WSDL_DEFINITION, Definition.class);
    } catch (ClassCastException e) {
    // ignore
    }
    if (definition == null) {
        ServiceInfo si = services.get(0);
        definition = newDefinition(si.getName(), si.getTargetNamespace());
        addNamespace(WSDLConstants.CONVENTIONAL_TNS_PREFIX, si.getTargetNamespace(), definition);
        addExtensibilityElements(definition, definition, getWSDL11Extensors(si.getDescription()));
        Collection<PortType> portTypes = new HashSet<>();
        for (ServiceInfo service : services) {
            Definition portTypeDef = definition;
            Definition orig = definition;
            if (!isSameTNS(service)) {
                portTypeDef = newDefinition(service.getInterface().getName(), service.getInterface().getName().getNamespaceURI());
                Import wsdlImport = definition.createImport();
                String tns = service.getInterface().getName().getNamespaceURI();
                wsdlImport.setDefinition(portTypeDef);
                wsdlImport.setNamespaceURI(tns);
                wsdlImport.setLocationURI(service.getInterface().getName().getLocalPart() + ".wsdl");
                definition.addImport(wsdlImport);
                addNamespace(getPrefix(tns), tns, definition);
            }
            portTypes.add(buildPortType(service.getInterface(), portTypeDef));
            if (service.getSchemas() != null && service.getSchemas().size() > 0) {
                if (!useSchemaImports) {
                    buildTypes(service.getSchemas(), imports, portTypeDef);
                } else {
                    buildTypesWithSchemaImports(service.getSchemas(), imports, portTypeDef);
                }
            }
            definition = orig;
        }
        for (ServiceInfo service : services) {
            buildBinding(definition, service.getBindings(), portTypes);
            buildService(service, definition);
        }
    }
    return definition;
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) XmlSchemaImport(org.apache.ws.commons.schema.XmlSchemaImport) SchemaImport(javax.wsdl.extensions.schema.SchemaImport) Import(javax.wsdl.Import) Definition(javax.wsdl.Definition) PortType(javax.wsdl.PortType) HashSet(java.util.HashSet)

Example 7 with Import

use of javax.wsdl.Import in project components by Talend.

the class JAXBConfigGen method processSchemas.

private void processSchemas(Definition def, Collection<String> namespaceList) throws Exception {
    if (def.getTypes() != null && def.getTypes().getExtensibilityElements() != null) {
        for (Iterator iter = def.getTypes().getExtensibilityElements().iterator(); iter.hasNext(); ) {
            ExtensibilityElement element = (ExtensibilityElement) iter.next();
            if (element instanceof javax.wsdl.extensions.schema.Schema) {
                javax.wsdl.extensions.schema.Schema schema = (javax.wsdl.extensions.schema.Schema) element;
                processSchema(schema, namespaceList);
            }
        }
    }
    if (def.getImports() != null) {
        for (Iterator itImp = def.getImports().values().iterator(); itImp.hasNext(); ) {
            Collection imps = (Collection) itImp.next();
            for (Iterator iter = imps.iterator(); iter.hasNext(); ) {
                Import imp = (Import) iter.next();
                processSchemas(imp.getDefinition(), namespaceList);
            }
        }
    }
}
Also used : SchemaImport(javax.wsdl.extensions.schema.SchemaImport) Import(javax.wsdl.Import) Iterator(java.util.Iterator) Collection(java.util.Collection) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement)

Example 8 with Import

use of javax.wsdl.Import in project tesb-studio-se by Talend.

the class CompressAndEncodeTool method appendImportDifinitions.

@SuppressWarnings("unchecked")
private static void appendImportDifinitions(Definition definition, ZipOutputStream zipOs) throws IOException, WSDLException {
    for (Collection<Import> vector : (Collection<Collection<Import>>) definition.getImports().values()) {
        for (Import impt : vector) {
            zipOs.putNextEntry(new ZipEntry(impt.getLocationURI()));
            WSDLFactory.newInstance().newWSDLWriter().writeWSDL(impt.getDefinition(), zipOs);
            appendImportDifinitions(impt.getDefinition(), zipOs);
        }
    }
}
Also used : Import(javax.wsdl.Import) ZipEntry(java.util.zip.ZipEntry) Collection(java.util.Collection)

Example 9 with Import

use of javax.wsdl.Import 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)

Example 10 with Import

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

the class WsdlVisitor method walkTree.

public void walkTree() {
    begin();
    try {
        visit(definition);
        for (Iterator iterator = definition.getImports().entrySet().iterator(); iterator.hasNext(); ) {
            Map.Entry entry = (Map.Entry) iterator.next();
            String namespaceURI = (String) entry.getKey();
            List importsForNamespace = (List) entry.getValue();
            for (Iterator iterator1 = importsForNamespace.iterator(); iterator1.hasNext(); ) {
                Import anImport = (Import) iterator1.next();
                visit(anImport);
            }
        }
        visit(definition.getTypes());
        Collection messages = definition.getMessages().values();
        for (Iterator iterator = messages.iterator(); iterator.hasNext(); ) {
            Message message = (Message) iterator.next();
            visit(message);
            Collection parts = message.getParts().values();
            for (Iterator iterator2 = parts.iterator(); iterator2.hasNext(); ) {
                Part part = (Part) iterator2.next();
                visit(part);
            }
        }
        Collection services = definition.getServices().values();
        for (Iterator iterator = services.iterator(); iterator.hasNext(); ) {
            Service service = (Service) iterator.next();
            visit(service);
            Collection ports = service.getPorts().values();
            for (Iterator iterator1 = ports.iterator(); iterator1.hasNext(); ) {
                Port port = (Port) iterator1.next();
                visit(port);
                Binding binding = port.getBinding();
                visit(binding);
                List bindingOperations = binding.getBindingOperations();
                for (int i = 0; i < bindingOperations.size(); i++) {
                    BindingOperation bindingOperation = (BindingOperation) bindingOperations.get(i);
                    visit(bindingOperation);
                    visit(bindingOperation.getBindingInput());
                    visit(bindingOperation.getBindingOutput());
                    Collection bindingFaults = bindingOperation.getBindingFaults().values();
                    for (Iterator iterator2 = bindingFaults.iterator(); iterator2.hasNext(); ) {
                        BindingFault bindingFault = (BindingFault) iterator2.next();
                        visit(bindingFault);
                    }
                }
                PortType portType = binding.getPortType();
                visit(portType);
                List operations = portType.getOperations();
                for (int i = 0; i < operations.size(); i++) {
                    Operation operation = (Operation) operations.get(i);
                    visit(operation);
                    {
                        Input input = operation.getInput();
                        visit(input);
                    }
                    {
                        Output output = operation.getOutput();
                        visit(output);
                    }
                    Collection faults = operation.getFaults().values();
                    for (Iterator iterator2 = faults.iterator(); iterator2.hasNext(); ) {
                        Fault fault = (Fault) iterator2.next();
                        visit(fault);
                    }
                }
            }
        }
    } catch (Exception e) {
        LOGGER.error(e.getMessage(), e);
    } finally {
        end();
    }
}
Also used : SOAPBinding(javax.wsdl.extensions.soap.SOAPBinding) Binding(javax.wsdl.Binding) Import(javax.wsdl.Import) Message(javax.wsdl.Message) BindingFault(javax.wsdl.BindingFault) Port(javax.wsdl.Port) Service(javax.wsdl.Service) BindingFault(javax.wsdl.BindingFault) Fault(javax.wsdl.Fault) Operation(javax.wsdl.Operation) BindingOperation(javax.wsdl.BindingOperation) BindingOperation(javax.wsdl.BindingOperation) BindingInput(javax.wsdl.BindingInput) Input(javax.wsdl.Input) Part(javax.wsdl.Part) BindingOutput(javax.wsdl.BindingOutput) Output(javax.wsdl.Output) Iterator(java.util.Iterator) Collection(java.util.Collection) List(java.util.List) Map(java.util.Map) PortType(javax.wsdl.PortType)

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