String base,
Map<String, String> params,
String ctxUri,
EndpointInfo endpointInfo) {
try {
Bus bus = message.getExchange().getBus();
Object prop = message.getContextualProperty(PUBLISHED_ENDPOINT_URL);
if (prop == null) {
prop = endpointInfo.getProperty(PUBLISHED_ENDPOINT_URL);
}
if (prop != null) {
base = String.valueOf(prop);
}
String wsdl = params.get("wsdl");
if (wsdl != null) {
// Always use the URL decoded version to ensure that we have a
// canonical representation of the import URL for lookup.
wsdl = URLDecoder.decode(wsdl, "utf-8");
}
String xsd = params.get("xsd");
if (xsd != null) {
// Always use the URL decoded version to ensure that we have a
// canonical representation of the import URL for lookup.
xsd = URLDecoder.decode(xsd, "utf-8");
}
Map<String, Definition> mp = CastUtils.cast((Map<?, ?>)endpointInfo.getService()
.getProperty(WSDLS_KEY));
Map<String, SchemaReference> smp = CastUtils.cast((Map<?, ?>)endpointInfo.getService()
.getProperty(SCHEMAS_KEY));
if (mp == null) {
endpointInfo.getService().setProperty(WSDLS_KEY,
new ConcurrentHashMap<String, Definition>(8, 0.75f, 4));
mp = CastUtils.cast((Map<?, ?>)endpointInfo.getService()
.getProperty(WSDLS_KEY));
}
if (smp == null) {
endpointInfo.getService().setProperty(SCHEMAS_KEY,
new ConcurrentHashMap<String, SchemaReference>(8, 0.75f, 4));
smp = CastUtils.cast((Map<?, ?>)endpointInfo.getService()
.getProperty(SCHEMAS_KEY));
}
if (!mp.containsKey("")) {
ServiceWSDLBuilder builder =
new ServiceWSDLBuilder(bus, endpointInfo.getService());
builder.setUseSchemaImports(
MessageUtils.getContextualBoolean(message, WSDL_CREATE_IMPORTS, false));
// base file name is ignored if createSchemaImports == false!
builder.setBaseFileName(endpointInfo.getService().getName().getLocalPart());
Definition def = builder.build(new HashMap<String, SchemaInfo>());
mp.put("", def);
updateDefinition(bus, def, mp, smp, base, endpointInfo, "");
}
Document doc;
if (xsd == null) {
Definition def = mp.get(wsdl);
if (def == null) {
String wsdl2 = resolveWithCatalogs(OASISCatalogManager.getCatalogManager(bus),
wsdl,
base);
if (wsdl2 != null) {
def = mp.get(wsdl2);
}
}
if (def == null) {
throw new WSDLQueryException(new org.apache.cxf.common.i18n.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(PUBLISHED_ENDPOINT_URL) != null) {
String epurl =
String.valueOf(endpointInfo.getProperty(PUBLISHED_ENDPOINT_URL));
updatePublishedEndpointUrl(epurl, def, endpointInfo.getName());
base = epurl;
}
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) {