} else {
handleException("Unknown WSDL format.. not WSDL 1.1 or WSDL 2.0");
}
if (wsdlToAxisServiceBuilder == null) {
throw new SynapseException(
"Could not get the WSDL to Axis Service Builder");
}
wsdlToAxisServiceBuilder.setBaseUri(wsdlURI != null ?
wsdlURI.toString() : synapseHome);
if (trace()) {
trace.info("Setting up custom resolvers");
}
// load the UserDefined WSDLResolver and SchemaURIResolver implementations
if (synCfg.getProperty(SynapseConstants.SYNAPSE_WSDL_RESOLVER) != null &&
synCfg.getProperty(SynapseConstants.SYNAPSE_SCHEMA_RESOLVER) != null) {
setUserDefinedResourceResolvers(synCfg, wsdlInputStream,
wsdlToAxisServiceBuilder);
} else {
//Use the Custom Resolvers
// Set up the URIResolver
if (resourceMap != null) {
// if the resource map is available use it
wsdlToAxisServiceBuilder.setCustomResolver(
new CustomXmlSchemaURIResolver(resourceMap, synCfg));
// Axis 2 also needs a WSDLLocator for WSDL 1.1 documents
if (wsdlToAxisServiceBuilder instanceof WSDL11ToAxisServiceBuilder) {
((WSDL11ToAxisServiceBuilder)
wsdlToAxisServiceBuilder).setCustomWSDLResolver(
new CustomWSDLLocator(new InputSource(wsdlInputStream),
wsdlURI != null ? wsdlURI.toString() : "",
resourceMap, synCfg));
}
} else {
//if the resource map isn't available ,
//then each import URIs will be resolved using base URI
wsdlToAxisServiceBuilder.setCustomResolver(
new CustomXmlSchemaURIResolver());
// Axis 2 also needs a WSDLLocator for WSDL 1.1 documents
if (wsdlToAxisServiceBuilder instanceof WSDL11ToAxisServiceBuilder) {
((WSDL11ToAxisServiceBuilder)
wsdlToAxisServiceBuilder).setCustomWSDLResolver(
new CustomWSDLLocator(new InputSource(wsdlInputStream),
wsdlURI != null ? wsdlURI.toString() : ""));
}
}
}
if (trace()) {
trace.info("Populating Axis2 service using WSDL");
if (trace.isTraceEnabled()) {
trace.trace("WSDL : " + wsdlElement.toString());
}
}
proxyService = wsdlToAxisServiceBuilder.populateService();
// this is to clear the bindings and ports already in the WSDL so that the
// service will generate the bindings on calling the printWSDL otherwise
// the WSDL which will be shown is same as the original WSDL except for the
// service name
proxyService.getEndpoints().clear();
} else {
handleException("Unknown WSDL format.. not WSDL 1.1 or WSDL 2.0");
}
} catch (AxisFault af) {
handleException("Error building service from WSDL", af);
} catch (IOException ioe) {
handleException("Error reading WSDL", ioe);
}
}
} else if (wsdlFound) {
handleException("Couldn't build the proxy service : " + name
+ ". Unable to locate the specified WSDL to build the service");
}
// Set the name and description. Currently Axis2 uses the name as the
// default Service destination
if (proxyService == null) {
throw new SynapseException("Could not create a proxy service");
}
proxyService.setName(name);
if (description != null) {
proxyService.setDocumentation(description);
}