You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by mr...@apache.org on 2006/07/31 22:44:26 UTC
svn commit: r427251 - in
/incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/hooks:
ODEAxisDispatcher.java ODEAxisService.java
Author: mriou
Date: Mon Jul 31 13:44:25 2006
New Revision: 427251
URL: http://svn.apache.org/viewvc?rev=427251&view=rev
Log:
ODE-12 Support doc/lit with different operation and message part element names.
Modified:
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/hooks/ODEAxisDispatcher.java
incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/hooks/ODEAxisService.java
Modified: incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/hooks/ODEAxisDispatcher.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/hooks/ODEAxisDispatcher.java?rev=427251&r1=427250&r2=427251&view=diff
==============================================================================
--- incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/hooks/ODEAxisDispatcher.java (original)
+++ incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/hooks/ODEAxisDispatcher.java Mon Jul 31 13:44:25 2006
@@ -19,7 +19,6 @@
package org.apache.ode.axis2.hooks;
-
import org.apache.axiom.om.OMElement;
import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
@@ -30,26 +29,24 @@
import org.apache.axis2.engine.AbstractDispatcher;
import org.apache.axis2.engine.AxisConfiguration;
import org.apache.axis2.i18n.Messages;
+import org.apache.commons.collections.map.MultiKeyMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import javax.xml.namespace.QName;
-
/**
* Dispatches the service based on the information from the target endpoint URL.
*/
public class ODEAxisDispatcher extends AbstractDispatcher {
- /**
- * Field NAME
- */
- public static final QName NAME = new QName("http://ode.intalio.org/",
- "ODEAxisDispatcher");
+ private static MultiKeyMap _elmtToOperation = new MultiKeyMap();
+
+ /** Field NAME */
+ public static final QName NAME = new QName("http://www.apache.org/ode", "ODEAxisDispatcher");
private static final Log log = LogFactory.getLog(ODEAxisDispatcher.class);
QName operationName = null;
-
public AxisOperation findOperation(AxisService service, MessageContext messageContext)
throws AxisFault {
AxisOperation operation;
@@ -88,6 +85,15 @@
if (index >=0 && index + "Response".length() == localName.length()) {
return service.getOperation(new QName(localName.substring(0, index)));
}
+
+ // Seems the operation still couldn't be found, let's check our operation => element
+ // mapping if we can find something (useful for doc/lit when people have the bad idea
+ // of using a different name for their operation and part element)
+ String opName = (String) _elmtToOperation.get(service.getName(), localName);
+ if (opName != null) {
+ operation = service.getOperation(new QName(opName));
+ return operation;
+ }
}
log.warn("No operation has been found!");
return null;
@@ -117,7 +123,6 @@
log.warn("No service has been found!");
return null;
}
-
public void initDispatcher() {
init(new HandlerDescription(NAME));
@@ -148,4 +153,16 @@
return null;
}
+ /**
+ * Associates an operation and the corresponding message part element name. Only
+ * makes sense for doc/lit services (only one part) for which the operation can't
+ * easily be guessed from the message element name.
+ * @param axisServiceName the service name as registered in Axis2
+ * @param operationName operation local name
+ * @param elmtName element local name
+ */
+ public static void addElmtToOpMapping(String axisServiceName, String operationName, String elmtName) {
+ if (operationName.equals(elmtName)) return;
+ _elmtToOperation.put(axisServiceName, elmtName, operationName);
+ }
}
Modified: incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/hooks/ODEAxisService.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/hooks/ODEAxisService.java?rev=427251&r1=427250&r2=427251&view=diff
==============================================================================
--- incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/hooks/ODEAxisService.java (original)
+++ incubator/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/hooks/ODEAxisService.java Mon Jul 31 13:44:25 2006
@@ -26,11 +26,14 @@
import org.apache.axis2.engine.AxisConfiguration;
import javax.wsdl.Definition;
+import javax.wsdl.Operation;
+import javax.wsdl.Part;
import javax.wsdl.Port;
-import javax.wsdl.extensions.ExtensibilityElement;
import javax.wsdl.extensions.soap.SOAPAddress;
import javax.xml.namespace.QName;
+import java.util.Collection;
import java.util.Iterator;
+import java.util.List;
/**
* Implementation of Axis Service used by ODE iapi to enlist itself
@@ -51,6 +54,10 @@
axisService.setWsdlfound(true);
axisService.setClassLoader(axisConfig.getServiceClassLoader());
+ // In doc/lit we need to declare a mapping between operations and message element names
+ // to be able to route properly.
+ declarePartsElements(wsdlDefinition, wsdlServiceName, serviceName, portName);
+
Iterator operations = axisService.getOperations();
ODEMessageReceiver msgReceiver = new ODEMessageReceiver();
while (operations.hasNext()) {
@@ -104,6 +111,23 @@
}
}
return null;
+ }
+
+ private static void declarePartsElements(Definition wsdlDefinition, QName wsdlServiceName,
+ String axisServiceName, String portName) {
+ List wsldOps = wsdlDefinition.getService(wsdlServiceName).getPort(portName)
+ .getBinding().getPortType().getOperations();
+ for (Object wsldOp : wsldOps) {
+ Operation wsdlOp = (Operation) wsldOp;
+ Collection parts = wsdlOp.getInput().getMessage().getParts().values();
+ // More than one part, it's rpc/enc, no mapping needs to be declared
+ if (parts.size() == 1) {
+ Part part = (Part) parts.iterator().next();
+ // Parts are types, it's rpc/enc, no mapping needs to be declared
+ if (part.getElementName() != null)
+ ODEAxisDispatcher.addElmtToOpMapping(axisServiceName, wsdlOp.getName(), part.getElementName().getLocalPart());
+ }
+ }
}
}