if (wsdl2 != null) {
def = mp.get(wsdl2);
}
}
if (def == null) {
throw new WSDLQueryException(new Message("WSDL_NOT_FOUND", LOG, wsdl), null);
}
synchronized (def) {
//writing a def is not threadsafe. Sync on it to make sure
//we don't get any ConcurrentModificationExceptions
if (endpointInfo.getProperty("publishedEndpointUrl") != null) {
String publishingUrl =
String.valueOf(endpointInfo.getProperty("publishedEndpointUrl"));
updatePublishedEndpointUrl(publishingUrl, def, endpointInfo.getName());
}
WSDLWriter wsdlWriter = bus.getExtension(WSDLManager.class)
.getWSDLFactory().newWSDLWriter();
def.setExtensionRegistry(bus.getExtension(WSDLManager.class).getExtensionRegistry());
doc = wsdlWriter.getDocument(def);
}
} else {
SchemaReference si = smp.get(xsd);
if (si == null) {
String xsd2 = resolveWithCatalogs(OASISCatalogManager.getCatalogManager(bus),
xsd,
base);
if (xsd2 != null) {
si = smp.get(xsd2);
}
}
if (si == null) {
throw new WSDLQueryException(new Message("SCHEMA_NOT_FOUND", LOG, wsdl), null);
}
String uri = si.getReferencedSchema().getDocumentBaseURI();
uri = resolveWithCatalogs(OASISCatalogManager.getCatalogManager(bus),
uri,
si.getReferencedSchema().getDocumentBaseURI());
if (uri == null) {
uri = si.getReferencedSchema().getDocumentBaseURI();
}
ResourceManagerWSDLLocator rml = new ResourceManagerWSDLLocator(uri,
bus);
InputSource src = rml.getBaseInputSource();
doc = XMLUtils.getParser().parse(src);
}
updateDoc(doc, base, mp, smp, endpointInfo);
String enc = null;
try {
enc = doc.getXmlEncoding();
} catch (Exception ex) {
//ignore - not dom level 3
}
if (enc == null) {
enc = "utf-8";
}
XMLStreamWriter writer = StaxUtils.createXMLStreamWriter(os,
enc);
StaxUtils.writeNode(doc, writer, true);
writer.flush();
} catch (WSDLQueryException wex) {
throw wex;
} catch (Exception wex) {
throw new WSDLQueryException(new Message("COULD_NOT_PROVIDE_WSDL",
LOG,
baseUri), wex);
}
}