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