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;
}
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;
}
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"));
}
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);
}
}
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;
}
Aggregations