tomj 2002/06/02 19:15:54
Modified: java/src/org/apache/axis/wsdl/toJava Utils.java
JavaSkelWriter.java JavaDeployWriter.java
Log:
Refactor common code in deploy writer and skeleton writer that determines
the element QName of an operation.
This fixes the interop doc/lit server side endpoints, as these endpoints were
set up to use skeletons.
Revision Changes Path
1.35 +81 -17 xml-axis/java/src/org/apache/axis/wsdl/toJava/Utils.java
Index: Utils.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/Utils.java,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- Utils.java 30 May 2002 23:46:02 -0000 1.34
+++ Utils.java 3 Jun 2002 02:15:53 -0000 1.35
@@ -54,31 +54,34 @@
*/
package org.apache.axis.wsdl.toJava;
+import org.apache.axis.Constants;
+import org.apache.axis.utils.JavaUtils;
+import org.apache.axis.wsdl.symbolTable.MessageEntry;
+import org.apache.axis.wsdl.symbolTable.SymbolTable;
+import org.apache.axis.wsdl.symbolTable.TypeEntry;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import javax.wsdl.BindingInput;
+import javax.wsdl.BindingOperation;
+import javax.wsdl.Fault;
+import javax.wsdl.Input;
+import javax.wsdl.Message;
+import javax.wsdl.Operation;
+import javax.wsdl.Part;
+import javax.wsdl.QName;
+import javax.wsdl.extensions.ExtensibilityElement;
+import javax.wsdl.extensions.soap.SOAPBody;
import java.io.File;
import java.io.IOException;
-
import java.net.MalformedURLException;
import java.net.URL;
-
import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
import java.util.StringTokenizer;
import java.util.Vector;
-import javax.wsdl.Fault;
-import javax.wsdl.Message;
-import javax.wsdl.QName;
-
-import org.apache.axis.Constants;
-
-import org.apache.axis.utils.JavaUtils;
-
-import org.apache.axis.wsdl.symbolTable.SymbolTable;
-import org.apache.axis.wsdl.symbolTable.TypeEntry;
-import org.apache.axis.wsdl.symbolTable.MessageEntry;
-
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
public class Utils extends org.apache.axis.wsdl.symbolTable.Utils {
/**
* Given a type, return the Java mapping of that type's holder.
@@ -445,5 +448,66 @@
public static boolean isPrimitiveType(TypeEntry type) {
return TYPES.get(type.getName()) != null;
} // isPrimitiveType
+
+ /**
+ * Return the XML Element which will trigger a particular operation
+ * or null if the default case (localPart equals operation name) will
+ * work fine.
+ *
+ * @param operation the operation
+ * @return element QName for doc/lit operation or null
+ */
+ public static QName getOperationQName(BindingOperation bindingOper) {
+ Operation operation = bindingOper.getOperation();
+ String operationName = operation.getName();
+ String javaOperName = JavaUtils.xmlNameToJava(operation.getName());
+ QName elementQName = null;
+
+ // Get a namespace from the soap:body tag, if any
+ // example:
+ // <soap:body namespace="this_is_what_we_want" ..>
+ String ns = null;
+ BindingInput bindInput = bindingOper.getBindingInput();
+ if (bindInput != null) {
+ Iterator it = bindInput.getExtensibilityElements().iterator();
+ while (it.hasNext()) {
+ ExtensibilityElement elem = (ExtensibilityElement) it.next();
+ if (elem instanceof SOAPBody) {
+ SOAPBody body = (SOAPBody) elem;
+ ns = body.getNamespaceURI();
+ break;
+ }
+ }
+ }
+ // Get the qname from the first message part, if it is an element
+ // example:
+ // <part name="paramters" element="ns:myelem">
+ Input input = operation.getInput();
+ if (input != null) {
+ Map parts = input.getMessage().getParts();
+ if (parts != null && !parts.isEmpty()) {
+ Iterator i = parts.values().iterator();
+ Part p = (Part) i.next();
+ elementQName = p.getElementName();
+ }
+ }
+
+ // NOTE: it is possible for someone to define a part as an element
+ // while using rpc/encoded, which is wrong and we might want to catch it
+ // here.
+
+ // If we didn't find an element declared in the part (assume it's a
+ // type), so the QName will be the operation name with the
+ // namespace (if any) from the binding soap:body tag..
+ if (elementQName == null) {
+ // We don't need to even set the QName in the meta data if we don't
+ // have a namespace or we didn't mangle the XML name to a java name
+ if (ns != null || !javaOperName.equals(operationName)) {
+ elementQName = new QName(ns, operationName);
+ }
+ }
+
+ return elementQName;
+ }
} // class Utils
1.28 +15 -35
xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaSkelWriter.java
Index: JavaSkelWriter.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaSkelWriter.java,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- JavaSkelWriter.java 31 May 2002 13:47:44 -0000 1.27
+++ JavaSkelWriter.java 3 Jun 2002 02:15:53 -0000 1.28
@@ -54,10 +54,13 @@
*/
package org.apache.axis.wsdl.toJava;
-import java.io.IOException;
-
-import java.util.Iterator;
-import java.util.List;
+import org.apache.axis.utils.JavaUtils;
+import org.apache.axis.wsdl.symbolTable.BindingEntry;
+import org.apache.axis.wsdl.symbolTable.Element;
+import org.apache.axis.wsdl.symbolTable.Parameter;
+import org.apache.axis.wsdl.symbolTable.Parameters;
+import org.apache.axis.wsdl.symbolTable.SymbolTable;
+import org.apache.axis.wsdl.symbolTable.TypeEntry;
import javax.wsdl.Binding;
import javax.wsdl.BindingInput;
@@ -65,22 +68,13 @@
import javax.wsdl.BindingOutput;
import javax.wsdl.Operation;
import javax.wsdl.OperationType;
-import javax.wsdl.PortType;
-
import javax.wsdl.extensions.ExtensibilityElement;
-
import javax.wsdl.extensions.soap.SOAPBody;
import javax.wsdl.extensions.soap.SOAPOperation;
-
-import org.apache.axis.utils.JavaUtils;
-
-import org.apache.axis.wsdl.symbolTable.BindingEntry;
-import org.apache.axis.wsdl.symbolTable.Element;
-import org.apache.axis.wsdl.symbolTable.Parameter;
-import org.apache.axis.wsdl.symbolTable.Parameters;
-import org.apache.axis.wsdl.symbolTable.PortTypeEntry;
-import org.apache.axis.wsdl.symbolTable.SymbolTable;
-import org.apache.axis.wsdl.symbolTable.TypeEntry;
+import javax.xml.rpc.namespace.QName;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
/**
* This is Wsdl2java's skeleton writer. It writes the <BindingName>Skeleton.java
@@ -206,29 +200,15 @@
pw.println(" _oper = new
org.apache.axis.description.OperationDesc(\"" +
javaOpName + "\", _params, " + returnStr + ");");
- String ns = "";
- BindingInput input = operation.getBindingInput();
- if (input != null) {
- List elems = input.getExtensibilityElements();
- Iterator it = elems.iterator();
- while (it.hasNext()) {
- ExtensibilityElement elem = (ExtensibilityElement)
it.next();
- if (elem instanceof SOAPBody) {
- SOAPBody body = (SOAPBody) elem;
- ns = body.getNamespaceURI();
- break;
- }
- }
- }
// If we need to know the QName (if we have a namespace or
// the actual method name doesn't match the XML we expect),
// record it in the OperationDesc
- if (!"".equals(ns) || !javaOpName.equals(opName)) {
- javax.xml.rpc.namespace.QName qn =
- new javax.xml.rpc.namespace.QName(ns, opName);
+ QName elementQName = Utils.getAxisQName(
+ Utils.getOperationQName(operation));
+ if (elementQName != null) {
pw.println(" _oper.setElementQName(" +
- Utils.getNewQName(qn) + ");");
+ Utils.getNewQName(elementQName) + ");");
}
// Find the SOAPAction.
1.45 +16 -41
xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaDeployWriter.java
Index: JavaDeployWriter.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaDeployWriter.java,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -r1.44 -r1.45
--- JavaDeployWriter.java 31 May 2002 19:08:10 -0000 1.44
+++ JavaDeployWriter.java 3 Jun 2002 02:15:53 -0000 1.45
@@ -54,38 +54,31 @@
*/
package org.apache.axis.wsdl.toJava;
-import java.io.IOException;
-
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Vector;
-
-import javax.wsdl.Binding;
-import javax.wsdl.BindingOperation;
-import javax.wsdl.Definition;
-import javax.wsdl.Operation;
-import javax.wsdl.OperationType;
-import javax.wsdl.Port;
-import javax.wsdl.QName;
-import javax.wsdl.Service;
-import javax.wsdl.Part;
-import javax.wsdl.Input;
-
import org.apache.axis.Constants;
import org.apache.axis.deployment.wsdd.WSDDConstants;
-
import org.apache.axis.utils.JavaUtils;
-
import org.apache.axis.wsdl.symbolTable.BindingEntry;
import org.apache.axis.wsdl.symbolTable.CollectionType;
import org.apache.axis.wsdl.symbolTable.DefinedElement;
import org.apache.axis.wsdl.symbolTable.Element;
import org.apache.axis.wsdl.symbolTable.Parameter;
import org.apache.axis.wsdl.symbolTable.Parameters;
-import org.apache.axis.wsdl.symbolTable.SchemaUtils;
import org.apache.axis.wsdl.symbolTable.SymbolTable;
import org.apache.axis.wsdl.symbolTable.TypeEntry;
+import javax.wsdl.Binding;
+import javax.wsdl.BindingOperation;
+import javax.wsdl.Definition;
+import javax.wsdl.Operation;
+import javax.wsdl.OperationType;
+import javax.wsdl.Port;
+import javax.wsdl.QName;
+import javax.wsdl.Service;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Vector;
+
/**
* This is Wsdl2java's deploy Writer. It writes the deploy.java file.
*/
@@ -309,32 +302,14 @@
Parameters params =
symbolTable.getOperationParameters(operation, "", bEntry);
if (params != null) {
- QName elementQName = null;
QName returnQName = null;
-
- // Get the operation qname
- Input input = operation.getInput();
- if (input != null) {
- Map parts = input.getMessage().getParts();
- if (parts != null && !parts.isEmpty()) {
- Iterator i = parts.values().iterator();
- Part p = (Part) i.next();
- elementQName = p.getElementName();
- }
- if (elementQName == null) {
- // FIXME - get namespace from WSDL?
- elementQName = new QName("", operationName);
- }
- QName defaultQName = new QName("", javaOperName);
- if (defaultQName.equals(elementQName)) {
- elementQName = null;
- }
- }
+
+ // Get the operation QName
+ QName elementQName = Utils.getOperationQName(bindingOper);
// Get the operation's return QName
if (params.returnName != null)
returnQName = Utils.getWSDLQName(params.returnName);
-
// Write the operation metadata
writeOperation(javaOperName, elementQName, returnQName,