Search in sources :

Example 1 with Definition

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

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

the class ServiceDiscoveryHelper method findWsdlImport.

private List<Definition> findWsdlImport(Definition definition, List<Definition> definitions, List<String> locationURIs, List<String> importNSs) {
    if (definitions == null) {
        definitions = new ArrayList<Definition>();
        definitions.add(definition);
    }
    if (locationURIs == null) {
        locationURIs = new ArrayList<String>();
    }
    if (importNSs == null) {
        importNSs = new ArrayList<String>();
    }
    if (definition.getImports() != null && !definition.getImports().isEmpty()) {
        Map imports = definition.getImports();
        for (Object key : imports.keySet()) {
            Vector importsImpl = (Vector) imports.get(key);
            for (int i = 0; i < importsImpl.size(); i++) {
                ImportImpl importImpl = (ImportImpl) importsImpl.get(i);
                if (!locationURIs.contains(importImpl.getLocationURI()) || !importNSs.contains(importImpl.getNamespaceURI())) {
                    locationURIs.add(importImpl.getLocationURI());
                    importNSs.add(importImpl.getNamespaceURI());
                    String importWsdlFileName = "importWsdl" + definitions.size() + ".wsdl";
                    importImpl.setLocationURI(importWsdlFileName);
                    Definition importDef = importImpl.getDefinition();
                    if (importDef != null) {
                        definitions.add(importDef);
                        findWsdlImport(importDef, definitions, locationURIs, importNSs);
                    }
                }
            }
        }
    }
    return definitions;
}
Also used : Definition(javax.wsdl.Definition) ImportImpl(com.ibm.wsdl.ImportImpl) Map(java.util.Map) Vector(java.util.Vector)

Example 3 with Definition

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

the class ServiceExportForESBRuntimeManager method createBlueprint.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.repository.services.ui.scriptmanager.ServiceExportManager#createBlueprint(java.io.File,
     * java.util.Map, java.util.Map, org.eclipse.core.resources.IFile, java.lang.String)
     */
@Override
public void createBlueprint(File outputFile, Map<ServicePort, Map<String, String>> ports, Map<String, String> additionalInfo, IFile wsdl, String studioServiceName) throws IOException, CoreException {
    // TODO: support multiport!!!
    Entry<ServicePort, Map<String, String>> studioPort = ports.entrySet().iterator().next();
    // TODO: do this in looooooooop!!!
    Definition def = WSDLUtils.getDefinition(wsdl);
    QName serviceQName = null;
    String endpointAddress = null;
    String endpointName = null;
    Map<QName, Service> services = def.getServices();
    ServicePort servicePort = studioPort.getKey();
    for (Entry<QName, Service> serviceEntry : services.entrySet()) {
        // TODO: support multi-services
        Service service = serviceEntry.getValue();
        // TODO: support multi-ports
        Collection<Port> servicePorts = service.getPorts().values();
        for (Port port : servicePorts) {
            if (servicePort.getName().equals(port.getBinding().getPortType().getQName().getLocalPart())) {
                serviceQName = serviceEntry.getKey();
                endpointName = port.getName();
                endpointAddress = WSDLUtils.getPortAddress(port);
                if (null != endpointAddress) {
                    // http://jira.talendforge.org/browse/TESB-3638
                    final URI uri = URI.create(endpointAddress);
                    endpointAddress = uri.getPath();
                    if (endpointAddress == null) {
                        endpointAddress = uri.getRawSchemeSpecificPart();
                        int interrogationMark = endpointAddress.indexOf('?');
                        if (interrogationMark > 0) {
                            endpointAddress = endpointAddress.substring(0, interrogationMark);
                        }
                    }
                    if (endpointAddress.equals("/services/") || endpointAddress.equals("/services")) {
                        // pass as is
                        endpointAddress = endpointAddress;
                    } else if (endpointAddress.startsWith("/services/")) {
                        // remove forwarding "/services/" context as required by runtime
                        // leave
                        endpointAddress = endpointAddress.substring("/services/".length() - 1);
                    // forwarding
                    // slash
                    } else if (endpointAddress.length() == 1) {
                        // empty path
                        endpointAddress += studioServiceName;
                    }
                }
                break;
            }
        }
    }
    Map<String, Object> endpointInfo = new HashMap<String, Object>();
    //$NON-NLS-1$
    endpointInfo.put("namespace", serviceQName.getNamespaceURI());
    //$NON-NLS-1$
    endpointInfo.put("service", serviceQName.getLocalPart());
    //$NON-NLS-1$
    endpointInfo.put("port", endpointName);
    //$NON-NLS-1$
    endpointInfo.put("address", endpointAddress);
    //$NON-NLS-1$
    endpointInfo.put("studioName", studioServiceName);
    //$NON-NLS-1$
    endpointInfo.put("wsdlLocation", wsdl.getName());
    Map<String, String> operation2job = new HashMap<String, String>();
    for (Map.Entry<ServicePort, Map<String, String>> port : ports.entrySet()) {
        // TODO: actual port work
        for (Map.Entry<String, String> operation : port.getValue().entrySet()) {
            operation2job.put(operation.getKey(), operation.getValue());
        }
    }
    //$NON-NLS-1$
    endpointInfo.put("operation2job", operation2job);
    boolean isStudioEEVersion = isStudioEEVersion();
    boolean useRegistry = isStudioEEVersion && Boolean.valueOf(additionalInfo.get(ServiceMetadataDialog.USE_SERVICE_REGISTRY));
    boolean useSL = Boolean.valueOf(additionalInfo.get(ServiceMetadataDialog.USE_SL));
    boolean useSAM = !useRegistry && Boolean.valueOf(additionalInfo.get(ServiceMetadataDialog.USE_SAM));
    boolean useSecurityToken = !useRegistry && Boolean.valueOf(additionalInfo.get(ServiceMetadataDialog.SECURITY_BASIC));
    boolean useSecuritySAML = !useRegistry && Boolean.valueOf(additionalInfo.get(ServiceMetadataDialog.SECURITY_SAML));
    boolean useAuthorization = !useRegistry && isStudioEEVersion && useSecuritySAML && Boolean.valueOf(additionalInfo.get(ServiceMetadataDialog.AUTHORIZATION));
    boolean useEncryption = !useRegistry && isStudioEEVersion && useSecuritySAML && Boolean.valueOf(additionalInfo.get(ServiceMetadataDialog.ENCRYPTION));
    boolean logMessages = Boolean.valueOf(additionalInfo.get(ServiceMetadataDialog.LOG_MESSAGES));
    boolean wsdlSchemaValidation = isStudioEEVersion && Boolean.valueOf(additionalInfo.get(ServiceMetadataDialog.WSDL_SCHEMA_VALIDATION));
    boolean useBusinessCorrelation = !useRegistry && Boolean.valueOf(additionalInfo.get(ServiceMetadataDialog.USE_BUSINESS_CORRELATION));
    //$NON-NLS-1$
    endpointInfo.put("useSL", useSL);
    //$NON-NLS-1$
    endpointInfo.put("useSAM", useSAM);
    //$NON-NLS-1$
    endpointInfo.put("useSecurityToken", useSecurityToken);
    //$NON-NLS-1$
    endpointInfo.put("useSecuritySAML", useSecuritySAML);
    //$NON-NLS-1$
    endpointInfo.put("useAuthorization", useAuthorization);
    //$NON-NLS-1$
    endpointInfo.put("useEncryption", useEncryption);
    //$NON-NLS-1$
    endpointInfo.put("useServiceRegistry", useRegistry);
    //$NON-NLS-1$
    endpointInfo.put("logMessages", logMessages);
    //$NON-NLS-1$
    endpointInfo.put("useWsdlSchemaValidation", wsdlSchemaValidation);
    //$NON-NLS-1$
    endpointInfo.put("useBusinessCorrelation", useBusinessCorrelation);
    Map<String, String> slCustomProperties = new HashMap<String, String>();
    if (useSL) /* && !useRegistry */
    {
        for (Map.Entry<String, String> prop : additionalInfo.entrySet()) {
            if (prop.getKey().startsWith(ServiceMetadataDialog.SL_CUSTOM_PROP_PREFIX)) {
                slCustomProperties.put(prop.getKey().substring(ServiceMetadataDialog.SL_CUSTOM_PROP_PREFIX.length()), prop.getValue());
            }
        }
    }
    //$NON-NLS-1$
    endpointInfo.put("slCustomProps", slCustomProperties);
    //$NON-NLS-1$
    endpointInfo.put(//$NON-NLS-1$
    "samlConfig", //$NON-NLS-1$
    serviceQName.toString().replaceAll("\\W+", "_").substring(1));
    //$NON-NLS-1$
    TemplateProcessor.processTemplate(//$NON-NLS-1$
    "DATA_SERVICE_BLUEPRINT_CONFIG", endpointInfo, outputFile, ServiceExportManager.class.getResourceAsStream("/resources/blueprint-template.xml"));
}
Also used : ServicePort(org.talend.repository.services.model.services.ServicePort) HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) ServiceExportManager(org.talend.repository.services.ui.scriptmanager.ServiceExportManager) ServicePort(org.talend.repository.services.model.services.ServicePort) Port(javax.wsdl.Port) Definition(javax.wsdl.Definition) Service(javax.wsdl.Service) URI(java.net.URI) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) HashMap(java.util.HashMap) Map(java.util.Map)

Example 4 with Definition

use of javax.wsdl.Definition in project Activiti by Activiti.

the class CxfWSDLImporter method importFrom.

public void importFrom(String url) {
    this.wsServices.clear();
    this.wsOperations.clear();
    this.structures.clear();
    this.wsdlLocation = url;
    try {
        Bus bus = BusFactory.getDefaultBus();
        final Enumeration<URL> xjcBindingUrls = Thread.currentThread().getContextClassLoader().getResources(JAXB_BINDINGS_RESOURCE);
        if (xjcBindingUrls.hasMoreElements()) {
            final URL xjcBindingUrl = xjcBindingUrls.nextElement();
            if (xjcBindingUrls.hasMoreElements()) {
                throw new ActivitiException("Several JAXB binding definitions found for activiti-cxf: " + JAXB_BINDINGS_RESOURCE);
            }
            DynamicClientFactory.newInstance(bus).createClient(url, Arrays.asList(new String[] { xjcBindingUrl.toString() }));
            WSDLManager wsdlManager = bus.getExtension(WSDLManager.class);
            Definition def = wsdlManager.getDefinition(url);
            WSDLServiceBuilder builder = new WSDLServiceBuilder(bus);
            List<ServiceInfo> services = builder.buildServices(def);
            for (ServiceInfo service : services) {
                WSService wsService = this.importService(service);
                this.wsServices.put(this.namespace + wsService.getName(), wsService);
            }
            if (def != null && def.getTypes() != null) {
                this.importTypes(def.getTypes());
            }
        } else {
            throw new ActivitiException("The JAXB binding definitions are not found for activiti-cxf: " + JAXB_BINDINGS_RESOURCE);
        }
    } catch (WSDLException e) {
        e.printStackTrace();
    } catch (IOException e) {
        throw new ActivitiException("Error retrieveing the JAXB binding definitions", e);
    }
}
Also used : Bus(org.apache.cxf.Bus) ActivitiException(org.activiti.engine.ActivitiException) WSDLException(javax.wsdl.WSDLException) StructureDefinition(org.activiti.engine.impl.bpmn.data.StructureDefinition) SimpleStructureDefinition(org.activiti.engine.impl.bpmn.data.SimpleStructureDefinition) Definition(javax.wsdl.Definition) PrimitiveStructureDefinition(org.activiti.engine.impl.bpmn.data.PrimitiveStructureDefinition) IOException(java.io.IOException) URL(java.net.URL) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) WSDLServiceBuilder(org.apache.cxf.wsdl11.WSDLServiceBuilder) WSDLManager(org.apache.cxf.wsdl.WSDLManager)

Example 5 with Definition

use of javax.wsdl.Definition in project Activiti by Activiti.

the class WSDLImporter method parseWSDLDefinition.

/**
   * Parse the WSDL definition using WSDL4J.
   */
private Definition parseWSDLDefinition() throws WSDLException {
    WSDLFactory wsdlFactory = WSDLFactory.newInstance();
    WSDLReader reader = wsdlFactory.newWSDLReader();
    reader.setFeature("javax.wsdl.verbose", false);
    reader.setFeature("javax.wsdl.importDocuments", true);
    Definition definition = reader.readWSDL(this.wsdlLocation);
    return definition;
}
Also used : WSDLFactory(javax.wsdl.factory.WSDLFactory) StructureDefinition(org.activiti.engine.impl.bpmn.data.StructureDefinition) SimpleStructureDefinition(org.activiti.engine.impl.bpmn.data.SimpleStructureDefinition) Definition(javax.wsdl.Definition) WSDLReader(javax.wsdl.xml.WSDLReader)

Aggregations

Definition (javax.wsdl.Definition)226 Test (org.junit.Test)113 QName (javax.xml.namespace.QName)61 File (java.io.File)52 Document (org.w3c.dom.Document)44 Element (org.w3c.dom.Element)40 HashMap (java.util.HashMap)36 WSDLReader (javax.wsdl.xml.WSDLReader)35 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)31 JBossWSTest (org.jboss.wsf.test.JBossWSTest)31 Service (javax.wsdl.Service)24 ExtensibilityElement (javax.wsdl.extensions.ExtensibilityElement)23 URL (java.net.URL)21 ArrayList (java.util.ArrayList)21 Port (javax.wsdl.Port)21 WSDLToIDLAction (org.apache.cxf.tools.corba.processors.wsdl.WSDLToIDLAction)21 Bus (org.apache.cxf.Bus)20 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)20 WSDLManager (org.apache.cxf.wsdl.WSDLManager)20 IOException (java.io.IOException)18