use of javax.wsdl.Import in project cxf by apache.
the class CorbaObjectReferenceHelper method populateEprInfo.
public static void populateEprInfo(EprMetaData info) {
if (!info.isValid()) {
return;
}
Binding match = info.getBinding();
Definition wsdlDef = info.getCandidateWsdlDef();
Collection<Service> services = CastUtils.cast(wsdlDef.getServices().values());
for (Service serv : services) {
Collection<Port> ports = CastUtils.cast(serv.getPorts().values());
for (Port pt : ports) {
if (pt.getBinding().equals(match)) {
info.setPortName(pt.getName());
info.setServiceQName(serv.getQName());
break;
}
}
}
if (info.getServiceQName() == null) {
Iterator<?> importLists = wsdlDef.getImports().values().iterator();
while (info.getServiceQName() == null && importLists.hasNext()) {
List<?> imports = (List<?>) importLists.next();
for (java.lang.Object imp : imports) {
if (imp instanceof Import) {
Definition importDef = ((Import) imp).getDefinition();
LOG.log(Level.FINE, "following wsdl import " + importDef.getDocumentBaseURI());
info.setCandidateWsdlDef(importDef);
populateEprInfo(info);
if (info.getServiceQName() != null) {
break;
}
}
}
}
}
}
use of javax.wsdl.Import in project cxf by apache.
the class CorbaObjectReferenceHelper method getBindingForTypeId.
public static EprMetaData getBindingForTypeId(String repId, Definition wsdlDef) {
LOG.log(Level.FINE, "RepositoryId " + repId + ", wsdl namespace " + wsdlDef.getTargetNamespace());
EprMetaData ret = new EprMetaData();
Collection<Binding> bindings = CastUtils.cast(wsdlDef.getBindings().values());
for (Binding b : bindings) {
List<?> extElements = b.getExtensibilityElements();
// Get the list of all extensibility elements
for (Iterator<?> extIter = extElements.iterator(); extIter.hasNext(); ) {
java.lang.Object element = extIter.next();
// Find a binding type so we can check against its repository ID
if (element instanceof BindingType) {
BindingType type = (BindingType) element;
if (repId.equals(type.getRepositoryID())) {
ret.setCandidateWsdlDef(wsdlDef);
ret.setBinding(b);
return ret;
}
}
}
}
if (!ret.isValid()) {
// recursivly check imports
Iterator<?> importLists = wsdlDef.getImports().values().iterator();
while (importLists.hasNext()) {
List<?> imports = (List<?>) importLists.next();
for (java.lang.Object imp : imports) {
if (imp instanceof Import) {
Definition importDef = ((Import) imp).getDefinition();
LOG.log(Level.INFO, "Following import " + importDef.getDocumentBaseURI());
ret = getBindingForTypeId(repId, importDef);
if (ret.isValid()) {
return ret;
}
}
}
}
}
return ret;
}
use of javax.wsdl.Import in project cxf by apache.
the class WSDLRefValidator method parseImports.
private void parseImports(Definition def) {
for (Import impt : getImports(def)) {
if (!importedDefinitions.contains(impt.getDefinition())) {
importedDefinitions.add(impt.getDefinition());
parseImports(impt.getDefinition());
}
}
}
use of javax.wsdl.Import in project cxf by apache.
the class WSDLASTVisitor method getLogicalDefinition.
// Gets the logical definition for a file - an import will be added for the
// schema types if -T is used and a separate schema file generated.
// if -n is used an import will be added for the schema types and no types generated.
private Definition getLogicalDefinition(String schemaFilename, Writer schemaWriter) throws WSDLException, JAXBException, Exception {
Definition def = manager.createWSDLDefinition(targetNamespace);
// checks for -T option.
if (schemaFilename != null) {
writeSchemaDefinition(definition, schemaWriter);
manager.addWSDLSchemaImport(def, schema.getTargetNamespace(), schemaFilename);
} else {
// checks for -n option
if (importSchemaFilename == null) {
Types types = definition.getTypes();
def.setTypes(types);
} else {
manager.addWSDLSchemaImport(def, schema.getTargetNamespace(), importSchemaFilename);
}
}
Collection<PortType> portTypes = CastUtils.cast(definition.getAllPortTypes().values());
for (PortType port : portTypes) {
def.addPortType(port);
}
Collection<Message> messages = CastUtils.cast(definition.getMessages().values());
for (Message msg : messages) {
def.addMessage(msg);
}
Collection<String> namespaces = CastUtils.cast(definition.getNamespaces().values());
for (String namespace : namespaces) {
String prefix = definition.getPrefix(namespace);
if (!"corba".equals(prefix)) {
def.addNamespace(prefix, namespace);
} else {
def.removeNamespace(prefix);
}
}
Collection<Import> imports = CastUtils.cast(definition.getImports().values());
for (Import importType : imports) {
def.addImport(importType);
}
def.setDocumentationElement(definition.getDocumentationElement());
def.setDocumentBaseURI(definition.getDocumentBaseURI());
return def;
}
use of javax.wsdl.Import in project cxf by apache.
the class WSDLSchemaManager method addWSDLDefinitionImport.
public void addWSDLDefinitionImport(Definition rootDefn, Definition defn, String prefix, File file) {
if (rootDefn.getImports().get(defn.getTargetNamespace()) == null && !".wsdl".equals(file.getName())) {
// Only import if not already done to prevent multiple imports of the same file
// in the WSDL. Also watch out for empty fileNames, which by this point in the
// code would show up as ".wsdl".
Import importDefn = rootDefn.createImport();
if (!ignoreImports) {
importDefn.setLocationURI(file.toURI().toString());
}
importDefn.setNamespaceURI(defn.getTargetNamespace());
rootDefn.addImport(importDefn);
}
if (!rootDefn.getNamespaces().values().contains(defn.getTargetNamespace())) {
rootDefn.addNamespace(prefix, defn.getTargetNamespace());
}
if (!importedDefns.containsKey(file)) {
importedDefns.put(file, defn);
}
}
Aggregations