use of javax.wsdl.Types in project Lucee by lucee.
the class JaxWSClient method toDumpData.
private DumpData toDumpData(BindingOperation bo) {
Map<QName, Message> messages = wsdl.getMessages();
DumpTable table = new DumpTable("#99cc99", "#ccffcc", "#000000");
DumpTable attributes = new DumpTable("#99cc99", "#ccffcc", "#000000");
String returns = "void";
attributes.appendRow(3, new SimpleDumpData("name"), new SimpleDumpData("type"));
Operation op = bo.getOperation();
// attributes
Input in = op.getInput();
Message msg = in.getMessage();
// msg=WSUtil.getMessageByLocalName(messages,bo.getBindingInput().getName());
// print.e(msg.getQName());
List<Part> parts = msg.getOrderedParts(null);
Iterator<Part> it = parts.iterator();
Part p;
QName en;
QName type;
while (it.hasNext()) {
p = it.next();
en = p.getElementName();
if (en != null) {
type = en;
Types types = wsdl.getTypes();
} else
type = p.getTypeName();
attributes.appendRow(0, new SimpleDumpData(en + ":" + p.getName()), new SimpleDumpData(toLuceeType(type)));
}
// return
msg = bo.getOperation().getOutput().getMessage();
msg = wsdl.getMessage(msg.getQName());
parts = msg.getOrderedParts(null);
it = parts.iterator();
while (it.hasNext()) {
p = it.next();
returns = toLuceeType(p.getTypeName());
}
table.appendRow(1, new SimpleDumpData("arguments"), attributes);
table.appendRow(1, new SimpleDumpData("return type"), new SimpleDumpData(returns));
return table;
}
use of javax.wsdl.Types in project carbon-apimgt by wso2.
the class WSDL11SOAPOperationExtractor method initModels.
/**
* Initiallize SOAP to REST Operations
*
* @return true if extracting operations was successful
*/
private boolean initModels() throws APIMgtWSDLException {
wsdlDefinition = getWSDLDefinition();
boolean canProcess = true;
targetNamespace = wsdlDefinition.getTargetNamespace();
Types types = wsdlDefinition.getTypes();
if (types != null) {
typeList = types.getExtensibilityElements();
}
if (typeList != null) {
for (Object ext : typeList) {
if (ext instanceof Schema) {
Schema schema = (Schema) ext;
Map importedSchemas = schema.getImports();
Element schemaElement = schema.getElement();
NodeList schemaNodes = schemaElement.getChildNodes();
schemaNodeList.addAll(SOAPOperationBindingUtils.list(schemaNodes));
// gets types from imported schemas from the parent wsdl. Nested schemas will not be imported.
if (importedSchemas != null) {
for (Object importedSchemaObj : importedSchemas.keySet()) {
String schemaUrl = (String) importedSchemaObj;
if (importedSchemas.get(schemaUrl) != null) {
Vector vector = (Vector) importedSchemas.get(schemaUrl);
for (Object schemaVector : vector) {
if (schemaVector instanceof SchemaImport) {
Schema referencedSchema = ((SchemaImport) schemaVector).getReferencedSchema();
if (referencedSchema != null && referencedSchema.getElement() != null) {
if (referencedSchema.getElement().hasChildNodes()) {
schemaNodeList.addAll(SOAPOperationBindingUtils.list(referencedSchema.getElement().getChildNodes()));
} else {
log.warn("The referenced schema : " + schemaUrl + " doesn't have any defined types");
}
} else {
boolean isInlineSchema = false;
for (Object aSchema : typeList) {
if (schemaUrl.equalsIgnoreCase(((Schema) aSchema).getElement().getAttribute(TARGET_NAMESPACE_ATTRIBUTE))) {
isInlineSchema = true;
break;
}
}
if (isInlineSchema) {
log.debug(schemaUrl + " is already defined inline. Hence continue.");
} else {
log.warn("Cannot access referenced schema for the schema defined at: " + schemaUrl);
}
}
}
}
}
}
} else {
log.info("No any imported schemas found in the given wsdl.");
}
List schemaIncludes = schema.getIncludes();
for (Iterator iter = schemaIncludes.iterator(); iter.hasNext(); ) {
SchemaReference schemaInclude = (SchemaReference) iter.next();
Schema schemaImp = schemaInclude.getReferencedSchema();
String schemaLoc = schemaInclude.getSchemaLocationURI();
if (schemaImp != null && schemaImp.getElement() != null) {
if (schemaImp.getElement().hasChildNodes()) {
schemaNodeList.addAll(SOAPOperationBindingUtils.list(schemaImp.getElement().getChildNodes()));
} else {
log.warn("The referenced schema : " + schemaLoc + " doesn't have any defined types");
}
}
}
if (log.isDebugEnabled()) {
Gson gson = new GsonBuilder().setExclusionStrategies(new SwaggerFieldsExcludeStrategy()).create();
log.debug("swagger definition model map from the wsdl: " + gson.toJson(parameterModelMap));
}
if (schemaNodeList == null) {
log.warn("No schemas found in the type element for target namespace:" + schema.getDocumentBaseURI());
}
}
}
if (schemaNodeList != null) {
for (Node node : schemaNodeList) {
WSDLParamDefinition wsdlParamDefinition = new WSDLParamDefinition();
ModelImpl model = new ModelImpl();
Property currentProperty = null;
try {
traverseTypeElement(node, null, model, currentProperty);
} catch (APIManagementException e) {
throw new APIMgtWSDLException(e);
}
if (StringUtils.isNotBlank(model.getName())) {
parameterModelMap.put(model.getName(), model);
}
if (wsdlParamDefinition.getDefinitionName() != null) {
wsdlParamDefinitions.add(wsdlParamDefinition);
}
}
} else {
log.info("No schema is defined in the wsdl document");
}
}
if (log.isDebugEnabled()) {
log.debug("Successfully initialized an instance of " + this.getClass().getSimpleName() + " with a single WSDL.");
}
return canProcess;
}
use of javax.wsdl.Types in project cxf by apache.
the class WSDLGetUtils method updateDefinition.
protected void updateDefinition(Bus bus, Definition def, Map<String, Definition> done, Map<String, SchemaReference> doneSchemas, String base, String docBase, String parentResolvedLocation) {
OASISCatalogManager catalogs = OASISCatalogManager.getCatalogManager(bus);
Collection<List<?>> imports = CastUtils.cast((Collection<?>) def.getImports().values());
for (List<?> lst : imports) {
List<Import> impLst = CastUtils.cast(lst);
for (Import imp : impLst) {
String start = imp.getLocationURI();
String decodedStart;
try {
decodedStart = URLDecoder.decode(start, "utf-8");
} catch (UnsupportedEncodingException e) {
throw new WSDLQueryException(new org.apache.cxf.common.i18n.Message("COULD_NOT_PROVIDE_WSDL", LOG, start), e);
}
String resolvedSchemaLocation = resolveWithCatalogs(catalogs, start, base);
if (resolvedSchemaLocation == null) {
try {
// check to see if it's already in a URL format. If so, leave it.
new URL(start);
} catch (MalformedURLException e) {
try {
start = getLocationURI(start, docBase);
decodedStart = URLDecoder.decode(start, "utf-8");
} catch (Exception e1) {
// ignore
}
if (done.put(decodedStart, imp.getDefinition()) == null) {
if (imp.getDefinition() != null && imp.getDefinition().getDocumentBaseURI() != null) {
done.put(imp.getDefinition().getDocumentBaseURI(), imp.getDefinition());
}
updateDefinition(bus, imp.getDefinition(), done, doneSchemas, base, start, null);
}
}
} else {
if (done.put(decodedStart, imp.getDefinition()) == null) {
done.put(resolvedSchemaLocation, imp.getDefinition());
if (imp.getDefinition() != null && imp.getDefinition().getDocumentBaseURI() != null) {
done.put(imp.getDefinition().getDocumentBaseURI(), imp.getDefinition());
}
updateDefinition(bus, imp.getDefinition(), done, doneSchemas, base, start, resolvedSchemaLocation);
}
}
}
}
/* This doesn't actually work. Setting setSchemaLocationURI on the import
* for some reason doesn't actually result in the new URI being written
* */
Types types = def.getTypes();
if (types != null) {
for (ExtensibilityElement el : CastUtils.cast(types.getExtensibilityElements(), ExtensibilityElement.class)) {
if (el instanceof Schema) {
updateSchemaImports(bus, (Schema) el, docBase, doneSchemas, base, parentResolvedLocation);
}
}
}
}
use of javax.wsdl.Types in project cxf by apache.
the class ServiceWSDLBuilder method buildTypesWithSchemaImports.
/**
* @param schemas
* @param imports
* @param def
*/
protected void buildTypesWithSchemaImports(final Collection<SchemaInfo> schemas, final Map<String, SchemaInfo> imports, final Definition def) {
Types types = def.createTypes();
Map<String, Schema> namespaceToSchemaMap = new HashMap<>();
Map<String, SchemaInfo> namespaceToSchemaInfo = new HashMap<>();
for (SchemaInfo schemaInfo : schemas) {
Schema schema = getSchemaImplementation(def);
schema.setRequired(true);
schema.setElementType(WSDLConstants.QNAME_SCHEMA);
String name = baseFileName + "_schema" + (++xsdCount) + ".xsd";
schema.setDocumentBaseURI(name);
schema.setElement(schemaInfo.getElement());
namespaceToSchemaMap.put(schemaInfo.getNamespaceURI(), schema);
namespaceToSchemaInfo.put(schemaInfo.getNamespaceURI(), schemaInfo);
imports.put(name, schemaInfo);
}
for (Schema schema : namespaceToSchemaMap.values()) {
Element docElement = schema.getElement();
List<Element> elementList = DOMUtils.findAllElementsByTagNameNS(docElement, "http://www.w3.org/2001/XMLSchema", "import");
for (Element el : elementList) {
String sn = el.getAttribute("namespace");
Schema referencedSchema = namespaceToSchemaMap.get(sn);
if (referencedSchema != null) {
SchemaInfo schemaInfo = namespaceToSchemaInfo.get(sn);
el.setAttribute("schemaLocation", referencedSchema.getDocumentBaseURI());
addSchemaImport(schema, schemaInfo, referencedSchema);
}
}
}
Document doc = DOMUtils.createDocument();
Element nd = doc.createElementNS(WSDLConstants.NS_SCHEMA_XSD, "schema");
nd.setAttribute("xmlns", WSDLConstants.NS_SCHEMA_XSD);
doc.appendChild(nd);
Schema schema = getSchemaImplementation(def);
schema.setRequired(true);
schema.setElementType(WSDLConstants.QNAME_SCHEMA);
Collection<String> defNamespaces = CastUtils.cast(def.getNamespaces().values());
for (SchemaInfo schemaInfo : schemas) {
Schema referencedSchema = namespaceToSchemaMap.get(schemaInfo.getNamespaceURI());
// this ensures only the schemas directly referenced by the wsdl are included.
if (defNamespaces.contains(schemaInfo.getNamespaceURI())) {
Element impElement = doc.createElementNS(WSDLConstants.NS_SCHEMA_XSD, "import");
impElement.setAttribute("schemaLocation", referencedSchema.getDocumentBaseURI());
impElement.setAttribute("namespace", schemaInfo.getNamespaceURI());
nd.appendChild(impElement);
addSchemaImport(schema, schemaInfo, referencedSchema);
}
}
schema.setElement(nd);
types.addExtensibilityElement(schema);
def.setTypes(types);
}
use of javax.wsdl.Types in project cxf by apache.
the class SchemaUtil method getSchemaList.
// Workaround for getting the elements
private void getSchemaList(Definition def) {
Types typesElement = def.getTypes();
if (typesElement != null) {
Iterator<?> ite = typesElement.getExtensibilityElements().iterator();
while (ite.hasNext()) {
Object obj = ite.next();
if (obj instanceof Schema) {
Schema schema = (Schema) obj;
addSchema(schema.getDocumentBaseURI(), schema);
}
}
}
}
Aggregations