BasicProviderpublic abstract class BasicProvider extends org.apache.axis.handlers.BasicHandler This class has one way of keeping track of the
operations declared for a particular service
provider. I'm not exactly married to this though. |
Fields Summary |
---|
public static final String | OPTION_WSDL_PORTTYPE | public static final String | OPTION_WSDL_SERVICEELEMENT | public static final String | OPTION_WSDL_SERVICEPORT | public static final String | OPTION_WSDL_TARGETNAMESPACE | public static final String | OPTION_WSDL_INPUTSCHEMA | public static final String | OPTION_WSDL_SOAPACTION_MODE | public static final String | OPTION_EXTRACLASSES | protected static Log | log | protected static Log | entLog |
Methods Summary |
---|
public void | addOperation(java.lang.String name, javax.xml.namespace.QName qname)
Hashtable operations = (Hashtable)getOption("Operations");
if (operations == null) {
operations = new Hashtable();
setOption("Operations", operations);
}
operations.put(qname, name);
| public void | generateWSDL(org.apache.axis.MessageContext msgContext)Generate the WSDL for this service.
Put in the "WSDL" property of the message context
as a org.w3c.dom.Document
if (log.isDebugEnabled())
log.debug("Enter: BasicProvider::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();
// This seems like a good idea, but in fact isn't because the
// emitter will figure out a reasonable name (<classname>Service)
// for the WSDL service element name. We provide the 'alias'
// setting to explicitly set this name. See bug 13262 for more info.
//emitter.setServiceElementName(serviceDesc.getName());
// 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);
// Set style/use
emitter.setStyle(serviceDesc.getStyle());
emitter.setUse(serviceDesc.getUse());
if (serviceDesc instanceof JavaServiceDesc) {
emitter.setClsSmart(((JavaServiceDesc)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 || targetNamespace.length() == 0) {
targetNamespace = interfaceNamespace;
}
emitter.setIntfNamespace(targetNamespace);
emitter.setLocationUrl(locationUrl);
emitter.setServiceDesc(serviceDesc);
emitter.setTypeMappingRegistry(msgContext.getTypeMappingRegistry());
String wsdlPortType = (String) service.getOption(OPTION_WSDL_PORTTYPE);
String wsdlServiceElement = (String) service.getOption(OPTION_WSDL_SERVICEELEMENT);
String wsdlServicePort = (String) service.getOption(OPTION_WSDL_SERVICEPORT);
String wsdlInputSchema = (String) service.getOption(OPTION_WSDL_INPUTSCHEMA);
String wsdlSoapActinMode = (String) service.getOption(OPTION_WSDL_SOAPACTION_MODE);
String extraClasses = (String) service.getOption(OPTION_EXTRACLASSES);
if (wsdlPortType != null && wsdlPortType.length() > 0) {
emitter.setPortTypeName(wsdlPortType);
}
if (wsdlServiceElement != null && wsdlServiceElement.length() > 0) {
emitter.setServiceElementName(wsdlServiceElement);
}
if (wsdlServicePort != null && wsdlServicePort.length() > 0) {
emitter.setServicePortName(wsdlServicePort);
}
if (wsdlInputSchema != null && wsdlInputSchema.length() > 0) {
emitter.setInputSchema(wsdlInputSchema);
}
if (wsdlSoapActinMode != null && wsdlSoapActinMode.length() > 0) {
emitter.setSoapAction(wsdlSoapActinMode);
}
if (extraClasses != null && extraClasses.length() > 0) {
emitter.setExtraClasses(extraClasses);
}
if (msgContext.isPropertyTrue(AxisEngine.PROP_EMIT_ALL_TYPES)) {
emitter.setEmitAllTypes(true);
}
Document doc = emitter.emit(Emitter.MODE_ALL);
msgContext.setProperty("WSDL", doc);
} catch (NoClassDefFoundError e) {
entLog.info(Messages.getMessage("toAxisFault00"), e);
throw new AxisFault(e.toString(), e);
} catch (Exception e) {
entLog.info(Messages.getMessage("toAxisFault00"), e);
throw AxisFault.makeFault(e);
}
if (log.isDebugEnabled())
log.debug("Exit: BasicProvider::generateWSDL (" + this +")");
| public java.lang.String | getOperationName(javax.xml.namespace.QName qname)
Hashtable operations = (Hashtable)getOption("Operations");
if (operations == null) return null;
return (String)operations.get(qname);
| public java.lang.String[] | getOperationNames()
Hashtable operations = (Hashtable)getOption("Operations");
if (operations == null) return null;
Object[] values = operations.values().toArray();
String[] names = new String[values.length];
System.arraycopy(values,0,names,0,values.length);
return names;
| public javax.xml.namespace.QName[] | getOperationQNames()
Hashtable operations = (Hashtable)getOption("Operations");
if (operations == null) return null;
Object[] keys = operations.keySet().toArray();
QName[] qnames = new QName[keys.length];
System.arraycopy(keys,0,qnames,0,keys.length);
return qnames;
| public abstract void | initServiceDesc(org.apache.axis.handlers.soap.SOAPService service, org.apache.axis.MessageContext msgContext)This method returns a ServiceDesc that contains the correct
implimentation class.
|
|