log.debug("Enter: JavaProvider::generateWSDL (" + this + ")");
/* Find the service we're invoking so we can grab it's options */
/***************************************************************/
SOAPService service = msgContext.getService();
ServiceDesc serviceDesc = service.getInitializedServiceDesc(msgContext);
// Calculate the appropriate namespaces for the WSDL we're going
// to put out.
//
// If we've been explicitly told which namespaces to use, respect
// that. If not:
//
// The "interface namespace" should be either:
// 1) The namespace of the ServiceDesc
// 2) The transport URL (if there's no ServiceDesc ns)
try {
// Location URL is whatever is explicitly set in the MC
String locationUrl =
msgContext.getStrProp(MessageContext.WSDLGEN_SERV_LOC_URL);
if (locationUrl == null) {
// If nothing, try what's explicitly set in the ServiceDesc
locationUrl = serviceDesc.getEndpointURL();
}
if (locationUrl == null) {
// If nothing, use the actual transport URL
locationUrl = msgContext.getStrProp(MessageContext.TRANS_URL);
}
// Interface namespace is whatever is explicitly set
String interfaceNamespace =
msgContext.getStrProp(MessageContext.WSDLGEN_INTFNAMESPACE);
if (interfaceNamespace == null) {
// If nothing, use the default namespace of the ServiceDesc
interfaceNamespace = serviceDesc.getDefaultNamespace();
}
if (interfaceNamespace == null) {
// If nothing still, use the location URL determined above
interfaceNamespace = locationUrl;
}
// Do we want to do this?
//
// if (locationUrl == null) {
// locationUrl = url;
// } else {
// try {
// URL urlURL = new URL(url);
// URL locationURL = new URL(locationUrl);
// URL urlTemp = new URL(urlURL.getProtocol(),
// locationURL.getHost(),
// locationURL.getPort(),
// urlURL.getFile());
// interfaceNamespace += urlURL.getFile();
// locationUrl = urlTemp.toString();
// } catch (Exception e) {
// locationUrl = url;
// interfaceNamespace = url;
// }
// }
Emitter emitter = new Emitter();
// service alias may be provided if exact naming is required,
// otherwise Axis will name it according to the implementing class name
String alias = (String)service.getOption("alias");
if(alias != null) emitter.setServiceElementName(alias);
emitter.setMode( (service.getStyle() == Style.RPC)
? Emitter.MODE_RPC
: Emitter.MODE_DOCUMENT);
emitter.setClsSmart(serviceDesc.getImplClass(), locationUrl);
// If a wsdl target namespace was provided, use the targetNamespace.
// Otherwise use the interfaceNamespace constructed above.
String targetNamespace = (String) service.getOption(OPTION_WSDL_TARGETNAMESPACE);
if (targetNamespace == null ||