You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by az...@apache.org on 2007/06/29 13:09:52 UTC
svn commit: r551853 [2/2] -
/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService.java
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService.java?view=diff&rev=551853&r1=551852&r2=551853
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService.java Fri Jun 29 04:09:50 2007
@@ -95,2109 +95,2115 @@
*/
public class AxisService extends AxisDescription {
- private Map endpointMap = new HashMap();
+ private Map endpointMap = new HashMap();
- /*This is a map between the QName of the element of a message
- *specified in the WSDL and an Operation. It enables SOAP Body-based
- *dispatching for doc-literal bindings.
- */
- private Map messageElementQNameToOperationMap = new HashMap();
-
- private int nsCount = 0;
- private static final Log log = LogFactory.getLog(AxisService.class);
- private URL fileName;
-
- // Maps httpLocations to corresponding operations. Used to dispatch rest messages.
- private HashMap httpLocationDispatcherMap = null;
-
- /** Map from String(action URI) -> AxisOperation */
- private HashMap operationsAliasesMap = null;
-
- // Collection of aliases that are invalid for this service because they are duplicated across
- // multiple operations under this service.
- private List invalidOperationsAliases = null;
+ /*This is a map between the QName of the element of a message
+ *specified in the WSDL and an Operation. It enables SOAP Body-based
+ *dispatching for doc-literal bindings.
+ */
+ private Map messageElementQNameToOperationMap = new HashMap();
+
+ private int nsCount = 0;
+ private static final Log log = LogFactory.getLog(AxisService.class);
+ private URL fileName;
+
+ // Maps httpLocations to corresponding operations. Used to dispatch rest messages.
+ private HashMap httpLocationDispatcherMap = null;
+
+ /**
+ * Map from String(action URI) -> AxisOperation
+ */
+ private HashMap operationsAliasesMap = null;
+
+ // Collection of aliases that are invalid for this service because they are duplicated across
+ // multiple operations under this service.
+ private List invalidOperationsAliases = null;
// private HashMap operations = new HashMap();
- // to store module ref at deploy time parsing
- private ArrayList moduleRefs = null;
+ // to store module ref at deploy time parsing
+ private ArrayList moduleRefs = null;
- // to store the wsdl definition , which is build at the deployment time
- // to keep the time that last update time of the service
- private long lastupdate;
- private HashMap moduleConfigmap;
- private String name;
- private ClassLoader serviceClassLoader;
-
- //to keep the XMLScheam getting either from WSDL or java2wsdl
- private ArrayList schemaList;
- //private XmlSchema schema;
-
- //wsdl is there for this service or not (in side META-INF)
- private boolean wsdlFound = false;
-
- //to store the scope of the service
- private String scope;
-
- //to store default message receivers
- private HashMap messageReceivers;
-
- // to set the handler chain available in phase info
- private boolean useDefaultChains = true;
-
- //to keep the status of the service , since service can stop at the run time
- private boolean active = true;
-
- private boolean elementFormDefault = true;
-
- //to keep the service target name space
- private String targetNamespace =
- Java2WSDLConstants.DEFAULT_TARGET_NAMESPACE;
- private String targetNamespacePrefix =
- Java2WSDLConstants.TARGETNAMESPACE_PREFIX;
-
- // to store the target namespace for the schema
- private String schematargetNamespace;// = Java2WSDLConstants.AXIS2_XSD;
- private String schematargetNamespacePrefix =
- Java2WSDLConstants.SCHEMA_NAMESPACE_PRFIX;
-
- private boolean enableAllTransports = true;
- private List exposedTransports = new ArrayList();
-
- //To keep reference to ServiceLifeCycle instance , if the user has
- // specified in services.xml
- private ServiceLifeCycle serviceLifeCycle;
-
-
- /**
- * Keeps track whether the schema locations are adjusted
- */
- private boolean schemaLocationsAdjusted = false;
-
- /**
- * A table that keeps a mapping of unique xsd names (Strings)
- * against the schema objects. This is populated in the first
- * instance the schemas are asked for and then used to serve
- * the subsequent requests
- */
- private Map schemaMappingTable = null;
-
-
- /**
- * counter variable for naming the schemas
- */
- private int count = 0;
- /**
- * A custom schema Name prefix. if set this will be used to
- * modify the schema names
- */
- private String customSchemaNamePrefix = null;
-
- /**
- * A custom schema name suffix. will be attached to the
- * schema file name when the files are uniquely named.
- * A good place to add a file extension if needed
- */
- private String customSchemaNameSuffix = null;
- /////////////////////////////////////////
- // WSDL related stuff ////////////////////
- ////////////////////////////////////////
- private NamespaceMap nameSpacesMap;
-
- private String soapNsUri;
- private String endpointName;
- private String endpointURL;
-
- // Flag representing whether WS-Addressing is required to use this service.
- // Reflects the wsaw:UsingAddressing wsdl extension element
- private String wsaddressingFlag = AddressingConstants.ADDRESSING_UNSPECIFIED;
- private boolean clientSide = false;
-
- //To keep a ref to ObjectSupplier instance
- private ObjectSupplier objectSupplier;
-
- // package to namespace mapping
- private Map p2nMap;
-
- private TypeTable typeTable;
-
- // Data Locators for WS-Mex Support
- private HashMap dataLocators;
- private HashMap dataLocatorClassNames;
- private AxisDataLocatorImpl defaultDataLocator;
- // Define search sequence for datalocator based on Data Locator types.
- LocatorType[] availableDataLocatorTypes = new LocatorType[]{LocatorType.SERVICE_DIALECT,
- LocatorType.SERVICE_LEVEL, LocatorType.GLOBAL_DIALECT, LocatorType.GLOBAL_LEVEL,
- LocatorType.DEFAULT_AXIS};
-
- // name of the binding used : use in codegeneration
- private String bindingName;
-
- // names list keep to preserve the parameter order
- private List operationsNameList;
-
- private String[] eprs = null;
-
- public AxisEndpoint getEndpoint(String key) {
- return (AxisEndpoint) endpointMap.get(key);
- }
-
- public void addEndpoint(String key, AxisEndpoint axisEndpoint) {
- this.endpointMap.put(key, axisEndpoint);
- }
-
- private boolean customWsdl = false;
-
- public String getWSAddressingFlag() {
- return wsaddressingFlag;
- }
-
- public void setWSAddressingFlag(String ar) {
- wsaddressingFlag = ar;
- if (wsaddressingFlag == null) {
- wsaddressingFlag = AddressingConstants.ADDRESSING_UNSPECIFIED;
- }
- }
-
- public boolean isSchemaLocationsAdjusted() {
- return schemaLocationsAdjusted;
- }
-
- public void setSchemaLocationsAdjusted(boolean schemaLocationsAdjusted) {
- this.schemaLocationsAdjusted = schemaLocationsAdjusted;
- }
-
- public Map getSchemaMappingTable() {
- return schemaMappingTable;
- }
-
- public void setSchemaMappingTable(Map schemaMappingTable) {
- this.schemaMappingTable = schemaMappingTable;
- }
-
- public String getCustomSchemaNamePrefix() {
- return customSchemaNamePrefix;
- }
-
- public void setCustomSchemaNamePrefix(String customSchemaNamePrefix) {
- this.customSchemaNamePrefix = customSchemaNamePrefix;
- }
-
- public String getCustomSchemaNameSuffix() {
- return customSchemaNameSuffix;
- }
-
- public void setCustomSchemaNameSuffix(String customSchemaNameSuffix) {
- this.customSchemaNameSuffix = customSchemaNameSuffix;
- }
-
- /**
- * Constructor AxisService.
- */
- public AxisService() {
- super();
- this.operationsAliasesMap = new HashMap();
- this.invalidOperationsAliases = new ArrayList();
- moduleConfigmap = new HashMap();
- //by default service scope is for the request
- scope = Constants.SCOPE_REQUEST;
- httpLocationDispatcherMap = new HashMap();
- messageReceivers = new HashMap();
- moduleRefs = new ArrayList();
- schemaList = new ArrayList();
- serviceClassLoader = (ClassLoader) org.apache.axis2.java.security.AccessController
- .doPrivileged(new PrivilegedAction() {
- public Object run() {
- return Thread.currentThread().getContextClassLoader();
- }
- });
- objectSupplier = new DefaultObjectSupplier();
- dataLocators = new HashMap();
- dataLocatorClassNames = new HashMap();
-
- }
-
- /**
- * @return name of the port type
- * @deprecated use AxisService#getEndpointName() instead.
- */
- public String getPortTypeName() {
- return endpointName;
- }
-
- /**
- * @param portTypeName
- * @deprecated use AxisService#setEndpointName() instead
- */
- public void setPortTypeName(String portTypeName) {
- this.endpointName = portTypeName;
- }
-
- public String getBindingName() {
- return bindingName;
- }
-
- public void setBindingName(String bindingName) {
- this.bindingName = bindingName;
- }
-
- /**
- * get the SOAPVersion
- */
- public String getSoapNsUri() {
- return soapNsUri;
- }
-
- public void setSoapNsUri(String soapNsUri) {
- this.soapNsUri = soapNsUri;
- }
-
- /**
- * get the endpointName
- */
- public String getEndpointName() {
- return endpointName;
- }
-
- public void setEndpointName(String endpoint) {
- this.endpointName = endpoint;
- }
-
- /**
- * Constructor AxisService.
- */
- public AxisService(String name) {
- this();
- this.name = name;
- }
-
- public void addMessageReceiver(String mepURI, MessageReceiver messageReceiver) {
- if (WSDL2Constants.MEP_URI_IN_ONLY.equals(mepURI) ||
- WSDLConstants.WSDL20_2006Constants.MEP_URI_IN_ONLY.equals(mepURI) ||
- WSDLConstants.WSDL20_2004_Constants.MEP_URI_IN_ONLY.equals(mepURI)) {
- messageReceivers
- .put(WSDL2Constants.MEP_URI_IN_ONLY, messageReceiver);
- messageReceivers
- .put(WSDLConstants.WSDL20_2006Constants.MEP_URI_IN_ONLY, messageReceiver);
- messageReceivers
- .put(WSDLConstants.WSDL20_2004_Constants.MEP_URI_IN_ONLY, messageReceiver);
- } else if (WSDL2Constants.MEP_URI_OUT_ONLY.equals(mepURI) ||
- WSDLConstants.WSDL20_2006Constants.MEP_URI_OUT_ONLY.equals(mepURI) ||
- WSDLConstants.WSDL20_2004_Constants.MEP_URI_OUT_ONLY.equals(mepURI)) {
- messageReceivers
- .put(WSDL2Constants.MEP_URI_OUT_ONLY, messageReceiver);
- messageReceivers
- .put(WSDLConstants.WSDL20_2006Constants.MEP_URI_OUT_ONLY, messageReceiver);
- messageReceivers
- .put(WSDLConstants.WSDL20_2004_Constants.MEP_URI_OUT_ONLY, messageReceiver);
- } else if (WSDL2Constants.MEP_URI_IN_OUT.equals(mepURI) ||
- WSDLConstants.WSDL20_2006Constants.MEP_URI_IN_OUT.equals(mepURI) ||
- WSDLConstants.WSDL20_2004_Constants.MEP_URI_IN_OUT.equals(mepURI)) {
- messageReceivers
- .put(WSDL2Constants.MEP_URI_IN_OUT, messageReceiver);
- messageReceivers
- .put(WSDLConstants.WSDL20_2006Constants.MEP_URI_IN_OUT, messageReceiver);
- messageReceivers
- .put(WSDLConstants.WSDL20_2004_Constants.MEP_URI_IN_OUT, messageReceiver);
- } else if (WSDL2Constants.MEP_URI_IN_OPTIONAL_OUT.equals(mepURI) ||
- WSDLConstants.WSDL20_2006Constants.MEP_URI_IN_OPTIONAL_OUT.equals(mepURI) ||
- WSDLConstants.WSDL20_2004_Constants.MEP_URI_IN_OPTIONAL_OUT.equals(mepURI)) {
- messageReceivers.put(WSDL2Constants.MEP_URI_IN_OPTIONAL_OUT,
- messageReceiver);
- messageReceivers.put(WSDLConstants.WSDL20_2006Constants.MEP_URI_IN_OPTIONAL_OUT,
- messageReceiver);
- messageReceivers.put(WSDLConstants.WSDL20_2004_Constants.MEP_URI_IN_OPTIONAL_OUT,
- messageReceiver);
- } else if (WSDL2Constants.MEP_URI_OUT_IN.equals(mepURI) ||
- WSDLConstants.WSDL20_2006Constants.MEP_URI_OUT_IN.equals(mepURI) ||
- WSDLConstants.WSDL20_2004_Constants.MEP_URI_OUT_IN.equals(mepURI)) {
- messageReceivers
- .put(WSDL2Constants.MEP_URI_OUT_IN, messageReceiver);
- messageReceivers
- .put(WSDLConstants.WSDL20_2006Constants.MEP_URI_OUT_IN, messageReceiver);
- messageReceivers
- .put(WSDLConstants.WSDL20_2004_Constants.MEP_URI_OUT_IN, messageReceiver);
- } else if (WSDL2Constants.MEP_URI_OUT_OPTIONAL_IN.equals(mepURI) ||
- WSDLConstants.WSDL20_2006Constants.MEP_URI_OUT_OPTIONAL_IN.equals(mepURI) ||
- WSDLConstants.WSDL20_2004_Constants.MEP_URI_OUT_OPTIONAL_IN.equals(mepURI)) {
- messageReceivers.put(WSDL2Constants.MEP_URI_OUT_OPTIONAL_IN,
- messageReceiver);
- messageReceivers.put(WSDLConstants.WSDL20_2006Constants.MEP_URI_OUT_OPTIONAL_IN,
- messageReceiver);
- messageReceivers.put(WSDLConstants.WSDL20_2004_Constants.MEP_URI_OUT_OPTIONAL_IN,
- messageReceiver);
- } else if (WSDL2Constants.MEP_URI_ROBUST_OUT_ONLY.equals(mepURI) ||
- WSDLConstants.WSDL20_2006Constants.MEP_URI_ROBUST_OUT_ONLY.equals(mepURI) ||
- WSDLConstants.WSDL20_2004_Constants.MEP_URI_ROBUST_OUT_ONLY.equals(mepURI)) {
- messageReceivers.put(WSDL2Constants.MEP_URI_ROBUST_OUT_ONLY,
- messageReceiver);
- messageReceivers.put(WSDLConstants.WSDL20_2006Constants.MEP_URI_ROBUST_OUT_ONLY,
- messageReceiver);
- messageReceivers.put(WSDLConstants.WSDL20_2004_Constants.MEP_URI_ROBUST_OUT_ONLY,
- messageReceiver);
- } else if (WSDL2Constants.MEP_URI_ROBUST_IN_ONLY.equals(mepURI) ||
- WSDLConstants.WSDL20_2006Constants.MEP_URI_ROBUST_IN_ONLY.equals(mepURI) ||
- WSDLConstants.WSDL20_2004_Constants.MEP_URI_ROBUST_IN_ONLY.equals(mepURI)) {
- messageReceivers.put(WSDL2Constants.MEP_URI_ROBUST_IN_ONLY,
- messageReceiver);
- messageReceivers.put(WSDLConstants.WSDL20_2006Constants.MEP_URI_ROBUST_IN_ONLY,
- messageReceiver);
- messageReceivers.put(WSDLConstants.WSDL20_2004_Constants.MEP_URI_ROBUST_IN_ONLY,
- messageReceiver);
- } else {
- messageReceivers.put(mepURI, messageReceiver);
- }
- }
-
- public MessageReceiver getMessageReceiver(String mepURL) {
- return (MessageReceiver) messageReceivers.get(mepURL);
- }
-
- /**
- * Adds module configuration , if there is moduleConfig tag in service.
- *
- * @param moduleConfiguration
- */
- public void addModuleConfig(ModuleConfiguration moduleConfiguration) {
- moduleConfigmap.put(moduleConfiguration.getModuleName(), moduleConfiguration);
- }
-
- /**
- * Add any control operations defined by a Module to this service.
- *
- * @param module the AxisModule which has just been engaged
- * @throws AxisFault if a problem occurs
- */
- void addModuleOperations(AxisModule module) throws AxisFault {
- HashMap map = module.getOperations();
- Collection col = map.values();
- PhaseResolver phaseResolver = new PhaseResolver(getAxisConfiguration());
- for (Iterator iterator = col.iterator(); iterator.hasNext();) {
- AxisOperation axisOperation = copyOperation((AxisOperation) iterator.next());
- if (this.getOperation(axisOperation.getName()) == null) {
- ArrayList wsamappings = axisOperation.getWSAMappingList();
- if (wsamappings != null) {
- for (int j = 0, size = wsamappings.size(); j < size; j++) {
- String mapping = (String) wsamappings.get(j);
- mapActionToOperation(mapping, axisOperation);
- }
- }
- // If we've set the "expose" parameter for this operation, it's normal (non-
- // control) and therefore it will appear in generated WSDL. If we haven't,
- // it's a control operation and will be ignored at WSDL-gen time.
- if (axisOperation.isParameterTrue(DeploymentConstants.TAG_EXPOSE)) {
- axisOperation.setControlOperation(false);
- } else {
- axisOperation.setControlOperation(true);
- }
-
- phaseResolver.engageModuleToOperation(axisOperation, module);
-
- this.addOperation(axisOperation);
- }
- }
- }
-
- public void addModuleref(String moduleref) {
- moduleRefs.add(moduleref);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.axis2.description.AxisService#addOperation(org.apache.axis2.description.AxisOperation)
- */
-
- /**
- * Method addOperation.
- *
- * @param axisOperation
- */
- public void addOperation(AxisOperation axisOperation) {
- axisOperation.setParent(this);
-
- Iterator modules = getEngagedModules().iterator();
-
- while (modules.hasNext()) {
- AxisModule module = (AxisModule) modules.next();
- try {
- axisOperation.engageModule(module);
- } catch (AxisFault axisFault) {
- log.info(Messages.getMessage("modulealredyengagetoservice", module.getName()));
- }
- }
- if (axisOperation.getMessageReceiver() == null) {
- axisOperation.setMessageReceiver(
- loadDefaultMessageReceiver(axisOperation.getMessageExchangePattern(), this));
- }
- if (axisOperation.getInputAction() == null) {
- axisOperation.setSoapAction("urn:" + axisOperation.getName().getLocalPart());
- }
-
- if (axisOperation.getOutputAction() == null) {
- axisOperation.setOutputAction("urn:" + axisOperation.getName().getLocalPart() +
- Java2WSDLConstants.RESPONSE);
- }
- addChild(axisOperation);
-
- String operationName = axisOperation.getName().getLocalPart();
-
- /*
- Some times name of the operation can be different from the name of the first child of the SOAPBody.
- This will put the correct mapping associating that name with the operation. This will be useful especially for
- the SOAPBodyBasedDispatcher
- */
-
- Iterator axisMessageIter = axisOperation.getChildren();
-
- while (axisMessageIter.hasNext()) {
- AxisMessage axisMessage = (AxisMessage) axisMessageIter.next();
- String messageName = axisMessage.getName();
- if (messageName != null && !messageName.equals(operationName)) {
- mapActionToOperation(messageName, axisOperation);
- }
- }
-
- mapActionToOperation(operationName, axisOperation);
-
- String action = axisOperation.getInputAction();
- if (action.length() > 0) {
- mapActionToOperation(action, axisOperation);
- }
-
- ArrayList wsamappings = axisOperation.getWSAMappingList();
- if (wsamappings != null) {
- for (int j = 0, size = wsamappings.size(); j < size; j++) {
- String mapping = (String) wsamappings.get(j);
- mapActionToOperation(mapping, axisOperation);
- }
- }
-
- if (axisOperation.getMessageReceiver() == null) {
- axisOperation.setMessageReceiver(
- loadDefaultMessageReceiver(
- axisOperation.getMessageExchangePattern(), this));
- }
- }
-
-
- private MessageReceiver loadDefaultMessageReceiver(String mepURL, AxisService service) {
- MessageReceiver messageReceiver;
- if (mepURL == null) {
- mepURL = WSDL2Constants.MEP_URI_IN_OUT;
- }
- if (service != null) {
- messageReceiver = service.getMessageReceiver(mepURL);
- if (messageReceiver != null) {
- return messageReceiver;
- }
- }
- if (getParent() != null && getParent().getParent() != null) {
- return ((AxisConfiguration) getParent().getParent()).getMessageReceiver(mepURL);
- }
- return null;
- }
-
-
- /**
- * Gets a copy from module operation.
- *
- * @param axisOperation
- * @return Returns AxisOperation.
- * @throws AxisFault
- */
- private AxisOperation copyOperation(AxisOperation axisOperation) throws AxisFault {
- AxisOperation operation =
- AxisOperationFactory
- .getOperationDescription(axisOperation.getMessageExchangePattern());
-
- operation.setMessageReceiver(axisOperation.getMessageReceiver());
- operation.setName(axisOperation.getName());
-
- Iterator parameters = axisOperation.getParameters().iterator();
-
- while (parameters.hasNext()) {
- Parameter parameter = (Parameter) parameters.next();
-
- operation.addParameter(parameter);
- }
-
- PolicyInclude policyInclude = new PolicyInclude(operation);
- PolicyInclude axisOperationPolicyInclude = axisOperation.getPolicyInclude();
-
- if (axisOperationPolicyInclude != null) {
- Policy policy = axisOperationPolicyInclude.getPolicy();
- if (policy != null) {
- policyInclude.setPolicy(axisOperationPolicyInclude.getPolicy());
- }
- }
- operation.setPolicyInclude(policyInclude);
-
- operation.setWsamappingList(axisOperation.getWSAMappingList());
- operation.setRemainingPhasesInFlow(axisOperation.getRemainingPhasesInFlow());
- operation.setPhasesInFaultFlow(axisOperation.getPhasesInFaultFlow());
- operation.setPhasesOutFaultFlow(axisOperation.getPhasesOutFaultFlow());
- operation.setPhasesOutFlow(axisOperation.getPhasesOutFlow());
-
- operation.setOutputAction(axisOperation.getOutputAction());
- String[] faultActionNames = axisOperation.getFaultActionNames();
- for (int i = 0; i < faultActionNames.length; i++) {
- operation.addFaultAction(faultActionNames[i],
- axisOperation.getFaultAction(faultActionNames[i]));
- }
-
- return operation;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.axis2.description.AxisService#addToengagedModules(javax.xml.namespace.QName)
- */
-
- /**
- * Engages a module. It is required to use this method.
- *
- * @param axisModule
- * @param engager
- */
- public void onEngage(AxisModule axisModule, AxisDescription engager)
- throws AxisFault {
- // adding module operations
- addModuleOperations(axisModule);
-
- Iterator operations = getOperations();
- while (operations.hasNext()) {
- AxisOperation axisOperation = (AxisOperation) operations.next();
- axisOperation.engageModule(axisModule, engager);
- }
- }
-
- /**
- * Maps an action (a SOAPAction or WSA action) to the given operation. This is used by
- * dispatching (both SOAPAction- and WSAddressing- based dispatching) to figure out which
- * operation a given message is for. Some notes on restrictions of "action"
- * - A null or empty action will be ignored
- * - An action that is a duplicate and references an idential operation is allowed
- * - An acton that is a duplicate and references a different operation is NOT allowed. In this
- * case, the action for the original operation is removed from the alias table, thus removing
- * the ability to route based on this action. This is necessary to prevent mis-directing
- * incoming message to the wrong operation based on SOAPAction.
- *
- * @param action the action key
- * @param axisOperation the operation to map to
- */
- public void mapActionToOperation(String action, AxisOperation axisOperation) {
- if (action == null || "".equals(action)) {
- if (log.isDebugEnabled()) {
- log.debug(
- "mapActionToOperation: A null or empty action cannot be used to map to an operation.");
- }
- return;
- }
- if (log.isDebugEnabled()) {
- log.debug("mapActionToOperation: Mapping Action to Operation: action: " + action +
- "; operation: " + axisOperation);
- }
-
- // First check if this action has already been flagged as invalid because it is a duplicate.
- if (invalidOperationsAliases.contains(action)) {
- // This SOAPAction has already been determined to be invalid; log a message
- // and do not add it to the operation alias map.
- if (log.isDebugEnabled()) {
- log.debug("mapActionToOperation: The action: " + action +
- " can not be used for operation: "
- + axisOperation + " with operation name: " + axisOperation.getName()
- + " because that SOAPAction is not unique for this service.");
- }
- return;
- }
-
- // Check if the action is currently mapping to an operation.
- AxisOperation currentlyMappedOperation = getOperationByAction(action);
- if (currentlyMappedOperation != null) {
- if (currentlyMappedOperation == axisOperation) {
- // This maps to the same operation, then it is already in the alias table, so
- // just silently ignore this mapping request.
- if (log.isDebugEnabled()) {
- log.debug(
- "mapActionToOperation: This operation is already mapped to this action: " +
- action + "; AxisOperation: "
- + currentlyMappedOperation + " named: " +
- currentlyMappedOperation.getName());
- }
- } else {
- // This action is already mapped, but it is to a different operation. Remove
- // the action mapping from the alias table and add it to the list of invalid mappings
- operationsAliasesMap.remove(action);
- invalidOperationsAliases.add(action);
- if (log.isDebugEnabled()) {
- log.debug(
- "mapActionToOperation: The action is already mapped to a different operation. The mapping of the action to any operations will be removed. Action: "
- + action + "; original operation: " + currentlyMappedOperation
- + " named " + currentlyMappedOperation.getName()
- + "; new operation: " + axisOperation
- + " named " + axisOperation.getName());
- }
- }
- } else {
- operationsAliasesMap.put(action, axisOperation);
- //Adding operation name to the mapping table
+ // to store the wsdl definition , which is build at the deployment time
+ // to keep the time that last update time of the service
+ private long lastupdate;
+ private HashMap moduleConfigmap;
+ private String name;
+ private ClassLoader serviceClassLoader;
+
+ //to keep the XMLScheam getting either from WSDL or java2wsdl
+ private ArrayList schemaList;
+ //private XmlSchema schema;
+
+ //wsdl is there for this service or not (in side META-INF)
+ private boolean wsdlFound = false;
+
+ //to store the scope of the service
+ private String scope;
+
+ //to store default message receivers
+ private HashMap messageReceivers;
+
+ // to set the handler chain available in phase info
+ private boolean useDefaultChains = true;
+
+ //to keep the status of the service , since service can stop at the run time
+ private boolean active = true;
+
+ private boolean elementFormDefault = true;
+
+ //to keep the service target name space
+ private String targetNamespace =
+ Java2WSDLConstants.DEFAULT_TARGET_NAMESPACE;
+ private String targetNamespacePrefix =
+ Java2WSDLConstants.TARGETNAMESPACE_PREFIX;
+
+ // to store the target namespace for the schema
+ private String schematargetNamespace;// = Java2WSDLConstants.AXIS2_XSD;
+ private String schematargetNamespacePrefix =
+ Java2WSDLConstants.SCHEMA_NAMESPACE_PRFIX;
+
+ private boolean enableAllTransports = true;
+ private List exposedTransports = new ArrayList();
+
+ //To keep reference to ServiceLifeCycle instance , if the user has
+ // specified in services.xml
+ private ServiceLifeCycle serviceLifeCycle;
+
+
+ /**
+ * Keeps track whether the schema locations are adjusted
+ */
+ private boolean schemaLocationsAdjusted = false;
+
+ /**
+ * A table that keeps a mapping of unique xsd names (Strings)
+ * against the schema objects. This is populated in the first
+ * instance the schemas are asked for and then used to serve
+ * the subsequent requests
+ */
+ private Map schemaMappingTable = null;
+
+
+ /**
+ * counter variable for naming the schemas
+ */
+ private int count = 0;
+ /**
+ * A custom schema Name prefix. if set this will be used to
+ * modify the schema names
+ */
+ private String customSchemaNamePrefix = null;
+
+ /**
+ * A custom schema name suffix. will be attached to the
+ * schema file name when the files are uniquely named.
+ * A good place to add a file extension if needed
+ */
+ private String customSchemaNameSuffix = null;
+ /////////////////////////////////////////
+ // WSDL related stuff ////////////////////
+ ////////////////////////////////////////
+ private NamespaceMap nameSpacesMap;
+
+ private String soapNsUri;
+ private String endpointName;
+ private String endpointURL;
+
+ // Flag representing whether WS-Addressing is required to use this service.
+ // Reflects the wsaw:UsingAddressing wsdl extension element
+ private String wsaddressingFlag = AddressingConstants.ADDRESSING_UNSPECIFIED;
+ private boolean clientSide = false;
+
+ //To keep a ref to ObjectSupplier instance
+ private ObjectSupplier objectSupplier;
+
+ // package to namespace mapping
+ private Map p2nMap;
+
+ private TypeTable typeTable;
+
+ // Data Locators for WS-Mex Support
+ private HashMap dataLocators;
+ private HashMap dataLocatorClassNames;
+ private AxisDataLocatorImpl defaultDataLocator;
+ // Define search sequence for datalocator based on Data Locator types.
+ LocatorType[] availableDataLocatorTypes = new LocatorType[]{LocatorType.SERVICE_DIALECT,
+ LocatorType.SERVICE_LEVEL, LocatorType.GLOBAL_DIALECT, LocatorType.GLOBAL_LEVEL,
+ LocatorType.DEFAULT_AXIS};
+
+ // name of the binding used : use in codegeneration
+ private String bindingName;
+
+ // names list keep to preserve the parameter order
+ private List operationsNameList;
+
+ private String[] eprs = null;
+
+ public AxisEndpoint getEndpoint(String key) {
+ return (AxisEndpoint) endpointMap.get(key);
+ }
+
+ public void addEndpoint(String key, AxisEndpoint axisEndpoint) {
+ this.endpointMap.put(key, axisEndpoint);
+ }
+
+ private boolean customWsdl = false;
+
+ public String getWSAddressingFlag() {
+ return wsaddressingFlag;
+ }
+
+ public void setWSAddressingFlag(String ar) {
+ wsaddressingFlag = ar;
+ if (wsaddressingFlag == null) {
+ wsaddressingFlag = AddressingConstants.ADDRESSING_UNSPECIFIED;
+ }
+ }
+
+ public boolean isSchemaLocationsAdjusted() {
+ return schemaLocationsAdjusted;
+ }
+
+ public void setSchemaLocationsAdjusted(boolean schemaLocationsAdjusted) {
+ this.schemaLocationsAdjusted = schemaLocationsAdjusted;
+ }
+
+ public Map getSchemaMappingTable() {
+ return schemaMappingTable;
+ }
+
+ public void setSchemaMappingTable(Map schemaMappingTable) {
+ this.schemaMappingTable = schemaMappingTable;
+ }
+
+ public String getCustomSchemaNamePrefix() {
+ return customSchemaNamePrefix;
+ }
+
+ public void setCustomSchemaNamePrefix(String customSchemaNamePrefix) {
+ this.customSchemaNamePrefix = customSchemaNamePrefix;
+ }
+
+ public String getCustomSchemaNameSuffix() {
+ return customSchemaNameSuffix;
+ }
+
+ public void setCustomSchemaNameSuffix(String customSchemaNameSuffix) {
+ this.customSchemaNameSuffix = customSchemaNameSuffix;
+ }
+
+ /**
+ * Constructor AxisService.
+ */
+ public AxisService() {
+ super();
+ this.operationsAliasesMap = new HashMap();
+ this.invalidOperationsAliases = new ArrayList();
+ moduleConfigmap = new HashMap();
+ //by default service scope is for the request
+ scope = Constants.SCOPE_REQUEST;
+ httpLocationDispatcherMap = new HashMap();
+ messageReceivers = new HashMap();
+ moduleRefs = new ArrayList();
+ schemaList = new ArrayList();
+ serviceClassLoader = (ClassLoader) org.apache.axis2.java.security.AccessController
+ .doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ });
+ objectSupplier = new DefaultObjectSupplier();
+ dataLocators = new HashMap();
+ dataLocatorClassNames = new HashMap();
+
+ }
+
+ /**
+ * @return name of the port type
+ * @deprecated use AxisService#getEndpointName() instead.
+ */
+ public String getPortTypeName() {
+ return endpointName;
+ }
+
+ /**
+ * @param portTypeName
+ * @deprecated use AxisService#setEndpointName() instead
+ */
+ public void setPortTypeName(String portTypeName) {
+ this.endpointName = portTypeName;
+ }
+
+ public String getBindingName() {
+ return bindingName;
+ }
+
+ public void setBindingName(String bindingName) {
+ this.bindingName = bindingName;
+ }
+
+ /**
+ * get the SOAPVersion
+ */
+ public String getSoapNsUri() {
+ return soapNsUri;
+ }
+
+ public void setSoapNsUri(String soapNsUri) {
+ this.soapNsUri = soapNsUri;
+ }
+
+ /**
+ * get the endpointName
+ */
+ public String getEndpointName() {
+ return endpointName;
+ }
+
+ public void setEndpointName(String endpoint) {
+ this.endpointName = endpoint;
+ }
+
+ /**
+ * Constructor AxisService.
+ */
+ public AxisService(String name) {
+ this();
+ this.name = name;
+ }
+
+ public void addMessageReceiver(String mepURI, MessageReceiver messageReceiver) {
+ if (WSDL2Constants.MEP_URI_IN_ONLY.equals(mepURI) ||
+ WSDLConstants.WSDL20_2006Constants.MEP_URI_IN_ONLY.equals(mepURI) ||
+ WSDLConstants.WSDL20_2004_Constants.MEP_URI_IN_ONLY.equals(mepURI)) {
+ messageReceivers
+ .put(WSDL2Constants.MEP_URI_IN_ONLY, messageReceiver);
+ messageReceivers
+ .put(WSDLConstants.WSDL20_2006Constants.MEP_URI_IN_ONLY, messageReceiver);
+ messageReceivers
+ .put(WSDLConstants.WSDL20_2004_Constants.MEP_URI_IN_ONLY, messageReceiver);
+ } else if (WSDL2Constants.MEP_URI_OUT_ONLY.equals(mepURI) ||
+ WSDLConstants.WSDL20_2006Constants.MEP_URI_OUT_ONLY.equals(mepURI) ||
+ WSDLConstants.WSDL20_2004_Constants.MEP_URI_OUT_ONLY.equals(mepURI)) {
+ messageReceivers
+ .put(WSDL2Constants.MEP_URI_OUT_ONLY, messageReceiver);
+ messageReceivers
+ .put(WSDLConstants.WSDL20_2006Constants.MEP_URI_OUT_ONLY, messageReceiver);
+ messageReceivers
+ .put(WSDLConstants.WSDL20_2004_Constants.MEP_URI_OUT_ONLY, messageReceiver);
+ } else if (WSDL2Constants.MEP_URI_IN_OUT.equals(mepURI) ||
+ WSDLConstants.WSDL20_2006Constants.MEP_URI_IN_OUT.equals(mepURI) ||
+ WSDLConstants.WSDL20_2004_Constants.MEP_URI_IN_OUT.equals(mepURI)) {
+ messageReceivers
+ .put(WSDL2Constants.MEP_URI_IN_OUT, messageReceiver);
+ messageReceivers
+ .put(WSDLConstants.WSDL20_2006Constants.MEP_URI_IN_OUT, messageReceiver);
+ messageReceivers
+ .put(WSDLConstants.WSDL20_2004_Constants.MEP_URI_IN_OUT, messageReceiver);
+ } else if (WSDL2Constants.MEP_URI_IN_OPTIONAL_OUT.equals(mepURI) ||
+ WSDLConstants.WSDL20_2006Constants.MEP_URI_IN_OPTIONAL_OUT.equals(mepURI) ||
+ WSDLConstants.WSDL20_2004_Constants.MEP_URI_IN_OPTIONAL_OUT.equals(mepURI)) {
+ messageReceivers.put(WSDL2Constants.MEP_URI_IN_OPTIONAL_OUT,
+ messageReceiver);
+ messageReceivers.put(WSDLConstants.WSDL20_2006Constants.MEP_URI_IN_OPTIONAL_OUT,
+ messageReceiver);
+ messageReceivers.put(WSDLConstants.WSDL20_2004_Constants.MEP_URI_IN_OPTIONAL_OUT,
+ messageReceiver);
+ } else if (WSDL2Constants.MEP_URI_OUT_IN.equals(mepURI) ||
+ WSDLConstants.WSDL20_2006Constants.MEP_URI_OUT_IN.equals(mepURI) ||
+ WSDLConstants.WSDL20_2004_Constants.MEP_URI_OUT_IN.equals(mepURI)) {
+ messageReceivers
+ .put(WSDL2Constants.MEP_URI_OUT_IN, messageReceiver);
+ messageReceivers
+ .put(WSDLConstants.WSDL20_2006Constants.MEP_URI_OUT_IN, messageReceiver);
+ messageReceivers
+ .put(WSDLConstants.WSDL20_2004_Constants.MEP_URI_OUT_IN, messageReceiver);
+ } else if (WSDL2Constants.MEP_URI_OUT_OPTIONAL_IN.equals(mepURI) ||
+ WSDLConstants.WSDL20_2006Constants.MEP_URI_OUT_OPTIONAL_IN.equals(mepURI) ||
+ WSDLConstants.WSDL20_2004_Constants.MEP_URI_OUT_OPTIONAL_IN.equals(mepURI)) {
+ messageReceivers.put(WSDL2Constants.MEP_URI_OUT_OPTIONAL_IN,
+ messageReceiver);
+ messageReceivers.put(WSDLConstants.WSDL20_2006Constants.MEP_URI_OUT_OPTIONAL_IN,
+ messageReceiver);
+ messageReceivers.put(WSDLConstants.WSDL20_2004_Constants.MEP_URI_OUT_OPTIONAL_IN,
+ messageReceiver);
+ } else if (WSDL2Constants.MEP_URI_ROBUST_OUT_ONLY.equals(mepURI) ||
+ WSDLConstants.WSDL20_2006Constants.MEP_URI_ROBUST_OUT_ONLY.equals(mepURI) ||
+ WSDLConstants.WSDL20_2004_Constants.MEP_URI_ROBUST_OUT_ONLY.equals(mepURI)) {
+ messageReceivers.put(WSDL2Constants.MEP_URI_ROBUST_OUT_ONLY,
+ messageReceiver);
+ messageReceivers.put(WSDLConstants.WSDL20_2006Constants.MEP_URI_ROBUST_OUT_ONLY,
+ messageReceiver);
+ messageReceivers.put(WSDLConstants.WSDL20_2004_Constants.MEP_URI_ROBUST_OUT_ONLY,
+ messageReceiver);
+ } else if (WSDL2Constants.MEP_URI_ROBUST_IN_ONLY.equals(mepURI) ||
+ WSDLConstants.WSDL20_2006Constants.MEP_URI_ROBUST_IN_ONLY.equals(mepURI) ||
+ WSDLConstants.WSDL20_2004_Constants.MEP_URI_ROBUST_IN_ONLY.equals(mepURI)) {
+ messageReceivers.put(WSDL2Constants.MEP_URI_ROBUST_IN_ONLY,
+ messageReceiver);
+ messageReceivers.put(WSDLConstants.WSDL20_2006Constants.MEP_URI_ROBUST_IN_ONLY,
+ messageReceiver);
+ messageReceivers.put(WSDLConstants.WSDL20_2004_Constants.MEP_URI_ROBUST_IN_ONLY,
+ messageReceiver);
+ } else {
+ messageReceivers.put(mepURI, messageReceiver);
+ }
+ }
+
+ public MessageReceiver getMessageReceiver(String mepURL) {
+ return (MessageReceiver) messageReceivers.get(mepURL);
+ }
+
+ /**
+ * Adds module configuration , if there is moduleConfig tag in service.
+ *
+ * @param moduleConfiguration
+ */
+ public void addModuleConfig(ModuleConfiguration moduleConfiguration) {
+ moduleConfigmap.put(moduleConfiguration.getModuleName(), moduleConfiguration);
+ }
+
+ /**
+ * Add any control operations defined by a Module to this service.
+ *
+ * @param module the AxisModule which has just been engaged
+ * @throws AxisFault if a problem occurs
+ */
+ void addModuleOperations(AxisModule module) throws AxisFault {
+ HashMap map = module.getOperations();
+ Collection col = map.values();
+ PhaseResolver phaseResolver = new PhaseResolver(getAxisConfiguration());
+ for (Iterator iterator = col.iterator(); iterator.hasNext();) {
+ AxisOperation axisOperation = copyOperation((AxisOperation) iterator.next());
+ if (this.getOperation(axisOperation.getName()) == null) {
+ ArrayList wsamappings = axisOperation.getWSAMappingList();
+ if (wsamappings != null) {
+ for (int j = 0, size = wsamappings.size(); j < size; j++) {
+ String mapping = (String) wsamappings.get(j);
+ mapActionToOperation(mapping, axisOperation);
+ }
+ }
+ // If we've set the "expose" parameter for this operation, it's normal (non-
+ // control) and therefore it will appear in generated WSDL. If we haven't,
+ // it's a control operation and will be ignored at WSDL-gen time.
+ if (axisOperation.isParameterTrue(DeploymentConstants.TAG_EXPOSE)) {
+ axisOperation.setControlOperation(false);
+ } else {
+ axisOperation.setControlOperation(true);
+ }
+
+ phaseResolver.engageModuleToOperation(axisOperation, module);
+
+ this.addOperation(axisOperation);
+ }
+ }
+ }
+
+ public void addModuleref(String moduleref) {
+ moduleRefs.add(moduleref);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.axis2.description.AxisService#addOperation(org.apache.axis2.description.AxisOperation)
+ */
+
+ /**
+ * Method addOperation.
+ *
+ * @param axisOperation
+ */
+ public void addOperation(AxisOperation axisOperation) {
+ axisOperation.setParent(this);
+
+ Iterator modules = getEngagedModules().iterator();
+
+ while (modules.hasNext()) {
+ AxisModule module = (AxisModule) modules.next();
+ try {
+ axisOperation.engageModule(module);
+ } catch (AxisFault axisFault) {
+ log.info(Messages.getMessage("modulealredyengagetoservice", module.getName()));
+ }
+ }
+ if (axisOperation.getMessageReceiver() == null) {
+ axisOperation.setMessageReceiver(
+ loadDefaultMessageReceiver(axisOperation.getMessageExchangePattern(), this));
+ }
+ if (axisOperation.getInputAction() == null) {
+ axisOperation.setSoapAction("urn:" + axisOperation.getName().getLocalPart());
+ }
+
+ if (axisOperation.getOutputAction() == null) {
+ axisOperation.setOutputAction("urn:" + axisOperation.getName().getLocalPart() +
+ Java2WSDLConstants.RESPONSE);
+ }
+ addChild(axisOperation);
+
+ String operationName = axisOperation.getName().getLocalPart();
+
+ /*
+ Some times name of the operation can be different from the name of the first child of the SOAPBody.
+ This will put the correct mapping associating that name with the operation. This will be useful especially for
+ the SOAPBodyBasedDispatcher
+ */
+
+ Iterator axisMessageIter = axisOperation.getChildren();
+
+ while (axisMessageIter.hasNext()) {
+ AxisMessage axisMessage = (AxisMessage) axisMessageIter.next();
+ String messageName = axisMessage.getName();
+ if (messageName != null && !messageName.equals(operationName)) {
+ mapActionToOperation(messageName, axisOperation);
+ }
+ }
+
+ mapActionToOperation(operationName, axisOperation);
+
+ String action = axisOperation.getInputAction();
+ if (action.length() > 0) {
+ mapActionToOperation(action, axisOperation);
+ }
+
+ ArrayList wsamappings = axisOperation.getWSAMappingList();
+ if (wsamappings != null) {
+ for (int j = 0, size = wsamappings.size(); j < size; j++) {
+ String mapping = (String) wsamappings.get(j);
+ mapActionToOperation(mapping, axisOperation);
+ }
+ }
+
+ if (axisOperation.getMessageReceiver() == null) {
+ axisOperation.setMessageReceiver(
+ loadDefaultMessageReceiver(
+ axisOperation.getMessageExchangePattern(), this));
+ }
+ }
+
+
+ private MessageReceiver loadDefaultMessageReceiver(String mepURL, AxisService service) {
+ MessageReceiver messageReceiver;
+ if (mepURL == null) {
+ mepURL = WSDL2Constants.MEP_URI_IN_OUT;
+ }
+ if (service != null) {
+ messageReceiver = service.getMessageReceiver(mepURL);
+ if (messageReceiver != null) {
+ return messageReceiver;
+ }
+ }
+ if (getParent() != null && getParent().getParent() != null) {
+ return ((AxisConfiguration) getParent().getParent()).getMessageReceiver(mepURL);
+ }
+ return null;
+ }
+
+
+ /**
+ * Gets a copy from module operation.
+ *
+ * @param axisOperation
+ * @return Returns AxisOperation.
+ * @throws AxisFault
+ */
+ private AxisOperation copyOperation(AxisOperation axisOperation) throws AxisFault {
+ AxisOperation operation =
+ AxisOperationFactory
+ .getOperationDescription(axisOperation.getMessageExchangePattern());
+
+ operation.setMessageReceiver(axisOperation.getMessageReceiver());
+ operation.setName(axisOperation.getName());
+
+ Iterator parameters = axisOperation.getParameters().iterator();
+
+ while (parameters.hasNext()) {
+ Parameter parameter = (Parameter) parameters.next();
+
+ operation.addParameter(parameter);
+ }
+
+ PolicyInclude policyInclude = new PolicyInclude(operation);
+ PolicyInclude axisOperationPolicyInclude = axisOperation.getPolicyInclude();
+
+ if (axisOperationPolicyInclude != null) {
+ Policy policy = axisOperationPolicyInclude.getPolicy();
+ if (policy != null) {
+ policyInclude.setPolicy(axisOperationPolicyInclude.getPolicy());
+ }
+ }
+ operation.setPolicyInclude(policyInclude);
+
+ operation.setWsamappingList(axisOperation.getWSAMappingList());
+ operation.setRemainingPhasesInFlow(axisOperation.getRemainingPhasesInFlow());
+ operation.setPhasesInFaultFlow(axisOperation.getPhasesInFaultFlow());
+ operation.setPhasesOutFaultFlow(axisOperation.getPhasesOutFaultFlow());
+ operation.setPhasesOutFlow(axisOperation.getPhasesOutFlow());
+
+ operation.setOutputAction(axisOperation.getOutputAction());
+ String[] faultActionNames = axisOperation.getFaultActionNames();
+ for (int i = 0; i < faultActionNames.length; i++) {
+ operation.addFaultAction(faultActionNames[i],
+ axisOperation.getFaultAction(faultActionNames[i]));
+ }
+
+ return operation;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.axis2.description.AxisService#addToengagedModules(javax.xml.namespace.QName)
+ */
+
+ /**
+ * Engages a module. It is required to use this method.
+ *
+ * @param axisModule
+ * @param engager
+ */
+ public void onEngage(AxisModule axisModule, AxisDescription engager)
+ throws AxisFault {
+ // adding module operations
+ addModuleOperations(axisModule);
+
+ Iterator operations = getOperations();
+ while (operations.hasNext()) {
+ AxisOperation axisOperation = (AxisOperation) operations.next();
+ axisOperation.engageModule(axisModule, engager);
+ }
+ }
+
+ /**
+ * Maps an action (a SOAPAction or WSA action) to the given operation. This is used by
+ * dispatching (both SOAPAction- and WSAddressing- based dispatching) to figure out which
+ * operation a given message is for. Some notes on restrictions of "action"
+ * - A null or empty action will be ignored
+ * - An action that is a duplicate and references an idential operation is allowed
+ * - An acton that is a duplicate and references a different operation is NOT allowed. In this
+ * case, the action for the original operation is removed from the alias table, thus removing
+ * the ability to route based on this action. This is necessary to prevent mis-directing
+ * incoming message to the wrong operation based on SOAPAction.
+ *
+ * @param action the action key
+ * @param axisOperation the operation to map to
+ */
+ public void mapActionToOperation(String action, AxisOperation axisOperation) {
+ if (action == null || "".equals(action)) {
+ if (log.isDebugEnabled()) {
+ log.debug(
+ "mapActionToOperation: A null or empty action cannot be used to map to an operation.");
+ }
+ return;
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("mapActionToOperation: Mapping Action to Operation: action: " + action +
+ "; operation: " + axisOperation);
+ }
+
+ // First check if this action has already been flagged as invalid because it is a duplicate.
+ if (invalidOperationsAliases.contains(action)) {
+ // This SOAPAction has already been determined to be invalid; log a message
+ // and do not add it to the operation alias map.
+ if (log.isDebugEnabled()) {
+ log.debug("mapActionToOperation: The action: " + action +
+ " can not be used for operation: "
+ + axisOperation + " with operation name: " + axisOperation.getName()
+ + " because that SOAPAction is not unique for this service.");
+ }
+ return;
+ }
+
+ // Check if the action is currently mapping to an operation.
+ AxisOperation currentlyMappedOperation = getOperationByAction(action);
+ if (currentlyMappedOperation != null) {
+ if (currentlyMappedOperation == axisOperation) {
+ // This maps to the same operation, then it is already in the alias table, so
+ // just silently ignore this mapping request.
+ if (log.isDebugEnabled()) {
+ log.debug(
+ "mapActionToOperation: This operation is already mapped to this action: " +
+ action + "; AxisOperation: "
+ + currentlyMappedOperation + " named: " +
+ currentlyMappedOperation.getName());
+ }
+ } else {
+ // This action is already mapped, but it is to a different operation. Remove
+ // the action mapping from the alias table and add it to the list of invalid mappings
+ operationsAliasesMap.remove(action);
+ invalidOperationsAliases.add(action);
+ if (log.isDebugEnabled()) {
+ log.debug(
+ "mapActionToOperation: The action is already mapped to a different operation. The mapping of the action to any operations will be removed. Action: "
+ + action + "; original operation: " + currentlyMappedOperation
+ + " named " + currentlyMappedOperation.getName()
+ + "; new operation: " + axisOperation
+ + " named " + axisOperation.getName());
+ }
+ }
+ } else {
+ operationsAliasesMap.put(action, axisOperation);
+ //Adding operation name to the mapping table
// operationsAliasesMap.put(axisOperation.getName().getLocalPart(), axisOperation);
- }
- }
+ }
+ }
- /**
- * Maps an constant string in the whttp:location to the given operation. This is used by
- * RequestURIOperationDispatcher based dispatching to figure out which operation it is that a
- * given message is for.
- *
- * @param string the constant drawn from whttp:location
- * @param axisOperation the operation to map to
- */
- public void addHttpLocationDispatcherString(String string, AxisOperation axisOperation) {
- httpLocationDispatcherMap.put(string, axisOperation);
- }
-
- public void printSchema(OutputStream out) throws AxisFault {
- for (int i = 0; i < schemaList.size(); i++) {
- XmlSchema schema = addNameSpaces(i);
- schema.write(out);
- }
- }
-
- public XmlSchema getSchema(int index) {
- return addNameSpaces(index);
- }
-
-
- /**
- * Release the list of schema objects.
- * <P>
- * In some environments, this can provide significant relief
- * of memory consumption in the java heap, as long as the
- * need for the schema list has completed.
- */
- public void releaseSchemaList() {
- if (schemaList != null) {
- // release the schema list
- schemaList.clear();
- }
-
- if (log.isDebugEnabled()) {
- log.debug("releaseSchemaList: schema list has been released.");
- }
- }
-
- private XmlSchema addNameSpaces(int i) {
- XmlSchema schema = (XmlSchema) schemaList.get(i);
- NamespaceMap map = (NamespaceMap) nameSpacesMap.clone();
- NamespacePrefixList namespaceContext = schema.getNamespaceContext();
- String prefixes[] = namespaceContext.getDeclaredPrefixes();
- for (int j = 0; j < prefixes.length; j++) {
- String prefix = prefixes[j];
- map.add(prefix, namespaceContext.getNamespaceURI(prefix));
- }
- schema.setNamespaceContext(map);
- return schema;
- }
-
- public void setEPRs(String[] eprs) {
- this.eprs = eprs;
- }
-
- public String[] getEPRs() throws AxisFault {
- if(eprs != null) {
- return eprs;
- }
- String requestIP;
- try {
- requestIP = HttpUtils.getIpAddress(getAxisConfiguration());
- } catch (SocketException e) {
- throw new AxisFault("Cannot get local IP address", e);
- }
- eprs = getEPRs(requestIP);
- return eprs;
- }
-
- private String[] getEPRs(String requestIP) {
- AxisConfiguration axisConfig = getAxisConfiguration();
- if (axisConfig == null) {
- return null;
- }
- ArrayList eprList = new ArrayList();
- if (enableAllTransports) {
- Iterator transports = axisConfig.getTransportsIn().values().iterator();
- while (transports.hasNext()) {
- TransportInDescription transportIn = (TransportInDescription) transports.next();
- TransportListener listener = transportIn.getReceiver();
- if (listener != null) {
- try {
- EndpointReference[] eprsForService =
- listener.getEPRsForService(this.name, requestIP);
- if (eprsForService != null) {
- for (int i = 0; i < eprsForService.length; i++) {
- EndpointReference endpointReference = eprsForService[i];
- String address = endpointReference.getAddress();
- if (address != null) {
- eprList.add(address);
- }
- }
- }
- } catch (AxisFault axisFault) {
- log.warn(axisFault.getMessage());
- }
- }
- }
- } else {
- List trs = this.exposedTransports;
- for (int i = 0; i < trs.size(); i++) {
- String trsName = (String) trs.get(i);
- TransportInDescription transportIn = axisConfig.getTransportIn(trsName);
- if (transportIn != null) {
- TransportListener listener = transportIn.getReceiver();
- if (listener != null) {
- try {
- EndpointReference[] eprsForService =
- listener.getEPRsForService(this.name, requestIP);
- if (eprsForService != null) {
- for (int j = 0; j < eprsForService.length; j++) {
- EndpointReference endpointReference = eprsForService[j];
- String address = endpointReference.getAddress();
- if (address != null) {
- eprList.add(address);
- }
- }
- }
- } catch (AxisFault axisFault) {
- log.warn(axisFault.getMessage());
- }
- }
- }
- }
- }
- return (String[]) eprList.toArray(new String[eprList.size()]);
- }
-
- private void printUserWSDL(OutputStream out) throws AxisFault {
- Parameter wsld4jdefinition = getParameter(WSDLConstants.WSDL_4_J_DEFINITION);
- if (wsld4jdefinition != null) {
- try {
- Definition definition = (Definition) wsld4jdefinition.getValue();
- if (isModifyUserWSDLPortAddress()) {
- setPortAddress(definition);
- }
- WSDLWriter writer = WSDLFactory.newInstance().newWSDLWriter();
- writer.writeWSDL(definition, out);
- } catch (WSDLException e) {
- throw AxisFault.makeFault(e);
- }
- } else {
- printWSDLError(out);
- }
- }
-
- /**
- * @param out
- * @param requestIP
- * @throws AxisFault
- */
- public void printWSDL(OutputStream out, String requestIP) throws AxisFault {
- if (isUseUserWSDL()) {
- printUserWSDL(out);
- } else {
- String[] eprArray = getEPRs(requestIP);
- getWSDL(out, eprArray);
- }
- }
-
- /**
- * Print the WSDL with a default URL. This will be called only during codegen time.
- *
- * @param out
- * @throws AxisFault
- */
- public void printWSDL(OutputStream out) throws AxisFault {
- if (isUseUserWSDL()) {
- printUserWSDL(out);
- } else {
- setWsdlFound(true);
- //pick the endpointName and take it as the epr for the WSDL
- getWSDL(out, new String[]{this.endpointName});
- }
- }
-
- private void setPortAddress(Definition definition) throws AxisFault {
- setPortAddress(definition, null);
- }
-
- private void setPortAddress(Definition definition, String requestIP) throws AxisFault {
- Iterator serviceItr = definition.getServices().values().iterator();
- while (serviceItr.hasNext()) {
- Service serviceElement = (Service) serviceItr.next();
- Iterator portItr = serviceElement.getPorts().values().iterator();
- while (portItr.hasNext()) {
- Port port = (Port) portItr.next();
- List list = port.getExtensibilityElements();
- for (int i = 0; i < list.size(); i++) {
- Object extensibilityEle = list.get(i);
- if (extensibilityEle instanceof SOAPAddress) {
- if (requestIP == null) {
- ((SOAPAddress) extensibilityEle).setLocationURI(getEPRs()[0]);
- } else {
- ((SOAPAddress) extensibilityEle).setLocationURI(getEPRs(requestIP)[0]);
- }
- }
- }
- }
- }
- }
-
- private void getWSDL(OutputStream out, String[] serviceURL) throws AxisFault {
- // Retrieve WSDL using the same data retrieval path for GetMetadata request.
- DataRetrievalRequest request = new DataRetrievalRequest();
- request.putDialect(DRConstants.SPEC.DIALECT_TYPE_WSDL);
- request.putOutputForm(OutputForm.INLINE_FORM);
-
- MessageContext context = new MessageContext();
- context.setAxisService(this);
- context.setTo(new EndpointReference(serviceURL[0]));
-
- Data[] result = getData(request, context);
- OMElement wsdlElement;
- if (result != null && result.length > 0) {
- wsdlElement = (OMElement) (result[0].getData());
- try {
- wsdlElement.serialize(out);
- out.flush();
- out.close();
- } catch (Exception e) {
- throw AxisFault.makeFault(e);
- }
- }
- }
-
- private void printWSDLError(OutputStream out) throws AxisFault {
- try {
- String wsdlntfound = "<error>" +
- "<description>Unable to generate WSDL 1.1 for this service</description>" +
- "<reason>If you wish Axis2 to automatically generate the WSDL 1.1, then please +" +
- "set useOriginalwsdl as false in your services.xml</reason>" +
- "</error>";
- out.write(wsdlntfound.getBytes());
- out.flush();
- out.close();
- } catch (IOException e) {
- throw AxisFault.makeFault(e);
- }
- }
-
- //WSDL 2.0
- public void printWSDL2(OutputStream out) throws AxisFault {
- AxisService2WSDL20 axisService2WSDL2 = new AxisService2WSDL20(this);
- try {
- OMElement wsdlElement = axisService2WSDL2.generateOM();
- wsdlElement.serialize(out);
- out.flush();
- out.close();
- } catch (Exception e) {
- throw AxisFault.makeFault(e);
- }
- }
-
- /**
- * Gets the description about the service which is specified in services.xml.
- * @deprecated Use getDocumentation() instead
- * @return Returns String.
- */
- public String getServiceDescription() {
- return getDocumentation();
- }
-
- /**
- * Method getClassLoader.
- *
- * @return Returns ClassLoader.
- */
- public ClassLoader getClassLoader() {
- return this.serviceClassLoader;
- }
-
- /**
- * Gets the control operation which are added by module like RM.
- */
- public ArrayList getControlOperations() {
- Iterator op_itr = getOperations();
- ArrayList operationList = new ArrayList();
-
- while (op_itr.hasNext()) {
- AxisOperation operation = (AxisOperation) op_itr.next();
-
- if (operation.isControlOperation()) {
- operationList.add(operation);
- }
- }
-
- return operationList;
- }
-
- public URL getFileName() {
- return fileName;
- }
-
- public long getLastupdate() {
- return lastupdate;
- }
-
- public ModuleConfiguration getModuleConfig(String moduleName) {
- return (ModuleConfiguration) moduleConfigmap.get(moduleName);
- }
-
- public ArrayList getModules() {
- return moduleRefs;
- }
-
- public String getName() {
- return name;
- }
-
- /**
- * Method getOperation.
- *
- * @param operationName
- * @return Returns AxisOperation.
- */
- public AxisOperation getOperation(QName operationName) {
- AxisOperation axisOperation = (AxisOperation) getChild(operationName);
- if(axisOperation==null){
- axisOperation = (AxisOperation) getChild(
- new QName(getTargetNamespace(),operationName.getLocalPart()));
- }
- if (axisOperation == null) {
- axisOperation = (AxisOperation) operationsAliasesMap.get(
- operationName.getLocalPart());
- }
-
- return axisOperation;
- }
-
-
- /**
- * Returns the AxisOperation which has been mapped to the given action.
- *
- * @param action the action key
- * @return Returns the corresponding AxisOperation or null if it isn't found.
- */
- public AxisOperation getOperationByAction(String action) {
- return (AxisOperation) operationsAliasesMap.get(action);
- }
-
- /**
- * Returns the operation given a SOAP Action. This
- * method should be called if only one Endpoint is defined for
- * this Service. If more than one Endpoint exists, one of them will be
- * picked. If more than one Operation is found with the given SOAP Action;
- * null will be returned. If no particular Operation is found with the given
- * SOAP Action; null will be returned.
- *
- * @param soapAction SOAP Action defined for the particular Operation
- * @return Returns an AxisOperation if a unique Operation can be found with the given
- * SOAP Action otherwise will return null.
- */
- public AxisOperation getOperationBySOAPAction(String soapAction) {
- if ((soapAction == null) || soapAction.length() == 0) {
- return null;
- }
-
- AxisOperation operation = (AxisOperation) getChild(new QName(soapAction));
-
- if (operation != null) {
- return operation;
- }
-
- operation = (AxisOperation) operationsAliasesMap.get(soapAction);
-
- return operation;
- }
-
- /**
- * Method getOperations.
- *
- * @return Returns HashMap
- */
- public Iterator getOperations() {
- return getChildren();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.axis2.description.ParameterInclude#getParameter(java.lang.String)
- */
-
- /**
- * Gets only the published operations.
- */
- public ArrayList getPublishedOperations() {
- Iterator op_itr = getOperations();
- ArrayList operationList = new ArrayList();
-
- while (op_itr.hasNext()) {
- AxisOperation operation = (AxisOperation) op_itr.next();
-
- if (!operation.isControlOperation()) {
- operationList.add(operation);
- }
- }
-
- return operationList;
- }
-
- /**
- * Sets the description about the service which is specified in services.xml
- * @deprecated Use setDocumentation() instead
- * @param documentation
- */
- public void setServiceDescription(String documentation) {
- setDocumentation(documentation);
- }
-
- /**
- * Method setClassLoader.
- *
- * @param classLoader
- */
- public void setClassLoader(ClassLoader classLoader) {
- this.serviceClassLoader = classLoader;
- }
-
- public void setFileName(URL fileName) {
- this.fileName = fileName;
- }
-
- /**
- * Sets the current time as last update time of the service.
- */
- public void setLastupdate() {
- lastupdate = new Date().getTime();
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public ArrayList getSchema() {
- return schemaList;
- }
-
- public void addSchema(XmlSchema schema) {
- if (schema != null) {
- schemaList.add(schema);
- if (schema.getTargetNamespace() != null) {
- addSchemaNameSpace(schema);
- }
- }
- }
-
- public void addSchema(Collection schemas) {
- Iterator iterator = schemas.iterator();
- while (iterator.hasNext()) {
- XmlSchema schema = (XmlSchema) iterator.next();
- schemaList.add(schema);
- addSchemaNameSpace(schema);
- }
- }
-
- public boolean isWsdlFound() {
- return wsdlFound;
- }
-
- public void setWsdlFound(boolean wsdlFound) {
- this.wsdlFound = wsdlFound;
- }
-
- public String getScope() {
- return scope;
- }
-
- /**
- * @param scope - Available scopes :
- * Constants.SCOPE_APPLICATION
- * Constants.SCOPE_TRANSPORT_SESSION
- * Constants.SCOPE_SOAP_SESSION
- * Constants.SCOPE_REQUEST.equals
- */
- public void setScope(String scope) {
- if (Constants.SCOPE_APPLICATION.equals(scope) ||
- Constants.SCOPE_TRANSPORT_SESSION.equals(scope) ||
- Constants.SCOPE_SOAP_SESSION.equals(scope) ||
- Constants.SCOPE_REQUEST.equals(scope)) {
- this.scope = scope;
- }
- }
-
- public boolean isUseDefaultChains() {
- return useDefaultChains;
- }
-
- public void setUseDefaultChains(boolean useDefaultChains) {
- this.useDefaultChains = useDefaultChains;
- }
-
- public Object getKey() {
- return this.name;
- }
-
- public boolean isActive() {
- return active;
- }
-
- public void setActive(boolean active) {
- this.active = active;
- }
-
- public String getSchematargetNamespace() {
- return schematargetNamespace;
- }
-
- public void setSchemaTargetNamespace(String schematargetNamespace) {
- this.schematargetNamespace = schematargetNamespace;
- }
-
- public String getSchemaTargetNamespacePrefix() {
- return schematargetNamespacePrefix;
- }
-
- public void setSchematargetNamespacePrefix(String schematargetNamespacePrefix) {
- this.schematargetNamespacePrefix = schematargetNamespacePrefix;
- }
-
- public String getTargetNamespace() {
- return targetNamespace;
- }
-
- public void setTargetNamespace(String targetNamespace) {
- this.targetNamespace = targetNamespace;
- }
-
- public String getTargetNamespacePrefix() {
- return targetNamespacePrefix;
- }
-
- public void setTargetNamespacePrefix(String targetNamespacePrefix) {
- this.targetNamespacePrefix = targetNamespacePrefix;
- }
-
- public XmlSchemaElement getSchemaElement(QName elementQName) {
- XmlSchemaElement element;
- for (int i = 0; i < schemaList.size(); i++) {
- XmlSchema schema = (XmlSchema) schemaList.get(i);
- if (schema != null) {
- element = schema.getElementByName(elementQName);
- if (element != null) {
- return element;
- }
- }
- }
- return null;
- }
-
- public boolean isEnableAllTransports() {
- return enableAllTransports;
- }
-
- /**
- * To eneble service to be expose in all the transport
- *
- * @param enableAllTransports
- */
- public void setEnableAllTransports(boolean enableAllTransports) {
- this.enableAllTransports = enableAllTransports;
- }
-
- public List getExposedTransports() {
- return this.exposedTransports;
- }
-
- public void setExposedTransports(List transports) {
- enableAllTransports = false;
- this.exposedTransports = transports;
- }
-
- public void addExposedTransport(String transport) {
- enableAllTransports = false;
- if (!this.exposedTransports.contains(transport)) {
- this.exposedTransports.add(transport);
- }
- }
-
- public void removeExposedTransport(String transport) {
- enableAllTransports = false;
- this.exposedTransports.remove(transport);
- }
-
- public boolean isExposedTransport(String transport) {
- return exposedTransports.contains(transport);
- }
-
- public void onDisengage(AxisModule module) throws AxisFault {
- Iterator operations = getChildren();
- while (operations.hasNext()) {
- AxisOperation axisOperation = (AxisOperation) operations.next();
- axisOperation.disengageModule(module);
- }
- removeModuleOperations(module);
- AxisConfiguration config = getAxisConfiguration();
- if (!config.isEngaged(module.getName())) {
- PhaseResolver phaseResolver = new PhaseResolver(config);
- phaseResolver.disengageModuleFromGlobalChains(module);
- }
- }
-
- /**
- * Remove any operations which were added by a given module.
- *
- * @param module the module in question
- */
- private void removeModuleOperations(AxisModule module) {
- HashMap moduleOerations = module.getOperations();
- if (moduleOerations != null) {
- Iterator moduleOperations_itr = moduleOerations.values().iterator();
- while (moduleOperations_itr.hasNext()) {
- AxisOperation operation = (AxisOperation) moduleOperations_itr.next();
- removeOperation(operation.getName());
- }
- }
- }
-
- //#######################################################################################
- // APIs to create AxisService
-
- //
-
- /**
- * To create a AxisService for a given WSDL and the created client is most suitable for client side
- * invocation not for server side invocation. Since all the soap action and wsa action is added to
- * operations
- *
- * @param wsdlURL location of the WSDL
- * @param wsdlServiceName name of the service to be invoke , if it is null then the first one will
- * be selected if there are more than one
- * @param portName name of the port , if there are more than one , if it is null then the
- * first one in the iterator will be selected
- * @param options Service client options, to set the target EPR
- * @return AxisService , the created service will be return
- */
- public static AxisService createClientSideAxisService(URL wsdlURL,
- QName wsdlServiceName,
- String portName,
- Options options) throws AxisFault {
- try {
- InputStream in = wsdlURL.openConnection().getInputStream();
- Document doc = XMLUtils.newDocument(in);
- WSDLReader reader = WSDLFactory.newInstance().newWSDLReader();
- reader.setFeature("javax.wsdl.importDocuments", true);
- Definition wsdlDefinition = reader.readWSDL(null, doc);
- return createClientSideAxisService(wsdlDefinition, wsdlServiceName, portName, options);
- } catch (IOException e) {
- log.error(e);
- throw AxisFault.makeFault(e);
- } catch (ParserConfigurationException e) {
- log.error(e);
- throw AxisFault.makeFault(e);
- } catch (SAXException e) {
- log.error(e);
- throw AxisFault.makeFault(e);
- } catch (WSDLException e) {
- log.error(e);
- throw AxisFault.makeFault(e);
- }
- }
-
- public static AxisService createClientSideAxisService(Definition wsdlDefinition,
- QName wsdlServiceName,
- String portName,
- Options options) throws AxisFault {
- WSDL11ToAxisServiceBuilder serviceBuilder =
- new WSDL11ToAxisServiceBuilder(wsdlDefinition, wsdlServiceName, portName);
- serviceBuilder.setServerSide(false);
- AxisService axisService = serviceBuilder.populateService();
- AxisEndpoint axisEndpoint = (AxisEndpoint) axisService.getEndpoints()
- .get(axisService.getEndpointName());
- options.setTo(new EndpointReference(axisEndpoint.getEndpointURL()));
- if (axisEndpoint != null) {
- options.setSoapVersionURI((String) axisEndpoint.getBinding()
- .getProperty(WSDL2Constants.ATTR_WSOAP_VERSION));
- }
- return axisService;
- }
-
- /**
- * To create an AxisService using given service impl class name
- * first generate schema corresponding to the given java class , next for each methods AxisOperation
- * will be created. If the method is in-out it will uses RPCMessageReceiver else
- * RPCInOnlyMessageReceiver
- * <p/>
- * Note : Inorder to work this properly RPCMessageReceiver should be available in the class path
- * otherewise operation can not continue
- *
- * @param implClass Service implementation class
- * @param axisConfig Current AxisConfiguration
- * @return return created AxisSrevice the creted service , it can either be null or valid service
- */
- public static AxisService createService(String implClass,
- AxisConfiguration axisConfig) throws AxisFault {
-
- try {
- HashMap messageReciverMap = new HashMap();
- Class inOnlyMessageReceiver = Loader.loadClass(
- "org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver");
- MessageReceiver messageReceiver =
- (MessageReceiver) inOnlyMessageReceiver.newInstance();
- messageReciverMap.put(
- WSDL2Constants.MEP_URI_IN_ONLY,
- messageReceiver);
- messageReciverMap.put(WSDL2Constants.MEP_URI_ROBUST_IN_ONLY,messageReceiver);
- Class inoutMessageReceiver = Loader.loadClass(
- "org.apache.axis2.rpc.receivers.RPCMessageReceiver");
- MessageReceiver inOutmessageReceiver =
- (MessageReceiver) inoutMessageReceiver.newInstance();
- messageReciverMap.put(
- WSDL2Constants.MEP_URI_IN_OUT,
- inOutmessageReceiver);
-
- return createService(implClass,
- axisConfig,
- messageReciverMap,
- null,
- null,
- axisConfig.getSystemClassLoader());
- } catch (Exception e) {
- throw AxisFault.makeFault(e);
- }
- }
-
- /**
- * messageReceiverClassMap will hold the MessageReceivers for given meps. Key will be the
- * mep and value will be the instance of the MessageReceiver class.
- * Ex:
- * Map mrMap = new HashMap();
- * mrMap.put("http://www.w3.org/2004/08/wsdl/in-only",
- * RPCInOnlyMessageReceiver.class.newInstance());
- * mrMap.put("http://www.w3.org/2004/08/wsdl/in-out",
- * RPCMessageReceiver.class.newInstance());
- *
- * @param implClass
- * @param axisConfiguration
- * @param messageReceiverClassMap
- * @param targetNamespace
- * @param schemaNamespace
- * @throws AxisFault
- */
- public static AxisService createService(String implClass,
- AxisConfiguration axisConfiguration,
- Map messageReceiverClassMap,
- String targetNamespace,
- String schemaNamespace,
- ClassLoader loader) throws AxisFault {
- int index = implClass.lastIndexOf(".");
- String serviceName;
- if (index > 0) {
- serviceName = implClass.substring(index + 1, implClass.length());
- } else {
- serviceName = implClass;
- }
-
- SchemaGenerator schemaGenerator;
- ArrayList excludeOpeartion = new ArrayList();
- AxisService service = new AxisService();
- service.setParent(axisConfiguration);
- service.setName(serviceName);
-
- try {
- Parameter generateBare = service.getParameter(Java2WSDLConstants.DOC_LIT_BARE_PARAMETER);
- if (generateBare!=null && "true".equals(generateBare.getValue())) {
- schemaGenerator = new DocLitBareSchemaGenerator(loader,
- implClass, schemaNamespace,
- Java2WSDLConstants.SCHEMA_NAMESPACE_PRFIX,service);
- } else {
- schemaGenerator = new DefaultSchemaGenerator(loader,
- implClass, schemaNamespace,
- Java2WSDLConstants.SCHEMA_NAMESPACE_PRFIX,service);
- }
- schemaGenerator.setElementFormDefault(Java2WSDLConstants.FORM_DEFAULT_UNQUALIFIED);
- Utils.addExcludeMethods(excludeOpeartion);
- schemaGenerator.setExcludeMethods(excludeOpeartion);
- } catch (Exception e) {
- throw AxisFault.makeFault(e);
- }
-
- return createService(implClass,
- serviceName,
- axisConfiguration,
- messageReceiverClassMap,
- targetNamespace,
- loader,
- schemaGenerator,service);
- }
- /**
- * messageReceiverClassMap will hold the MessageReceivers for given meps. Key will be the
- * mep and value will be the instance of the MessageReceiver class.
- * Ex:
- * Map mrMap = new HashMap();
- * mrMap.put("http://www.w3.org/2004/08/wsdl/in-only",
- * RPCInOnlyMessageReceiver.class.newInstance());
- * mrMap.put("http://www.w3.org/2004/08/wsdl/in-out",
- * RPCMessageReceiver.class.newInstance());
- *
- * @param implClass
- * @param axisConfiguration
- * @param messageReceiverClassMap
- * @param targetNamespace
- * @throws AxisFault
- */
- public static AxisService createService(String implClass,
- String serviceName,
- AxisConfiguration axisConfiguration,
- Map messageReceiverClassMap,
- String targetNamespace,
- ClassLoader loader,
- SchemaGenerator schemaGenerator,
- AxisService axisService) throws AxisFault {
- Parameter parameter = new Parameter(Constants.SERVICE_CLASS, implClass);
- OMElement paraElement = Utils.getParameter(Constants.SERVICE_CLASS, implClass, false);
- parameter.setParameterElement(paraElement);
- axisService.setUseDefaultChains(false);
- axisService.addParameter(parameter);
- axisService.setName(serviceName);
- axisService.setClassLoader(loader);
-
- NamespaceMap map = new NamespaceMap();
- map.put(Java2WSDLConstants.AXIS2_NAMESPACE_PREFIX,
- Java2WSDLConstants.AXIS2_XSD);
- map.put(Java2WSDLConstants.DEFAULT_SCHEMA_NAMESPACE_PREFIX,
- Java2WSDLConstants.URI_2001_SCHEMA_XSD);
- axisService.setNameSpacesMap(map);
- axisService.setElementFormDefault(false);
- try {
- axisService.addSchema(schemaGenerator.generateSchema());
- } catch (Exception e) {
- throw AxisFault.makeFault(e);
- }
- axisService.setSchemaTargetNamespace(schemaGenerator.getSchemaTargetNameSpace());
- axisService.setTypeTable(schemaGenerator.getTypeTable());
- if (targetNamespace == null) {
- targetNamespace = schemaGenerator.getSchemaTargetNameSpace();
- }
- if (targetNamespace != null && !"".equals(targetNamespace)) {
- axisService.setTargetNamespace(targetNamespace);
- }
- JMethod[] method = schemaGenerator.getMethods();
- PhasesInfo pinfo = axisConfiguration.getPhasesInfo();
- for (int i = 0; i < method.length; i++) {
- JMethod jmethod = method[i];
- AxisOperation operation =axisService.getOperation(new QName(jmethod.getSimpleName()));
- String mep = operation.getMessageExchangePattern();
- MessageReceiver mr;
- if (messageReceiverClassMap != null) {
-
- if (messageReceiverClassMap.get(mep) != null) {
- Object obj = messageReceiverClassMap.get(mep);
- if (obj instanceof MessageReceiver) {
- mr = (MessageReceiver) obj;
- operation.setMessageReceiver(mr);
- } else {
- log.error(
- "Object is not an instance of MessageReceiver, thus, default MessageReceiver has been set");
- mr = axisConfiguration
- .getMessageReceiver(operation.getMessageExchangePattern());
- operation.setMessageReceiver(mr);
- }
- } else {
- log.error(
- "Required MessageReceiver couldn't be found, thus, default MessageReceiver has been used");
- mr = axisConfiguration
- .getMessageReceiver(operation.getMessageExchangePattern());
- operation.setMessageReceiver(mr);
- }
- } else {
- log.error(
- "MessageRecevierClassMap couldn't be found, thus, default MessageReceiver has been used");
- mr = axisConfiguration.getMessageReceiver(operation.getMessageExchangePattern());
- operation.setMessageReceiver(mr);
- }
- pinfo.setOperationPhases(operation);
- axisService.addOperation(operation);
- }
- return axisService;
-
- }
-
- public void removeOperation(QName opName) {
- AxisOperation operation = getOperation(opName);
- if (operation != null) {
- removeChild(opName);
- ArrayList mappingList = operation.getWSAMappingList();
- if (mappingList != null) {
- for (int i = 0; i < mappingList.size(); i++) {
- String actionMapping = (String) mappingList.get(i);
- operationsAliasesMap.remove(actionMapping);
- }
- }
- operationsAliasesMap.remove(operation.getName().getLocalPart());
- }
- }
-
- public Map getNameSpacesMap() {
- return nameSpacesMap;
- }
-
- public void setNameSpacesMap(NamespaceMap nameSpacesMap) {
- this.nameSpacesMap = nameSpacesMap;
- }
-
- private void addSchemaNameSpace(XmlSchema schema) {
- String targetNameSpace = schema.getTargetNamespace();
- String prefix = schema.getNamespaceContext().getPrefix(targetNameSpace);
-
- boolean found = false;
- if (nameSpacesMap != null && nameSpacesMap.size() > 0) {
- Iterator itr = nameSpacesMap.values().iterator();
- Set keys = nameSpacesMap.keySet();
- while (itr.hasNext()) {
- String value = (String) itr.next();
- if (value.equals(targetNameSpace) && keys.contains(prefix)) {
- found = true;
- }
- }
- }
- if (nameSpacesMap == null) {
- nameSpacesMap = new NamespaceMap();
- }
- if (!found) {
- nameSpacesMap.put("ns" + nsCount, targetNameSpace);
- nsCount++;
- }
- }
-
- /**
- * runs the schema mappings if it has not been run previously
- * it is best that this logic be in the axis service since one can
- * call the axis service to populate the schema mappings
- */
- public Map populateSchemaMappings() {
-
- //populate the axis service with the necessary schema references
- ArrayList schema = this.schemaList;
- Map changedScheamLocations = null;
- if (!this.schemaLocationsAdjusted) {
- Hashtable nameTable = new Hashtable();
- //calculate unique names for the schemas
- calcualteSchemaNames(schema, nameTable);
- //adjust the schema locations as per the calculated names
- changedScheamLocations = adjustSchemaNames(schema, nameTable);
- //reverse the nametable so that there is a mapping from the
- //name to the schemaObject
- setSchemaMappingTable(swapMappingTable(nameTable));
- setSchemaLocationsAdjusted(true);
- }
- return changedScheamLocations;
- }
-
-
- /**
- * run 1 -calcualte unique names
- *
- * @param schemas
- */
- private void calcualteSchemaNames(List schemas, Hashtable nameTable) {
- //first traversal - fill the hashtable
- for (int i = 0; i < schemas.size(); i++) {
- XmlSchema schema = (XmlSchema) schemas.get(i);
- XmlSchemaObjectCollection includes = schema.getIncludes();
-
- for (int j = 0; j < includes.getCount(); j++) {
- Object item = includes.getItem(j);
- XmlSchema s;
- if (item instanceof XmlSchemaExternal) {
- XmlSchemaExternal externalSchema = (XmlSchemaExternal) item;
- s = externalSchema.getSchema();
- if (s != null && nameTable.get(s) == null) {
- //insert the name into the table
- insertIntoNameTable(nameTable, s);
- //recursively call the same procedure
- calcualteSchemaNames(Arrays.asList(
- new XmlSchema[]{s}),
- nameTable);
- }
- }
- }
- }
- }
-
- /**
- * A quick private sub routine to insert the names
- *
- * @param nameTable
- * @param s
- */
- private void insertIntoNameTable(Hashtable nameTable, XmlSchema s) {
- nameTable.put(s,
- ("xsd" + count++)
- + (customSchemaNameSuffix != null ?
- customSchemaNameSuffix :
- ""));
- }
-
- /**
- * Run 2 - adjust the names
- */
- private Map adjustSchemaNames(List schemas, Hashtable nameTable) {
- Hashtable importedSchemas = new Hashtable();
- //process the schemas in the main schema list
- for (int i = 0; i < schemas.size(); i++) {
[... 1905 lines stripped ...]
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org