Return-Path: Delivered-To: apmail-xml-axis-dev-archive@xml.apache.org Received: (qmail 54410 invoked by uid 500); 21 Nov 2001 16:41:08 -0000 Mailing-List: contact axis-dev-help@xml.apache.org; run by ezmlm Precedence: bulk Reply-To: axis-dev@xml.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list axis-dev@xml.apache.org Received: (qmail 54397 invoked by uid 500); 21 Nov 2001 16:41:08 -0000 Delivered-To: apmail-xml-axis-cvs@apache.org Date: 21 Nov 2001 16:25:57 -0000 Message-ID: <20011121162557.51229.qmail@icarus.apache.org> From: butek@apache.org To: xml-axis-cvs@apache.org Subject: cvs commit: xml-axis/java/src/org/apache/axis/wsdl SymTabEntry.java SymbolTable.java ServiceEntry.java PortTypeEntry.java NoopWriter.java MessageEntry.java BindingEntry.java WriterFactory.java Utils.java Type.java Parameters.java JavaWriterFactory.java JavaWriter.java JavaUndeployWriter.java JavaTypeWriter.java JavaTestCaseWriter.java JavaStubWriter.java JavaSkelWriter.java JavaServiceWriter.java JavaServiceInterfaceWriter.java JavaServiceImplWriter.java JavaPortTypeWriter.java JavaInterfaceWriter.java JavaImplWriter.java JavaHolderWriter.java JavaFaultWriter.java JavaEnumTypeWriter.java JavaDeployWriter.java JavaDefinitionWriter.java JavaBindingWriter.java Emitter.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N butek 01/11/21 08:25:57 Modified: java/src/org/apache/axis/wsdl WriterFactory.java Utils.java Type.java Parameters.java JavaWriterFactory.java JavaWriter.java JavaUndeployWriter.java JavaTypeWriter.java JavaTestCaseWriter.java JavaStubWriter.java JavaSkelWriter.java JavaServiceWriter.java JavaServiceInterfaceWriter.java JavaServiceImplWriter.java JavaPortTypeWriter.java JavaInterfaceWriter.java JavaImplWriter.java JavaHolderWriter.java JavaFaultWriter.java JavaEnumTypeWriter.java JavaDeployWriter.java JavaDefinitionWriter.java JavaBindingWriter.java Emitter.java Added: java/src/org/apache/axis/wsdl SymTabEntry.java SymbolTable.java ServiceEntry.java PortTypeEntry.java NoopWriter.java MessageEntry.java BindingEntry.java Log: Added SymbolTable to Wsdl2java. This called for lots of additions and rearrangements. Revision Changes Path 1.5 +21 -14 xml-axis/java/src/org/apache/axis/wsdl/WriterFactory.java Index: WriterFactory.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/WriterFactory.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- WriterFactory.java 2001/10/31 17:28:55 1.4 +++ WriterFactory.java 2001/11/21 16:25:56 1.5 @@ -58,6 +58,7 @@ import javax.wsdl.Binding; import javax.wsdl.Definition; +import javax.wsdl.Message; import javax.wsdl.PortType; import javax.wsdl.Service; @@ -75,35 +76,41 @@ public interface WriterFactory { /** - * Get a Writer implementation that will generate bindings for the given - * PortType and HashMap of Parameters keyed off of operations. + * Allow the Writer extension to make a pass through the symbol table doing any pre-writing + * logic, like creating the Java names for each object and constructing signature strings. */ - public Writer getWriter(PortType portType, HashMap operationParameters); + public void writerPass(Definition def, SymbolTable symbolTable); /** - * Get a Writer implementation that will generate bindings for the given - * Binding and HashMap of Parameters keyed off of operations. + * Get a Writer implementation that will generate bindings for the given Message. */ - public Writer getWriter(Binding binding, HashMap operationParameters); + public Writer getWriter(Message message, SymbolTable symbolTable); /** - * Get a Writer implementation that will generate bindings for the given - * Service and HashMap of (HashMap of Parameters keyed off of operations) - * keyed off of portTypes. + * Get a Writer implementation that will generate bindings for the given PortType. */ - public Writer getWriter(Service service, HashMap portTypeOperationParameters); + public Writer getWriter(PortType portType, SymbolTable symbolTable); /** - * Get a Writer implementation that will generate bindings for the given - * Type. + * Get a Writer implementation that will generate bindings for the given Binding. */ - public Writer getWriter(Type type); + public Writer getWriter(Binding binding, SymbolTable symbolTable); /** + * Get a Writer implementation that will generate bindings for the given Service. + */ + public Writer getWriter(Service service, SymbolTable symbolTable); + + /** + * Get a Writer implementation that will generate bindings for the given Type. + */ + public Writer getWriter(Type type, SymbolTable symbolTable); + + /** * Get a Writer implementation that will generate anything that doesn't * fit into the scope of any of the other writers. */ - public Writer getWriter(Definition definition); + public Writer getWriter(Definition definition, SymbolTable symbolTable); /** * Provide the Emitter to the factory. 1.13 +110 -2 xml-axis/java/src/org/apache/axis/wsdl/Utils.java Index: Utils.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/Utils.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- Utils.java 2001/11/12 20:38:51 1.12 +++ Utils.java 2001/11/21 16:25:56 1.13 @@ -55,6 +55,7 @@ package org.apache.axis.wsdl; import org.w3c.dom.Node; +import org.w3c.dom.NodeList; import org.w3c.dom.NamedNodeMap; import javax.wsdl.QName; @@ -430,7 +431,7 @@ if( !Character.isLetterOrDigit(c) && c != '_' ) nameArray[j] = '_'; } - return new String(nameArray); + return capitalizeFirstChar(new String(nameArray)); } public static String makePackageName(String namespace) @@ -504,10 +505,117 @@ || typeValue.equals("double") || typeValue.equals("boolean") || typeValue.equals("byte")) - return "javax.xml.rpc.holders." + Utils.capitalizeFirstChar(typeValue) + "Holder"; + return "javax.xml.rpc.holders." + capitalizeFirstChar(typeValue) + "Holder"; else return typeValue + "Holder"; } // holder + + /** + * If the specified node represents a supported JAX-RPC complexType/element, + * a Vector is returned which contains the child element types and + * child element names. The even indices are the element types (Types) and + * the odd indices are the corresponding names (Strings). + * If the specified node is not a supported JAX-RPC complexType/element + * null is returned. + */ + public static Vector getComplexElementTypesAndNames(Node node, SymbolTable symbolTable) { + if (node == null) { + return null; + } + + // If the node kind is an element, dive into it. + QName nodeKind = Utils.getNodeQName(node); + if (nodeKind != null && + nodeKind.getLocalPart().equals("element") && + Utils.isSchemaNS(nodeKind.getNamespaceURI())) { + NodeList children = node.getChildNodes(); + Node complexNode = null; + for (int j = 0; j < children.getLength() && complexNode == null; j++) { + QName complexKind = Utils.getNodeQName(children.item(j)); + if (complexKind != null && + complexKind.getLocalPart().equals("complexType") && + Utils.isSchemaNS(complexKind.getNamespaceURI())) { + complexNode = children.item(j); + node = complexNode; + } + } + } + + // Expecting a schema complexType + nodeKind = Utils.getNodeQName(node); + if (nodeKind != null && + nodeKind.getLocalPart().equals("complexType") && + Utils.isSchemaNS(nodeKind.getNamespaceURI())) { + + // Under the complexType there should be a sequence or all group node. + // (There may be other #text nodes, which we will ignore). + NodeList children = node.getChildNodes(); + Node groupNode = null; + for (int j = 0; j < children.getLength() && groupNode == null; j++) { + QName groupKind = Utils.getNodeQName(children.item(j)); + if (groupKind != null && + (groupKind.getLocalPart().equals("sequence") || + groupKind.getLocalPart().equals("all")) && + Utils.isSchemaNS(groupKind.getNamespaceURI())) + groupNode = children.item(j); + } + + if (groupNode == null) { + return new Vector(); + } + if (groupNode != null) { + + // Process each of the element nodes under the group node + Vector v = new Vector(); + NodeList elements = children.item(1).getChildNodes(); + for (int i=0; i < elements.getLength(); i++) { + QName elementKind = Utils.getNodeQName(elements.item(i)); + if (elementKind != null && + elementKind.getLocalPart().equals("element") && + Utils.isSchemaNS(elementKind.getNamespaceURI())) { + + // Get the name and type qnames. + // The name of the element is the local part of the name's qname. + // The type qname is used to locate the Type, which is then + // used to retrieve the proper java name of the type. + Node elementNode = elements.item(i); + QName nodeName = Utils.getNodeNameQName(elementNode); + QName nodeType = Utils.getNodeTypeRefQName(elementNode); + if (nodeType == null) { // The element may use an anonymous type + nodeType = nodeName; + } + + Type Type = (Type) symbolTable.getTypeEntry(nodeType); + if (Type != null) { + v.add(Type); + v.add(nodeName.getLocalPart()); + } + } + } + return v; + } + } + return null; + } + + /** + * Query Java Local Name + */ + public static String getJavaLocalName(String fullName) { + return fullName.substring(fullName.lastIndexOf('.') + 1); + } // getJavaLocalName + + /** + * Query Java Package Name + */ + public static String getJavaPackageName(String fullName) { + if (fullName.lastIndexOf('.') > 0) { + return fullName.substring(0, fullName.lastIndexOf('.')); + } + else { + return ""; + } + } // getJavaPackageName } 1.13 +13 -45 xml-axis/java/src/org/apache/axis/wsdl/Type.java Index: Type.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/Type.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- Type.java 2001/11/09 19:57:45 1.12 +++ Type.java 2001/11/21 16:25:56 1.13 @@ -63,16 +63,15 @@ * This class represents a type that is supported by the WSDL2Java emitter. * A Type has a QName representing its XML name and a Java Name, which * is its full java name. The Type may also have a Node, which locates - * the definition of the emit type in the xml. - * A Type object is built by the TypeFactory for each XML complexType, simpleType, - * or element (necessary for ref=) that is defined or encountered. + * the definition of the emit type in the xml. + * A Type object extends SymTabEntry and is built by the SymbolTable class for + * each XML complexType, simpleType, or element (necessary for ref=) that is + * defined or encountered. * * @author Rich Scheuerle (scheu@us.ibm.com) */ -public class Type { +public class Type extends SymTabEntry { - private QName qName; // QName of the element type - private String jName; // Name of the Java Mapping (Class or primitive) private Node node; // Element node private boolean shouldEmit; // Indicates if this Type should have code emitted for it. private boolean isBaseType; // Indicates if represented by a java primitive or util class @@ -81,9 +80,8 @@ * Create a Type object for an xml construct name that represents a base java type */ protected Type(QName pqName) { - qName = pqName; + super(pqName, Utils.getBaseJavaName(pqName)); node = null; - jName = Utils.getBaseJavaName(qName); shouldEmit = false; isBaseType = true; } @@ -93,9 +91,8 @@ * The Type corresponding to the ultimate reference type is passed as refType */ protected Type(QName pqName, Type refType, Node pNode) { - qName = pqName; + super(pqName, refType.getJavaName()); node = pNode; - jName = refType.getJavaName(); shouldEmit = false; isBaseType = (refType.getBaseType() != null); } @@ -104,44 +101,17 @@ * Create a Type object for an xml construct that is not a base java type */ protected Type(QName pqName, String pjName, Node pNode) { - qName = pqName; + super(pqName, pjName); node = pNode; - jName = pjName; shouldEmit = (node != null); isBaseType = false; } /** - * Query QName - */ - public QName getQName() { - return qName; - } - - /** * Query Java Mapping Name */ public String getJavaName() { - return jName; - } - - /** - * Query Java Local Name - */ - public String getJavaLocalName() { - return jName.substring(jName.lastIndexOf('.')+1); - } - - /** - * Query Java Package Name - */ - public String getJavaPackageName() { - if (jName.lastIndexOf('.') > 0) { - return jName.substring(0, jName.lastIndexOf('.')); - } - else { - return ""; - } + return name; } /** @@ -179,7 +149,7 @@ */ public String getBaseType() { if (isBaseType) { - return jName; + return name; } else { return null; @@ -190,11 +160,9 @@ * Get string representation. */ public String toString() { - return - "QName: " + getQName() + "\n" + - "JName: " + getJavaName() + "\n" + - "Emit?: " + shouldEmit + "\n" + - "Base?: " + isBaseType + "\n" + + return super.toString() + + "Emit?: " + shouldEmit + "\n" + + "Base?: " + isBaseType + "\n" + "Node: " + getNode() + "\n"; } }; 1.2 +22 -0 xml-axis/java/src/org/apache/axis/wsdl/Parameters.java Index: Parameters.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/Parameters.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- Parameters.java 2001/11/15 20:08:41 1.1 +++ Parameters.java 2001/11/21 16:25:56 1.2 @@ -98,4 +98,26 @@ + "\n(inputs, inouts, outputs) = (" + inputs + ", " + inouts + ", " + outputs + ")" + "\nlist = " + list; } // toString + + /** + * This class simply collects + */ + protected static class Parameter { + + // constant values for the parameter mode. + public static final byte IN = 1; + public static final byte OUT = 2; + public static final byte INOUT = 3; + + public String name; + public String type; + public byte mode = IN; + + public String toString() { + return "(" + type + ", " + name + ", " + + (mode == IN ? "IN)" : mode == INOUT ? "INOUT)" : "OUT)"); + } // toString + } // class Parameter + + } // class Parameters 1.6 +180 -10 xml-axis/java/src/org/apache/axis/wsdl/JavaWriterFactory.java Index: JavaWriterFactory.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/JavaWriterFactory.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- JavaWriterFactory.java 2001/10/31 17:28:55 1.5 +++ JavaWriterFactory.java 2001/11/21 16:25:56 1.6 @@ -55,9 +55,15 @@ package org.apache.axis.wsdl; import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.Vector; import javax.wsdl.Binding; import javax.wsdl.Definition; +import javax.wsdl.Message; +import javax.wsdl.Operation; import javax.wsdl.PortType; import javax.wsdl.Service; @@ -76,6 +82,17 @@ } // ctor /** + * Do the Wsdl2java writer pass: + * - resolve name clashes + * - construct signatures + */ + public void writerPass(Definition def, SymbolTable symbolTable) { + javifyNames(symbolTable); + resolveNameClashes(symbolTable); + constructSignatures(def, symbolTable); + } // writerPass + + /** * Provide the emitter object to this class. */ public void setEmitter(Emitter emitter) { @@ -83,37 +100,190 @@ } // setEmitter /** + * Since Wsdl2java doesn't emit anything for Messages, return the No-op writer. + */ + public Writer getWriter(Message message, SymbolTable symbolTable) { + return new NoopWriter(); + } // getWriter + + /** * Return Wsdl2java's JavaPortTypeWriter object. */ - public Writer getWriter(PortType portType, HashMap operationParameters) { - return new JavaPortTypeWriter(emitter, portType, operationParameters); + public Writer getWriter(PortType portType, SymbolTable symbolTable) { + return new JavaPortTypeWriter(emitter, portType, symbolTable); } // getWriter /** * Return Wsdl2java's JavaBindingWriter object. */ - public Writer getWriter(Binding binding, HashMap operationParameters) { - return new JavaBindingWriter(emitter, binding, operationParameters); + public Writer getWriter(Binding binding, SymbolTable symbolTable) { + return new JavaBindingWriter(emitter, binding, symbolTable); } // getWriter /** * Return Wsdl2java's JavaServiceWriter object. */ - public Writer getWriter(Service service, HashMap portTypeOperationParameters) { - return new JavaServiceWriter(emitter, service, portTypeOperationParameters); + public Writer getWriter(Service service, SymbolTable symbolTable) { + return new JavaServiceWriter(emitter, service, symbolTable); } // getWriter /** * Return Wsdl2java's JavaTypeWriter object. */ - public Writer getWriter(Type type) { - return new JavaTypeWriter(emitter, type); + public Writer getWriter(Type type, SymbolTable symbolTable) { + return new JavaTypeWriter(emitter, type, symbolTable); } // getWriter /** * Return Wsdl2java's JavaDefinitionWriter object. */ - public Writer getWriter(Definition definition) { - return new JavaDefinitionWriter(emitter, definition); + public Writer getWriter(Definition definition, SymbolTable symbolTable) { + return new JavaDefinitionWriter(emitter, definition, symbolTable); } // getWriter + + /** + * Fill in the names of each SymTabEntry with the javaified name + */ + private void javifyNames(SymbolTable symbolTable) { + Iterator it = symbolTable.getHashMap().values().iterator(); + while (it.hasNext()) { + Vector v = (Vector) it.next(); + for (int i = 0; i < v.size(); ++i) { + SymTabEntry entry = (SymTabEntry) v.elementAt(i); + + // If entry instanceof Type, then the java name has already been filled in. + // Don't try to do it again. This method should really be doing the filling in + // of ALL enty java names, but that's another step toward generalizing the + // framework that I don't have time for right now. + if (!(entry instanceof Type)) { + entry.setName(symbolTable.getJavaName(entry.getQName())); + } + } + } + } // javifyNames + + /** + * Messages, PortTypes, Bindings, and Services can share the same name. If they do in this + * Definition, force their names to be suffixed with _PortType and _Service, respectively. + */ + private void resolveNameClashes(SymbolTable symbolTable) { + Iterator it = symbolTable.getHashMap().values().iterator(); + while (it.hasNext()) { + Vector v = (Vector) it.next(); + if (v.size() > 1) { + for (int i = 0; i < v.size(); ++i) { + SymTabEntry entry = (SymTabEntry) v.elementAt(i); + if (entry instanceof Type) { + entry.setName(entry.getName() + "_Type"); + } + else if (entry instanceof PortTypeEntry) { + entry.setName(entry.getName() + "_Port"); + } + else if (entry instanceof ServiceEntry) { + entry.setName(entry.getName() + "_Service"); + } + // else if (entry instanceof MessageEntry) { + // we don't care about messages + // } + // else if (entry instanceof BindingEntry) { + // since files generated from bindings all append strings to the name, + // we don't care about bindings + // } + } + } + } + } // resolveNameClashes + + private void constructSignatures(Definition def, SymbolTable symbolTable) { + Map portTypes = def.getPortTypes(); + Iterator i = portTypes.values().iterator(); + + while (i.hasNext()) { + PortType portType = (PortType) i.next(); + PortTypeEntry ptEntry = + symbolTable.getPortTypeEntry(portType.getQName()); + if (ptEntry != null) { + // Remove Duplicates - happens with only a few WSDL's. No idea why!!! + // (like http://www.xmethods.net/tmodels/InteropTest.wsdl) + // TODO: Remove this patch... + // NOTE from RJB: this is a WSDL4J bug and the WSDL4J guys have been notified. + Iterator operations = + new HashSet(portType.getOperations()).iterator(); + while(operations.hasNext()) { + Operation operation = (Operation) operations.next(); + String name = operation.getName(); + constructSignatures(ptEntry.getParameters(name), name); + } + + } + } + } // constructSignatures + + /** + * Construct the signatures. signature is used by both the interface and the stub. + * skelSig is used by the skeleton. + */ + private void constructSignatures(Parameters parms, String name) { + int allOuts = parms.outputs + parms.inouts; + String signature = " public " + parms.returnType + " " + name + "("; + String axisSig = " public " + parms.returnType + " " + name + "("; + String skelSig = null; + + if (allOuts == 0) + skelSig = " public void " + name + "("; + else + skelSig = " public Object " + name + "("; + + if (emitter.bMessageContext) { + skelSig = skelSig + "org.apache.axis.MessageContext ctx"; + axisSig = axisSig + "org.apache.axis.MessageContext ctx"; + if ((parms.inputs + parms.inouts) > 0) { + skelSig = skelSig + ", "; + } + if (parms.list.size() > 0) { + axisSig = axisSig + ", "; + } + } + boolean needComma = false; + + for (int i = 0; i < parms.list.size(); ++i) { + Parameters.Parameter p = (Parameters.Parameter) parms.list.get(i); + + if (needComma) { + signature = signature + ", "; + axisSig = axisSig + ", "; + if (p.mode != Parameters.Parameter.OUT) + skelSig = skelSig + ", "; + } + else + needComma = true; + if (p.mode == Parameters.Parameter.IN) { + signature = signature + p.type + " " + p.name; + axisSig = axisSig + p.type + " " + p.name; + skelSig = skelSig + p.type + " " + p.name; + } + else if (p.mode == Parameters.Parameter.INOUT) { + signature = signature + Utils.holder(p.type) + " " + p.name; + axisSig = axisSig + Utils.holder(p.type) + " " + p.name; + skelSig = skelSig + p.type + " " + p.name; + } + else// (p.mode == Parameters.Parameter.OUT) + { + signature = signature + Utils.holder(p.type) + " " + p.name; + axisSig = axisSig + Utils.holder(p.type) + " " + p.name; + } + } + signature = signature + ") throws java.rmi.RemoteException"; + axisSig = axisSig + ") throws java.rmi.RemoteException"; + skelSig = skelSig + ") throws java.rmi.RemoteException"; + if (parms.faultString != null) { + signature = signature + ", " + parms.faultString; + axisSig = axisSig + ", " + parms.faultString; + skelSig = skelSig + ", " + parms.faultString; + } + parms.signature = signature; + parms.axisSignature = axisSig; + parms.skelSignature = skelSig; + } // constructSignatures + } // class JavaWriterFactory 1.7 +5 -4 xml-axis/java/src/org/apache/axis/wsdl/JavaWriter.java Index: JavaWriter.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/JavaWriter.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- JavaWriter.java 2001/11/09 19:57:45 1.6 +++ JavaWriter.java 2001/11/21 16:25:56 1.7 @@ -104,16 +104,17 @@ */ protected JavaWriter( Emitter emitter, - Type type, + SymTabEntry entry, String suffix, String extension, String message) { this.emitter = emitter; - this.qname = type.getQName(); + this.qname = entry.getQName(); this.namespaces = emitter.getNamespaces(); - this.className = type.getJavaLocalName() + (suffix == null ? "" : suffix); + this.className = Utils.getJavaLocalName(entry.getName()) + + (suffix == null ? "" : suffix); this.fileName = className + '.' + extension; - this.packageName = namespaces.getCreate(qname.getNamespaceURI()); + this.packageName = Utils.getJavaPackageName(entry.getName()); this.message = message; } // ctor 1.3 +5 -2 xml-axis/java/src/org/apache/axis/wsdl/JavaUndeployWriter.java Index: JavaUndeployWriter.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/JavaUndeployWriter.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- JavaUndeployWriter.java 2001/11/09 15:02:17 1.2 +++ JavaUndeployWriter.java 2001/11/21 16:25:56 1.3 @@ -72,17 +72,19 @@ */ public class JavaUndeployWriter extends JavaWriter { private Definition definition; + private SymbolTable symbolTable; /** * Constructor. */ - protected JavaUndeployWriter(Emitter emitter, Definition definition) { + protected JavaUndeployWriter(Emitter emitter, Definition definition, SymbolTable symbolTable) { super(emitter, new QName(definition.getTargetNamespace(), "undeploy"), "", "xml", JavaUtils.getMessage("genUndeploy00")); this.definition = definition; + this.symbolTable = symbolTable; } // ctor /** @@ -133,9 +135,10 @@ */ private void writeDeployPort(Port port) throws IOException { Binding binding = port.getBinding(); + BindingEntry bEntry = symbolTable.getBindingEntry(binding.getQName()); String serviceName = port.getName(); - boolean isRPC = (emitter.wsdlAttr.getBindingStyle(binding) == WsdlAttributes.STYLE_RPC); + boolean isRPC = (bEntry.getBindingStyle() == BindingEntry.STYLE_RPC); pw.println(" "); 1.3 +94 -3 xml-axis/java/src/org/apache/axis/wsdl/JavaTypeWriter.java Index: JavaTypeWriter.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/JavaTypeWriter.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- JavaTypeWriter.java 2001/11/09 19:57:45 1.2 +++ JavaTypeWriter.java 2001/11/21 16:25:56 1.3 @@ -61,6 +61,7 @@ import javax.wsdl.QName; import org.w3c.dom.Node; +import org.w3c.dom.NodeList; /** * This is Wsdl2java's Type Writer. It writes the following files, as appropriate: @@ -69,24 +70,27 @@ public class JavaTypeWriter implements Writer { Writer typeWriter = null; Writer holderWriter = null; + SymbolTable symbolTable = null; /** * Constructor. */ protected JavaTypeWriter( Emitter emitter, - Type type) { + Type type, + SymbolTable symbolTable) { + this.symbolTable = symbolTable; // Determine what sort of type this is and instantiate the appropriate Writer. Node node = type.getNode(); // Generate the proper class for either "complex" or "enumeration" types - Vector v = emitter.getTypeFactory().getComplexElementTypesAndNames(node); + Vector v = Utils.getComplexElementTypesAndNames(node, symbolTable); if (v != null) { typeWriter = new JavaComplexTypeWriter(emitter, type, v); } else { - v = emitter.getTypeFactory().getEnumerationBaseAndValues(node); + v = getEnumerationBaseAndValues(node); if (v != null) { typeWriter = new JavaEnumTypeWriter(emitter, type, v); } @@ -112,5 +116,92 @@ holderWriter.write(); } } // write + + /** + * If the specified node represents a supported JAX-RPC enumeration, + * a Vector is returned which contains the base type and the enumeration values. + * The first element in the vector is the base type (an Type). + * Subsequent elements are values (Strings). + * If this is not an enumeration, null is returned. + */ + public Vector getEnumerationBaseAndValues(Node node) { + if (node == null) { + return null; + } + + // If the node kind is an element, dive into it. + QName nodeKind = Utils.getNodeQName(node); + if (nodeKind != null && + nodeKind.getLocalPart().equals("element") && + Utils.isSchemaNS(nodeKind.getNamespaceURI())) { + NodeList children = node.getChildNodes(); + Node simpleNode = null; + for (int j = 0; j < children.getLength() && simpleNode == null; j++) { + QName simpleKind = Utils.getNodeQName(children.item(j)); + if (simpleKind != null && + simpleKind.getLocalPart().equals("simpleType") && + Utils.isSchemaNS(simpleKind.getNamespaceURI())) { + simpleNode = children.item(j); + node = simpleNode; + } + } + } + // Get the node kind, expecting a schema simpleType + nodeKind = Utils.getNodeQName(node); + if (nodeKind != null && + nodeKind.getLocalPart().equals("simpleType") && + Utils.isSchemaNS(nodeKind.getNamespaceURI())) { + + // Under the simpleType there should be a restriction. + // (There may be other #text nodes, which we will ignore). + NodeList children = node.getChildNodes(); + Node restrictionNode = null; + for (int j = 0; j < children.getLength() && restrictionNode == null; j++) { + QName restrictionKind = Utils.getNodeQName(children.item(j)); + if (restrictionKind != null && + restrictionKind.getLocalPart().equals("restriction") && + Utils.isSchemaNS(restrictionKind.getNamespaceURI())) + restrictionNode = children.item(j); + } + + // The restriction node indicates the type being restricted + // (the base attribute contains this type). + // The base type must be a built-in type...and we only think + // this makes sense for string. + Type baseEType = null; + if (restrictionNode != null) { + QName baseType = Utils.getNodeTypeRefQName(restrictionNode, "base"); + baseEType = symbolTable.getTypeEntry(baseType); + if (baseEType != null && + !baseEType.getJavaName().equals("java.lang.String")) { + baseEType = null; + } + } + + // Process the enumeration elements underneath the restriction node + if (baseEType != null && restrictionNode != null) { + + Vector v = new Vector(); + v.add(baseEType); + NodeList enums = restrictionNode.getChildNodes(); + for (int i=0; i < enums.getLength(); i++) { + QName enumKind = Utils.getNodeQName(enums.item(i)); + if (enumKind != null && + enumKind.getLocalPart().equals("enumeration") && + Utils.isSchemaNS(enumKind.getNamespaceURI())) { + + // Put the enum value in the vector. + Node enumNode = enums.item(i); + String value = Utils.getAttribute(enumNode, "value"); + if (value != null) { + v.add(value); + } + } + } + return v; + } + } + return null; + } } // class JavaTypeWriter 1.5 +17 -12 xml-axis/java/src/org/apache/axis/wsdl/JavaTestCaseWriter.java Index: JavaTestCaseWriter.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/JavaTestCaseWriter.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- JavaTestCaseWriter.java 2001/11/15 20:08:41 1.4 +++ JavaTestCaseWriter.java 2001/11/21 16:25:56 1.5 @@ -74,19 +74,19 @@ */ public class JavaTestCaseWriter extends JavaWriter { private Service service; - private HashMap portTypeOperationParameters; + private SymbolTable symbolTable; /** * Constructor. */ protected JavaTestCaseWriter( Emitter emitter, - Service service, - HashMap portTypeOperationParameters) { - super(emitter, service.getQName(), "TestCase", "java", + ServiceEntry sEntry, + SymbolTable symbolTable) { + super(emitter, sEntry, "TestCase", "java", JavaUtils.getMessage("genTest00")); - this.service = service; - this.portTypeOperationParameters = portTypeOperationParameters; + this.service = sEntry.getService(); + this.symbolTable = symbolTable; } // ctor /** @@ -117,9 +117,11 @@ while (portIterator.hasNext()) { Port p = (Port) portIterator.next(); Binding binding = p.getBinding(); + BindingEntry bEntry = + symbolTable.getBindingEntry(binding.getQName()); // If this isn't an SOAP binding, skip it - if (emitter.wsdlAttr.getBindingType(binding) != WsdlAttributes.TYPE_SOAP) { + if (bEntry.getBindingType() != BindingEntry.TYPE_SOAP) { continue; } @@ -140,7 +142,10 @@ public final void writeServiceTestCode(String portName, Binding binding) throws IOException { PortType portType = binding.getPortType(); - String bindingType = emitter.getTypeFactory().getJavaName(portType.getQName()); + PortTypeEntry ptEntry = + symbolTable.getPortTypeEntry(portType.getQName()); + BindingEntry bEntry = symbolTable.getBindingEntry(binding.getQName()); + String bindingType = ptEntry.getName(); pw.println(); pw.println(" public void test" + portName + "() {"); @@ -162,13 +167,13 @@ } // writeServiceTestCode private final void writePortTestCode(PortType port) throws IOException { + PortTypeEntry ptEntry = symbolTable.getPortTypeEntry(port.getQName()); Iterator ops = port.getOperations().iterator(); - HashMap operationParameters = (HashMap) portTypeOperationParameters.get(port.getQName()); while (ops.hasNext()) { pw.println(" try {"); Operation op = (Operation) ops.next(); String namespace = (String) emitter.getNamespaces().get(port.getQName().getNamespaceURI()); - Parameters params = (Parameters) operationParameters.get(op.getName()); + Parameters params = ptEntry.getParameters(op.getName()); if ( !"void".equals( params.returnType ) ) { pw.print(" "); @@ -206,11 +211,11 @@ pw.print(", "); } - Emitter.Parameter param = (Emitter.Parameter) iparam.next(); + Parameters.Parameter param = (Parameters.Parameter) iparam.next(); String paramType = null; switch (param.mode) { - case Emitter.Parameter.IN: + case Parameters.Parameter.IN: paramType = param.type; break; 1.8 +55 -32 xml-axis/java/src/org/apache/axis/wsdl/JavaStubWriter.java Index: JavaStubWriter.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/JavaStubWriter.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- JavaStubWriter.java 2001/11/15 20:08:41 1.7 +++ JavaStubWriter.java 2001/11/21 16:25:56 1.8 @@ -86,35 +86,35 @@ * file which contains the Stub class. */ public class JavaStubWriter extends JavaWriter { + private BindingEntry bEntry; private Binding binding; - private HashMap operationParameters; + private SymbolTable symbolTable; /** * Constructor. */ protected JavaStubWriter( Emitter emitter, - Binding binding, - HashMap operationParameters) { - super(emitter, binding.getQName(), "Stub", "java", + BindingEntry bEntry, + SymbolTable symbolTable) { + super(emitter, bEntry, "Stub", "java", JavaUtils.getMessage("genStub00")); - this.binding = binding; - this.operationParameters = operationParameters; + this.bEntry = bEntry; + this.binding = bEntry.getBinding(); + this.symbolTable = symbolTable; } // ctor /** * Write the body of the binding's stub file. */ protected void writeFileBody() throws IOException { - if (operationParameters == null) - throw new IOException( - JavaUtils.getMessage("emitFail01", "" + qname)); - PortType portType = binding.getPortType(); + PortTypeEntry ptEntry = + symbolTable.getPortTypeEntry(portType.getQName()); String name = Utils.xmlNameToJava(qname.getLocalPart()); - String portTypeName = emitter.emitFactory.getJavaName(portType.getQName()); + String portTypeName = ptEntry.getName(); boolean isRPC = true; - if (emitter.wsdlAttr.getBindingStyle(binding) == WsdlAttributes.STYLE_DOCUMENT) { + if (bEntry.getBindingStyle() == BindingEntry.STYLE_DOCUMENT) { isRPC = false; } @@ -191,7 +191,8 @@ List operations = binding.getBindingOperations(); for (int i = 0; i < operations.size(); ++i) { BindingOperation operation = (BindingOperation) operations.get(i); - Parameters parameters = (Parameters) operationParameters.get(operation.getOperation().getName()); + Parameters parameters = + ptEntry.getParameters(operation.getOperation().getName()); // Get the soapAction from the String soapAction = ""; @@ -265,7 +266,7 @@ if (input != null) { partTypes(v, input.getMessage().getOrderedParts(null), - (emitter.wsdlAttr.getInputBodyType(operation) == WsdlAttributes.USE_LITERAL)); + (bEntry.getInputBodyType(operation) == BindingEntry.USE_LITERAL)); } // Collect all the output types @@ -274,7 +275,7 @@ if (output != null) { partTypes(v, output.getMessage().getOrderedParts(null), - (emitter.wsdlAttr.getOutputBodyType(operation) == WsdlAttributes.USE_LITERAL)); + (bEntry.getOutputBodyType(operation) == BindingEntry.USE_LITERAL)); } // Collect all the types in faults @@ -287,7 +288,7 @@ Fault f = (Fault) i.next(); partTypes(v, f.getMessage().getOrderedParts(null), - (emitter.wsdlAttr.getFaultBodyType(operation, f.getName()) == WsdlAttributes.USE_LITERAL)); + (bEntry.getFaultBodyType(operation, f.getName()) == BindingEntry.USE_LITERAL)); } } @@ -308,7 +309,7 @@ } // getNestedTypes private void getNestedTypes(Node type, HashSet types) { - Vector v = emitter.emitFactory.getComplexElementTypesAndNames(type); + Vector v = Utils.getComplexElementTypesAndNames(type, symbolTable); if (v != null) { for (int i = 0; i < v.size(); i+=2) { if (!types.contains(v.get(i))) { @@ -337,7 +338,7 @@ qType = part.getElementName(); } if (qType != null) { - v.add(emitter.emitFactory.getType(qType)); + v.add(symbolTable.getTypeEntry(qType)); } } } // partTypes @@ -387,20 +388,20 @@ // loop over paramters and set up in/out params for (int i = 0; i < parms.list.size(); ++i) { - Emitter.Parameter p = (Emitter.Parameter) parms.list.get(i); + Parameters.Parameter p = (Parameters.Parameter) parms.list.get(i); - Type type = emitter.emitFactory.getDefinedType(p.type); + Type type = getDefinedType(p.type); if (type == null) { // XXX yikes, something is wrong } QName qn = type.getQName(); String typeString = "new org.apache.axis.encoding.XMLType( new javax.xml.rpc.namespace.QName(\"" + qn.getNamespaceURI() + "\", \"" + Utils.capitalizeFirstChar(qn.getLocalPart()) + "\"))"; - if (p.mode == Emitter.Parameter.IN) { + if (p.mode == Parameters.Parameter.IN) { pw.println(" call.addParameter(\"" + p.name + "\", " + typeString + ", org.apache.axis.client.Call.PARAM_MODE_IN);"); } - else if (p.mode == Emitter.Parameter.INOUT) { + else if (p.mode == Parameters.Parameter.INOUT) { pw.println(" call.addParameter(\"" + p.name + "\", " + typeString + ", call.PARAM_MODE_INOUT);"); } else { // p.mode == Parameter.OUT @@ -409,7 +410,7 @@ } // set output type if (!"void".equals(parms.returnType)) { - QName qn = emitter.emitFactory.getDefinedType(parms.returnType).getQName(); + QName qn = getDefinedType(parms.returnType).getQName(); String outputType = "new org.apache.axis.encoding.XMLType(new javax.xml.rpc.namespace.QName(\"" + qn.getNamespaceURI() + "\", \"" + Utils.capitalizeFirstChar(qn.getLocalPart()) + "\"))"; pw.println(" call.setReturnType(" + outputType + ");"); @@ -427,17 +428,17 @@ // Write the input and inout parameter list boolean needComma = false; for (int i = 0; i < parms.list.size(); ++i) { - Emitter.Parameter p = (Emitter.Parameter) parms.list.get(i); + Parameters.Parameter p = (Parameters.Parameter) parms.list.get(i); if (needComma) { - if (p.mode != Emitter.Parameter.OUT) + if (p.mode != Parameters.Parameter.OUT) pw.print(", "); } else needComma = true; - if (p.mode == Emitter.Parameter.IN) + if (p.mode == Parameters.Parameter.IN) pw.print(wrapPrimitiveType(p.type, p.name)); - else if (p.mode == Emitter.Parameter.INOUT) + else if (p.mode == Parameters.Parameter.INOUT) pw.print(wrapPrimitiveType(p.type, p.name + "._value")); } pw.println("});"); @@ -454,10 +455,10 @@ // There is only one output and it is an inout, so the resp object // must go into the inout holder. int i = 0; - Emitter.Parameter p = (Emitter.Parameter) parms.list.get(i); + Parameters.Parameter p = (Parameters.Parameter) parms.list.get(i); - while (p.mode != Emitter.Parameter.INOUT) - p = (Emitter.Parameter) parms.list.get(++i); + while (p.mode != Parameters.Parameter.INOUT) + p = (Parameters.Parameter) parms.list.get(++i); pw.println (" " + p.name + "._value = " + getResponseString(p.type, "resp")); } else { @@ -475,8 +476,8 @@ int outdex = 0; boolean firstInoutIsResp = (parms.outputs == 0); for (int i = 0; i < parms.list.size (); ++i) { - Emitter.Parameter p = (Emitter.Parameter) parms.list.get (i); - if (p.mode != Emitter.Parameter.IN) { + Parameters.Parameter p = (Parameters.Parameter) parms.list.get (i); + if (p.mode != Parameters.Parameter.IN) { if (firstInoutIsResp) { firstInoutIsResp = false; pw.println (" " + p.name + "._value = " + getResponseString(p.type, "resp")); @@ -496,5 +497,27 @@ pw.println(" }"); pw.println(); } // writeOperation + + /** + * Get the defined Type for the given Java Name + * Return null if not found. + */ + public Type getDefinedType(String javaName) { + Vector types = symbolTable.getTypes(); + for (int i = 0; i < types.size(); ++i) { + Type et = (Type) types.elementAt(i); + if(et.getJavaName().equals(javaName)) { + // There could be multiple types/elements with this + // name. Get one that defines the name. + if (et instanceof BaseJavaType || + et instanceof DefinedType || + (et instanceof ElementType && + ((ElementType) et).getDefinedDirectly())) { + return et; + } + } + } + return null; + } // getDefinedType } // class JavaStubWriter 1.5 +24 -23 xml-axis/java/src/org/apache/axis/wsdl/JavaSkelWriter.java Index: JavaSkelWriter.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/JavaSkelWriter.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- JavaSkelWriter.java 2001/11/15 20:08:41 1.4 +++ JavaSkelWriter.java 2001/11/21 16:25:56 1.5 @@ -75,34 +75,34 @@ * file which contains the Skeleton class. */ public class JavaSkelWriter extends JavaWriter { + private BindingEntry bEntry; private Binding binding; - private HashMap operationParameters; + private SymbolTable symbolTable; /** * Constructor. */ protected JavaSkelWriter( Emitter emitter, - Binding binding, - HashMap operationParameters) { - super(emitter, binding.getQName(), "Skeleton", "java", + BindingEntry bEntry, + SymbolTable symbolTable) { + super(emitter, bEntry, "Skeleton", "java", JavaUtils.getMessage("genSkel00")); - this.binding = binding; - this.operationParameters = operationParameters; + this.bEntry = bEntry; + this.binding = bEntry.getBinding(); + this.symbolTable = symbolTable; } // ctor /** * Write the body of the binding's stub file. */ protected void writeFileBody() throws IOException { - if (operationParameters == null) - throw new IOException( - JavaUtils.getMessage("emitFail01", "" + qname)); - PortType portType = binding.getPortType(); - String portTypeName = emitter.emitFactory.getJavaName(portType.getQName()); + PortTypeEntry ptEntry = + symbolTable.getPortTypeEntry(portType.getQName()); + String portTypeName = ptEntry.getName(); boolean isRPC = true; - if (emitter.wsdlAttr.getBindingStyle(binding) == WsdlAttributes.STYLE_DOCUMENT) { + if (bEntry.getBindingStyle() == BindingEntry.STYLE_DOCUMENT) { isRPC = false; } @@ -126,7 +126,8 @@ List operations = binding.getBindingOperations(); for (int i = 0; i < operations.size(); ++i) { BindingOperation operation = (BindingOperation) operations.get(i); - Parameters parameters = (Parameters) operationParameters.get(operation.getOperation().getName()); + Parameters parameters = + ptEntry.getParameters(operation.getOperation().getName()); // Get the soapAction from the String soapAction = ""; @@ -173,13 +174,13 @@ // Instantiate the holders for (int i = 0; i < parms.list.size(); ++i) { - Emitter.Parameter p = (Emitter.Parameter) parms.list.get(i); + Parameters.Parameter p = (Parameters.Parameter) parms.list.get(i); String holder = Utils.holder(p.type); - if (p.mode == Emitter.Parameter.INOUT) { + if (p.mode == Parameters.Parameter.INOUT) { pw.println(" " + holder + " " + p.name + "Holder = new " + holder + "(" + p.name + ");"); } - else if (p.mode == Emitter.Parameter.OUT) { + else if (p.mode == Parameters.Parameter.OUT) { pw.println(" " + holder + " " + p.name + "Holder = new " + holder + "();"); } } @@ -202,9 +203,9 @@ call = call + ", "; else needComma = true; - Emitter.Parameter p = (Emitter.Parameter) parms.list.get(i); + Parameters.Parameter p = (Parameters.Parameter) parms.list.get(i); - if (p.mode == Emitter.Parameter.IN) + if (p.mode == Parameters.Parameter.IN) call = call + p.name; else call = call + p.name + "Holder"; @@ -224,9 +225,9 @@ // There is only one inout parameter. Find it in the parms list and write // its return int i = 0; - Emitter.Parameter p = (Emitter.Parameter) parms.list.get(i); - while (p.mode != Emitter.Parameter.INOUT) - p = (Emitter.Parameter) parms.list.get(++i); + Parameters.Parameter p = (Parameters.Parameter) parms.list.get(i); + while (p.mode != Parameters.Parameter.INOUT) + p = (Parameters.Parameter) parms.list.get(++i); pw.println(" return " + wrapPrimitiveType(p.type, p.name + "Holder._value") + ";"); } else { @@ -235,9 +236,9 @@ if (!"void".equals(parms.returnType)) pw.println(" list.add(new org.apache.axis.message.RPCParam(\"" + parms.returnName + "\", ret));"); for (int i = 0; i < parms.list.size(); ++i) { - Emitter.Parameter p = (Emitter.Parameter) parms.list.get(i); + Parameters.Parameter p = (Parameters.Parameter) parms.list.get(i); - if (p.mode != Emitter.Parameter.IN) + if (p.mode != Parameters.Parameter.IN) pw.println(" list.add(new org.apache.axis.message.RPCParam(\"" + p.name + "\", " + wrapPrimitiveType(p.type, p.name + "Holder._value") +"));"); } pw.println(" return list;"); 1.3 +4 -6 xml-axis/java/src/org/apache/axis/wsdl/JavaServiceWriter.java Index: JavaServiceWriter.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/JavaServiceWriter.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- JavaServiceWriter.java 2001/11/09 19:57:45 1.2 +++ JavaServiceWriter.java 2001/11/21 16:25:56 1.3 @@ -75,13 +75,11 @@ protected JavaServiceWriter( Emitter emitter, Service service, - HashMap portTypeOperationParameters) { - QName serviceQName = new QName(service.getQName().getNamespaceURI(), - Utils.capitalizeFirstChar(Utils.xmlNameToJava(service.getQName().getLocalPart()))); - service.setQName (serviceQName); - serviceWriter = new JavaServiceImplWriter(emitter, service); + SymbolTable symbolTable) { + ServiceEntry sEntry = symbolTable.getServiceEntry(service.getQName()); + serviceWriter = new JavaServiceImplWriter(emitter, sEntry, symbolTable); if (emitter.bEmitTestCase) { - testCaseWriter = new JavaTestCaseWriter(emitter, service, portTypeOperationParameters); + testCaseWriter = new JavaTestCaseWriter(emitter, sEntry, symbolTable); } } // ctor 1.5 +7 -7 xml-axis/java/src/org/apache/axis/wsdl/JavaServiceInterfaceWriter.java Index: JavaServiceInterfaceWriter.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/JavaServiceInterfaceWriter.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- JavaServiceInterfaceWriter.java 2001/11/15 20:08:41 1.4 +++ JavaServiceInterfaceWriter.java 2001/11/21 16:25:56 1.5 @@ -69,19 +69,19 @@ */ public class JavaServiceInterfaceWriter extends JavaWriter { private PortType portType; - private HashMap operationParameters; + private PortTypeEntry ptEntry; /** * Constructor. */ protected JavaServiceInterfaceWriter( Emitter emitter, - PortType portType, - HashMap operationParameters) { - super(emitter, portType.getQName(), "AXIS", "java", + PortTypeEntry ptEntry, + SymbolTable symbolTable) { + super(emitter, ptEntry, "AXIS", "java", JavaUtils.getMessage("genIface01")); - this.portType = portType; - this.operationParameters = operationParameters; + this.ptEntry = ptEntry; + this.portType = ptEntry.getPortType(); } // ctor /** @@ -105,7 +105,7 @@ * This method generates the axis server side impl interface signatures operation. */ private void writeOperationAxisSkelSignatures(Operation operation) throws IOException { - Parameters parms = (Parameters) operationParameters.get(operation.getName()); + Parameters parms = ptEntry.getParameters(operation.getName()); pw.println(parms.axisSignature + ";"); } // writeOperationAxisSkelSignatures 1.3 +13 -6 xml-axis/java/src/org/apache/axis/wsdl/JavaServiceImplWriter.java Index: JavaServiceImplWriter.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/JavaServiceImplWriter.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- JavaServiceImplWriter.java 2001/11/09 15:02:17 1.2 +++ JavaServiceImplWriter.java 2001/11/21 16:25:56 1.3 @@ -77,16 +77,19 @@ */ public class JavaServiceImplWriter extends JavaWriter { private Service service; + private SymbolTable symbolTable; /** * Constructor. */ protected JavaServiceImplWriter( Emitter emitter, - Service service) { - super(emitter, service.getQName(), "", "java", + ServiceEntry sEntry, + SymbolTable symbolTable) { + super(emitter, sEntry, "", "java", JavaUtils.getMessage("genService00")); - this.service = service; + this.service = sEntry.getService(); + this.symbolTable = symbolTable; } // ctor /** @@ -107,15 +110,19 @@ while (portIterator.hasNext()) { Port p = (Port) portIterator.next(); Binding binding = p.getBinding(); + BindingEntry bEntry = + symbolTable.getBindingEntry(binding.getQName()); + PortTypeEntry ptEntry = symbolTable.getPortTypeEntry( + binding.getPortType().getQName()); // If this isn't an SOAP binding, skip it - if (emitter.wsdlAttr.getBindingType(binding) != WsdlAttributes.TYPE_SOAP) { + if (bEntry.getBindingType() != BindingEntry.TYPE_SOAP) { continue; } String portName = p.getName(); - String stubClass = emitter.emitFactory.getJavaName(binding.getQName()) + "Stub"; - String bindingType = emitter.emitFactory.getJavaName(binding.getPortType().getQName()); + String stubClass = bEntry.getName() + "Stub"; + String bindingType = ptEntry.getName(); // Get endpoint address and validate it String address = getAddressFromPort(p); 1.4 +5 -6 xml-axis/java/src/org/apache/axis/wsdl/JavaPortTypeWriter.java Index: JavaPortTypeWriter.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/JavaPortTypeWriter.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- JavaPortTypeWriter.java 2001/11/09 19:57:45 1.3 +++ JavaPortTypeWriter.java 2001/11/21 16:25:56 1.4 @@ -75,13 +75,12 @@ */ protected JavaPortTypeWriter( Emitter emitter, - PortType portType, HashMap operationParameters) { - QName qname = new QName(portType.getQName().getNamespaceURI(), - Utils.capitalizeFirstChar(Utils.xmlNameToJava(portType.getQName().getLocalPart()))); - portType.setQName(qname); - interfaceWriter = new JavaInterfaceWriter(emitter, portType, operationParameters); + PortType portType, SymbolTable symbolTable) { + PortTypeEntry ptEntry = symbolTable.getPortTypeEntry(portType.getQName()); + interfaceWriter = + new JavaInterfaceWriter(emitter, ptEntry, symbolTable); if (emitter.bEmitSkeleton && emitter.bMessageContext) { - serviceInterfaceWriter = new JavaServiceInterfaceWriter(emitter, portType, operationParameters); + serviceInterfaceWriter = new JavaServiceInterfaceWriter(emitter, ptEntry, symbolTable); } } // ctor 1.5 +9 -8 xml-axis/java/src/org/apache/axis/wsdl/JavaInterfaceWriter.java Index: JavaInterfaceWriter.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/JavaInterfaceWriter.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- JavaInterfaceWriter.java 2001/11/15 20:08:41 1.4 +++ JavaInterfaceWriter.java 2001/11/21 16:25:56 1.5 @@ -70,19 +70,20 @@ * which contains the interface. */ public class JavaInterfaceWriter extends JavaWriter { - private PortType portType; - private HashMap operationParameters; + private PortType portType; + private PortTypeEntry ptEntry; + private SymbolTable symbolTable; /** * Constructor. */ protected JavaInterfaceWriter( Emitter emitter, - PortType portType, HashMap operationParameters) { - super(emitter, portType.getQName(), "", "java", - JavaUtils.getMessage("genIface00")); - this.portType = portType; - this.operationParameters = operationParameters; + PortTypeEntry ptEntry, SymbolTable symbolTable) { + super(emitter, ptEntry, "", "java", JavaUtils.getMessage("genIface00")); + this.ptEntry = ptEntry; + this.portType = ptEntry.getPortType(); + this.symbolTable = symbolTable; } // ctor /** @@ -110,7 +111,7 @@ */ private void writeOperation(PortType portType, Operation operation, String namespace) throws IOException { writeComment(pw, operation.getDocumentationElement()); - Parameters parms = (Parameters) operationParameters.get(operation.getName()); + Parameters parms = ptEntry.getParameters(operation.getName()); pw.println(parms.signature + ";"); } // writeOperation 1.5 +13 -13 xml-axis/java/src/org/apache/axis/wsdl/JavaImplWriter.java Index: JavaImplWriter.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/JavaImplWriter.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- JavaImplWriter.java 2001/11/15 20:08:41 1.4 +++ JavaImplWriter.java 2001/11/21 16:25:56 1.5 @@ -87,33 +87,32 @@ */ public class JavaImplWriter extends JavaWriter { private Binding binding; - private HashMap operationParameters; + private SymbolTable symbolTable; + private BindingEntry bEntry; /** * Constructor. */ protected JavaImplWriter( Emitter emitter, - Binding binding, - HashMap operationParameters) { - super(emitter, binding.getQName(), "Impl", "java", + BindingEntry bEntry, + SymbolTable symbolTable) { + super(emitter, bEntry, "Impl", "java", JavaUtils.getMessage("genImpl00")); - this.binding = binding; - this.operationParameters = operationParameters; + this.binding = bEntry.getBinding(); + this.symbolTable = symbolTable; + this.bEntry = bEntry; } // ctor /** * Write the body of the binding's stub file. */ protected void writeFileBody() throws IOException { - if (operationParameters == null) - throw new IOException( - JavaUtils.getMessage("emitFail01", "" + qname)); - PortType portType = binding.getPortType(); - String portTypeName = emitter.emitFactory.getJavaName(portType.getQName()); + PortTypeEntry ptEntry = symbolTable.getPortTypeEntry(portType.getQName()); + String portTypeName = ptEntry.getName(); boolean isRPC = true; - if (emitter.wsdlAttr.getBindingStyle(binding) == WsdlAttributes.STYLE_DOCUMENT) { + if (bEntry.getBindingStyle() == BindingEntry.STYLE_DOCUMENT) { isRPC = false; } pw.print("public class " + className + " implements " + portTypeName); @@ -126,7 +125,8 @@ List operations = binding.getBindingOperations(); for (int i = 0; i < operations.size(); ++i) { BindingOperation operation = (BindingOperation) operations.get(i); - Parameters parameters = (Parameters) operationParameters.get(operation.getOperation().getName()); + Parameters parameters = + ptEntry.getParameters(operation.getOperation().getName()); // Get the soapAction from the String soapAction = ""; 1.4 +1 -1 xml-axis/java/src/org/apache/axis/wsdl/JavaHolderWriter.java Index: JavaHolderWriter.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/JavaHolderWriter.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- JavaHolderWriter.java 2001/11/09 19:57:45 1.3 +++ JavaHolderWriter.java 2001/11/21 16:25:56 1.4 @@ -77,7 +77,7 @@ * Generate the holder for the given complex type. */ protected void writeFileBody() throws IOException { - String holderType = type.getJavaLocalName(); + String holderType = Utils.getJavaLocalName(type.getName()); pw.println("public final class " + className + " implements java.io.Serializable {"); pw.println(" public " + holderType + " _value;"); pw.println(); 1.3 +4 -2 xml-axis/java/src/org/apache/axis/wsdl/JavaFaultWriter.java Index: JavaFaultWriter.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/JavaFaultWriter.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- JavaFaultWriter.java 2001/11/09 15:02:17 1.2 +++ JavaFaultWriter.java 2001/11/21 16:25:56 1.3 @@ -69,13 +69,15 @@ */ public class JavaFaultWriter extends JavaWriter { private Fault fault; + private SymbolTable symbolTable; /** * Constructor. */ - protected JavaFaultWriter(Emitter emitter, QName qname, Fault fault) { + protected JavaFaultWriter(Emitter emitter, QName qname, Fault fault, SymbolTable symbolTable) { super(emitter, qname, "", "java", JavaUtils.getMessage("genFault00")); this.fault = fault; + this.symbolTable = symbolTable; } // ctor /** @@ -86,7 +88,7 @@ Vector params = new Vector(); - emitter.partStrings(params, fault.getMessage().getOrderedParts(null), false); + symbolTable.partStrings(params, fault.getMessage().getOrderedParts(null)); for (int i = 0; i < params.size(); i += 2) pw.println(" public " + params.get(i) + " " + params.get(i + 1) + ";"); 1.5 +2 -2 xml-axis/java/src/org/apache/axis/wsdl/JavaEnumTypeWriter.java Index: JavaEnumTypeWriter.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/JavaEnumTypeWriter.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- JavaEnumTypeWriter.java 2001/11/09 19:57:45 1.4 +++ JavaEnumTypeWriter.java 2001/11/21 16:25:56 1.5 @@ -91,7 +91,7 @@ // The first index is the base type. Get its java name. String baseType = ((Type) elements.get(0)).getJavaName(); - String javaName = type.getJavaLocalName(); + String javaName = Utils.getJavaLocalName(type.getName()); // Note: // The current JAX-RPC spec indicates that enumeration is supported for all simple types. @@ -100,7 +100,7 @@ // support only the enumeration of Strings. // The current state of the AXIS code only supports enumerations of Strings. If JAX-RPC // does introduce new bindings, changes will be required in this method, in EnumSerialization, - // and in TypeFactory.getEnumerationBaseAndValues. + // and in JavaTypeWriter.getEnumerationBaseAndValues. pw.println("public class " + javaName + " implements java.io.Serializable {"); // Each object has a private _value_ variable to store the base value 1.4 +12 -10 xml-axis/java/src/org/apache/axis/wsdl/JavaDeployWriter.java Index: JavaDeployWriter.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/JavaDeployWriter.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- JavaDeployWriter.java 2001/11/09 19:57:45 1.3 +++ JavaDeployWriter.java 2001/11/21 16:25:56 1.4 @@ -59,6 +59,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map; +import java.util.Vector; import javax.wsdl.Binding; import javax.wsdl.BindingOperation; @@ -74,17 +75,19 @@ */ public class JavaDeployWriter extends JavaWriter { private Definition definition; + private SymbolTable symbolTable; /** * Constructor. */ - protected JavaDeployWriter(Emitter emitter, Definition definition) { + protected JavaDeployWriter(Emitter emitter, Definition definition, SymbolTable symbolTable) { super(emitter, new QName(definition.getTargetNamespace(), "deploy"), "", "xml", JavaUtils.getMessage("genDeploy00")); this.definition = definition; + this.symbolTable = symbolTable; } // ctor /** @@ -136,9 +139,9 @@ * Write out bean mappings for each type */ private void writeDeployTypes() throws IOException { - HashMap types = emitter.getTypeFactory().getTypes(); + Vector types = symbolTable.getTypes(); - if (types.isEmpty()) return; + if (types.size() == 0) return; pw.println(); @@ -146,9 +149,8 @@ HashMap nsMap = new HashMap(); int i = 1; String nsPrefix = null; - Iterator it = types.values().iterator(); - while (it.hasNext()) { - Type type = (Type) it.next(); + for (int j = 0; j < types.size(); ++j) { + Type type = (Type) types.elementAt(j); if (type.getBaseType() == null && type.getShouldEmit()) { if (!nsMap.containsKey(type.getQName().getNamespaceURI())) { pw.println(""); @@ -159,9 +161,8 @@ } } pw.println(">"); - it = types.values().iterator(); - while (it.hasNext()) { - Type type = (Type) it.next(); + for (int j = 0; j < types.size(); ++j) { + Type type = (Type) types.elementAt(j); if (type.getBaseType() == null && type.getShouldEmit()) { nsPrefix = (String)nsMap.get(type.getQName().getNamespaceURI()); pw.println(" <" + nsPrefix + ":" + Utils.capitalizeFirstChar(type.getQName().getLocalPart()) @@ -176,9 +177,10 @@ */ private void writeDeployPort(Port port) throws IOException { Binding binding = port.getBinding(); + BindingEntry bEntry = symbolTable.getBindingEntry(binding.getQName()); String serviceName = port.getName(); - boolean isRPC = (emitter.wsdlAttr.getBindingStyle(binding) == WsdlAttributes.STYLE_RPC); + boolean isRPC = (bEntry.getBindingStyle() == BindingEntry.STYLE_RPC); pw.println(" "); 1.4 +7 -4 xml-axis/java/src/org/apache/axis/wsdl/JavaDefinitionWriter.java Index: JavaDefinitionWriter.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/JavaDefinitionWriter.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- JavaDefinitionWriter.java 2001/11/09 19:57:45 1.3 +++ JavaDefinitionWriter.java 2001/11/21 16:25:56 1.4 @@ -76,15 +76,18 @@ Writer undeployWriter = null; Emitter emitter; Definition definition; + SymbolTable symbolTable; /** * Constructor. */ - protected JavaDefinitionWriter(Emitter emitter, Definition definition) { - deployWriter = new JavaDeployWriter(emitter, definition); - undeployWriter = new JavaUndeployWriter(emitter, definition); + protected JavaDefinitionWriter(Emitter emitter, Definition definition, + SymbolTable symbolTable) { + deployWriter = new JavaDeployWriter(emitter, definition, symbolTable); + undeployWriter = new JavaUndeployWriter(emitter, definition, symbolTable); this.emitter = emitter; this.definition = definition; + this.symbolTable = symbolTable; } // ctor /** @@ -121,7 +124,7 @@ Fault fault = (Fault) fi.next(); String exceptionName = Utils.capitalizeFirstChar(Utils.xmlNameToJava(fault.getName())); QName faultName = new QName(definition.getTargetNamespace(), exceptionName); - new JavaFaultWriter(emitter, faultName, fault).write(); + new JavaFaultWriter(emitter, faultName, fault, symbolTable).write(); } } // writeFaults 1.6 +7 -9 xml-axis/java/src/org/apache/axis/wsdl/JavaBindingWriter.java Index: JavaBindingWriter.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/JavaBindingWriter.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- JavaBindingWriter.java 2001/11/09 19:57:45 1.5 +++ JavaBindingWriter.java 2001/11/21 16:25:56 1.6 @@ -78,18 +78,16 @@ protected JavaBindingWriter( Emitter emitter, Binding binding, - HashMap operationParameters) { - QName bindingQName = new QName(binding.getQName().getNamespaceURI(), - Utils.capitalizeFirstChar(Utils.xmlNameToJava(binding.getQName().getLocalPart()))); - binding.setQName (bindingQName); - stubWriter = new JavaStubWriter(emitter, binding, operationParameters); + SymbolTable symbolTable) { + BindingEntry bEntry = symbolTable.getBindingEntry(binding.getQName()); + stubWriter = new JavaStubWriter(emitter, bEntry, symbolTable); if (emitter.bEmitSkeleton) { - skelWriter = new JavaSkelWriter(emitter, binding, operationParameters); - String fileName = bindingQName.getLocalPart() + "Impl.java"; + skelWriter = new JavaSkelWriter(emitter, bEntry, symbolTable); + String fileName = Utils.getJavaLocalName(bEntry.getName()) + "Impl.java"; try { // NOTE: Where does the fileExists method really belong? - if (!((JavaWriter) stubWriter).fileExists (fileName, bindingQName.getNamespaceURI())) { - implWriter = new JavaImplWriter(emitter, binding, operationParameters); + if (!((JavaWriter) stubWriter).fileExists (fileName, binding.getQName().getNamespaceURI())) { + implWriter = new JavaImplWriter(emitter, bEntry, symbolTable); } } catch (IOException ioe) { 1.105 +62 -416 xml-axis/java/src/org/apache/axis/wsdl/Emitter.java Index: Emitter.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/Emitter.java,v retrieving revision 1.104 retrieving revision 1.105 diff -u -r1.104 -r1.105 --- Emitter.java 2001/11/21 15:50:46 1.104 +++ Emitter.java 2001/11/21 16:25:56 1.105 @@ -60,24 +60,16 @@ import javax.wsdl.Binding; import javax.wsdl.Definition; -import javax.wsdl.Fault; import javax.wsdl.Import; -import javax.wsdl.Input; import javax.wsdl.Message; -import javax.wsdl.Operation; -import javax.wsdl.Output; -import javax.wsdl.Part; import javax.wsdl.PortType; -import javax.wsdl.QName; import javax.wsdl.Service; import javax.wsdl.factory.WSDLFactory; import javax.wsdl.xml.WSDLReader; import java.io.IOException; import java.util.ArrayList; -import java.util.Collection; import java.util.Enumeration; import java.util.HashMap; -import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -101,7 +93,6 @@ protected Document doc = null; protected Definition def = null; - protected WsdlAttributes wsdlAttr = null; protected boolean bEmitSkeleton = false; protected boolean bMessageContext = false; protected boolean bEmitTestCase = false; @@ -113,36 +104,30 @@ protected ArrayList fileList = new ArrayList(); protected Namespaces namespaces = null; protected HashMap delaySetMap = null; - protected TypeFactory emitFactory = null; protected WriterFactory writerFactory = null; + protected SymbolTable symbolTable = null; - // portTypesInfo is a Hashmap of pairs where HashMap2 is a - // Hashmap of pairs. - protected HashMap portTypesInfo = null; - /** * Default constructor. */ public Emitter(WriterFactory writerFactory) { this.writerFactory = writerFactory; - portTypesInfo = new HashMap(); } // ctor /** * Construct an Emitter that initially looks like the given Emitter. */ public Emitter(Emitter that) { - this.bEmitSkeleton = that.bEmitSkeleton; - this.bMessageContext = that.bMessageContext; - this.bEmitTestCase = that.bEmitTestCase; - this.bVerbose = that.bVerbose; - this.bGenerateImports = that.bGenerateImports; - this.outputDir = that.outputDir; - this.scope = that.scope; - this.namespaces = that.namespaces; - this.emitFactory = that.emitFactory; - this.portTypesInfo = that.portTypesInfo; - this.writerFactory = that.writerFactory; + this.bEmitSkeleton = that.bEmitSkeleton; + this.bMessageContext = that.bMessageContext; + this.bEmitTestCase = that.bEmitTestCase; + this.bVerbose = that.bVerbose; + this.bGenerateImports = that.bGenerateImports; + this.outputDir = that.outputDir; + this.scope = that.scope; + this.namespaces = that.namespaces; + this.writerFactory = that.writerFactory; + this.symbolTable = that.symbolTable; } // ctor /** @@ -179,12 +164,13 @@ if (delaySetMap != null) { namespaces.putAll(delaySetMap); } - emitFactory = new TypeFactory(namespaces); + + symbolTable = new SymbolTable(namespaces); emit(def, doc); // Output deploy.xml and undeploy.xml outside of the recursive emit method. if (bEmitSkeleton) { - Writer writer = writerFactory.getWriter(def); + Writer writer = writerFactory.getWriter(def, symbolTable); writer.write(); } } @@ -199,19 +185,11 @@ this.def = def; this.doc = doc; - // Generate types from doc - if (doc != null) { - emitFactory.buildTypes(doc); - if (bVerbose) { - System.out.println(JavaUtils.getMessage("types00")); - emitFactory.dump(); - } - // Output Java classes for types - writeTypes(); + if (def == null) { + symbolTable.add(null, doc); } + else { - - if (def != null) { // Generated all the imported XML if (bGenerateImports) { @@ -231,11 +209,20 @@ } } - // Collect information about ports and operations - wsdlAttr = new WsdlAttributes(def, new HashMap()); + symbolTable.add(def, doc); - firstPass(); + writerFactory.writerPass(def, symbolTable); + if (bVerbose) { + System.out.println(JavaUtils.getMessage("types00")); + dumpTypes(); + } + // Output Java classes for types + writeTypes(); + + // Output messages + writeMessages(); + // Output interfaces for portTypes writePortTypes(); @@ -248,6 +235,18 @@ } // emit /** + * Dump Types for debugging + */ + public void dumpTypes() { + Vector types = symbolTable.getTypes(); + for (int i = 0; i < types.size(); ++i) { + Type et = (Type) types.elementAt(i); + System.out.println(); + System.out.println(et); + } + } // dumpTypes + + /** * Look for a NStoPkg.properties file in the CLASSPATH. If it exists, * then collect the namespace->package mappings from it. */ @@ -269,50 +268,6 @@ } } // getNStoPkgFromPropsFile - /** - * Do some cleanup of the 'symbol table' and add our own symbol table structures - */ - protected void firstPass() throws IOException { - - // PortTypes and Services can share the same name. If they do in this Definition, - // force their names to be suffixed with _PortType and _Service, respectively. - resolvePortTypeServiceNameClashes(); - - // portTypesInfo is a Hashmap of pairs where HashMap2 is a - // Hashmap of pairs. - createPortTypesInfo(); - } // firstPass - - // portTypesInfo is a Hashmap of pairs where HashMap2 is a HashMap of - // pairs. Walk through the symbol table and create this HashMap of - // a HashMap of Parameters. - private void createPortTypesInfo() throws IOException { - Iterator i = def.getPortTypes().values().iterator(); - while (i.hasNext()) { - PortType portType = (PortType) i.next(); - - // If the portType is undefined, then we're parsing a Definition - // that didn't contain a portType, merely a binding that referred - // to a non-existent port type. Don't bother with it. - if (!portType.isUndefined()) { - HashMap portTypeInfo = new HashMap(); - - // Remove Duplicates - happens with only a few WSDL's. No idea why!!! - // (like http://www.xmethods.net/tmodels/InteropTest.wsdl) - // TODO: Remove this patch... - // NOTE from RJB: this is a WSDL4J bug and the WSDL4J guys have been notified. - Iterator operations = (new HashSet(portType.getOperations())).iterator(); - while(operations.hasNext()) { - Operation operation = (Operation) operations.next(); - String namespace = portType.getQName().getNamespaceURI(); - Parameters parms = parameters(operation, namespace); - portTypeInfo.put(operation.getName(), parms); - } - portTypesInfo.put(portType.getQName(), portTypeInfo); - } - } - } // createPortTypesInfo - /////////////////////////////////////////////////// // // Command line switches @@ -405,26 +360,19 @@ } /** - * PortTypes and Services can share the same name. If they do in this Definition, - * force their names to be suffixed with _PortType and _Service, respectively. These names - * are placed back in the QName of the PortType and Service objects themselves. + * Generate the bindings for all messages. */ - private void resolvePortTypeServiceNameClashes() { - Map portTypes = def.getPortTypes(); - Map services = def.getServices(); - Iterator pti = portTypes.keySet().iterator(); - while (pti.hasNext()) { - QName ptName = (QName) pti.next(); - Iterator si = services.keySet().iterator(); - while (si.hasNext()) { - QName sName = (QName) si.next(); - if (ptName.equals(sName)) { - ptName.setLocalPart(ptName.getLocalPart() + "_Port"); - sName.setLocalPart(sName.getLocalPart() + "_Service"); - } - } + protected void writeMessages() throws IOException { + Map messages = def.getMessages(); + Iterator i = messages.values().iterator(); + + while (i.hasNext()) { + Message message = (Message) i.next(); + + Writer writer = writerFactory.getWriter(message, symbolTable); + writer.write(); } - } // resolvePortTypeServiceNameClashes + } // writeMessages /** * Generate the bindings for all port types. @@ -440,310 +388,13 @@ // that didn't contain a portType, merely a binding that referred // to a non-existent port type. Don't bother writing it. if (!portType.isUndefined()) { - HashMap operationParameters = (HashMap) portTypesInfo.get(portType.getQName()); - Writer writer = writerFactory.getWriter(portType, operationParameters); + Writer writer = writerFactory.getWriter(portType, symbolTable); writer.write(); } } } // writePortTypes /** - * This class simply collects - */ - protected static class Parameter { - - // constant values for the parameter mode. - public static final byte IN = 1; - public static final byte OUT = 2; - public static final byte INOUT = 3; - - public String name; - public String type; - public byte mode = IN; - - public String toString() { - return "(" + type + ", " + name + ", " - + (mode == IN ? "IN)" : mode == INOUT ? "INOUT)" : "OUT)"); - } // toString - } // class Parameter - - - /** - * For the given operation, this method returns the parameter info conveniently collated. - * There is a bit of processing that is needed to write the interface, stub, and skeleton. - * Rather than do that processing 3 times, it is done once, here, and stored in the - * Parameters object. - */ - protected Parameters parameters(Operation operation, String namespace) throws IOException { - Parameters parameters = new Parameters(); - - // The input and output Vectors, when filled in, will be of the form: - // {, , , , ..., , } - Vector inputs = new Vector(); - Vector outputs = new Vector(); - - List parameterOrder = operation.getParameterOrdering(); - - // Handle parameterOrder="", which is techinically illegal - if (parameterOrder != null && parameterOrder.isEmpty()) { - parameterOrder = null; - } - - // All input parts MUST be in the parameterOrder list. It is an error otherwise. - if (parameterOrder != null) { - Input input = operation.getInput(); - if (input != null) { - Message inputMsg = input.getMessage(); - Map allInputs = inputMsg.getParts(); - Collection orderedInputs = inputMsg.getOrderedParts(parameterOrder); - if (allInputs.size() != orderedInputs.size()) { - throw new IOException(JavaUtils.getMessage("emitFail00", operation.getName())); - } - } - } - - // Collect all the input parameters - Input input = operation.getInput(); - if (input != null) { - partStrings(inputs, - input.getMessage().getOrderedParts(null), - (wsdlAttr.getInputBodyType(operation) == WsdlAttributes.USE_LITERAL)); - } - - // Collect all the output parameters - Output output = operation.getOutput(); - if (output != null) { - partStrings(outputs, - output.getMessage().getOrderedParts(null), - (wsdlAttr.getOutputBodyType(operation) == WsdlAttributes.USE_LITERAL)); - } - - if (parameterOrder != null) { - // Construct a list of the parameters in the parameterOrder list, determining the - // mode of each parameter and preserving the parameterOrder list. - for (int i = 0; i < parameterOrder.size(); ++i) { - String name = (String) parameterOrder.get(i); - - // index in the inputs Vector of the given name, -1 if it doesn't exist. - int index = getPartIndex(name, inputs); - - // index in the outputs Vector of the given name, -1 if it doesn't exist. - int outdex = getPartIndex(name, outputs); - - if (index > 0) { - // The mode of this parameter is either in or inout - addInishParm(inputs, outputs, index, outdex, parameters, true); - } - else if (outdex > 0) { - addOutParm(outputs, outdex, parameters, true); - } - else { - System.err.println(JavaUtils.getMessage("noPart00", name)); - } - } - } - - // Get the mode info about those parts that aren't in the parameterOrder list. - // Since they're not in the parameterOrder list, the order doesn't matter. - // Add the input and inout parts first, then add the output parts. - for (int i = 1; i < inputs.size(); i += 2) { - int outdex = getPartIndex((String) inputs.get(i), outputs); - addInishParm(inputs, outputs, i, outdex, parameters, false); - } - - // Now that the remaining in and inout parameters are collected, the first entry in the - // outputs Vector is the return value. The rest are out parameters. - if (outputs.size() > 0) { - parameters.returnType = (String) outputs.get(0); - parameters.returnName = (String) outputs.get(1); - ++parameters.outputs; - for (int i = 3; i < outputs.size(); i += 2) { - addOutParm(outputs, i, parameters, false); - } - } - - // Collect the list of faults into a single string, separated by commas. - Map faults = operation.getFaults(); - Iterator i = faults.values().iterator(); - while (i.hasNext()) { - Fault fault = (Fault) i.next(); - String exceptionName = Utils.capitalizeFirstChar(Utils.xmlNameToJava((String) fault.getName())); - if (parameters.faultString == null) - parameters.faultString = exceptionName; - else - parameters.faultString = parameters.faultString + ", " + exceptionName; - } - - if (parameters.returnType == null) - parameters.returnType = "void"; - constructSignatures(parameters, operation.getName()); - return parameters; - } // parameters - - /** - * Return the index of the given name in the given Vector, -1 if it doesn't exist. - */ - private int getPartIndex(String name, Vector v) { - for (int i = 1; i < v.size(); i += 2) { - if (name.equals(v.get(i))) { - return i; - } - } - return -1; - } // getPartIndex - - /** - * Add an in or inout parameter to the parameters object. - */ - private void addInishParm(Vector inputs, Vector outputs, int index, int outdex, Parameters parameters, boolean trimInput) { - Parameter p = new Parameter(); - p.name = (String) inputs.get(index); - p.type = (String) inputs.get(index - 1); - - // Should we remove the given parameter type/name entries from the Vector? - if (trimInput) { - inputs.remove(index); - inputs.remove(index - 1); - } - - // At this point we know the name and type of the parameter, and that it's at least an - // in parameter. Now check to see whether it's also in the outputs Vector. If it is, - // then it's an inout parameter. - if (outdex > 0 && p.type.equals(outputs.get(outdex - 1))) { - outputs.remove(outdex); - outputs.remove(outdex - 1); - p.mode = Parameter.INOUT; - ++parameters.inouts; - } - else { - ++parameters.inputs; - } - parameters.list.add(p); - } // addInishParm - - /** - * Add an output parameter to the parameters object. - */ - private void addOutParm(Vector outputs, int outdex, Parameters parameters, boolean trim) { - Parameter p = new Parameter(); - p.name = (String) outputs.get(outdex); - p.type = (String) outputs.get(outdex - 1); - if (trim) { - outputs.remove(outdex); - outputs.remove(outdex - 1); - } - p.mode = Parameter.OUT; - ++parameters.outputs; - parameters.list.add(p); - } // addOutParm - - /** - * Construct the signatures. signature is used by both the interface and the stub. - * skelSig is used by the skeleton. - */ - private void constructSignatures(Parameters parms, String name) { - int allOuts = parms.outputs + parms.inouts; - String signature = " public " + parms.returnType + " " + name + "("; - String axisSig = " public " + parms.returnType + " " + name + "("; - String skelSig = null; - - if (allOuts == 0) - skelSig = " public void " + name + "("; - else - skelSig = " public Object " + name + "("; - - if (bMessageContext) { - skelSig = skelSig + "org.apache.axis.MessageContext ctx"; - axisSig = axisSig + "org.apache.axis.MessageContext ctx"; - if ((parms.inputs + parms.inouts) > 0) { - skelSig = skelSig + ", "; - } - if (parms.list.size() > 0) { - axisSig = axisSig + ", "; - } - } - boolean needComma = false; - - for (int i = 0; i < parms.list.size(); ++i) { - Parameter p = (Parameter) parms.list.get(i); - - if (needComma) { - signature = signature + ", "; - axisSig = axisSig + ", "; - if (p.mode != Parameter.OUT) - skelSig = skelSig + ", "; - } - else - needComma = true; - if (p.mode == Parameter.IN) { - signature = signature + p.type + " " + p.name; - axisSig = axisSig + p.type + " " + p.name; - skelSig = skelSig + p.type + " " + p.name; - } - else if (p.mode == Parameter.INOUT) { - signature = signature + Utils.holder(p.type) + " " + p.name; - axisSig = axisSig + Utils.holder(p.type) + " " + p.name; - skelSig = skelSig + p.type + " " + p.name; - } - else// (p.mode == Parameter.OUT) - { - signature = signature + Utils.holder(p.type) + " " + p.name; - axisSig = axisSig + Utils.holder(p.type) + " " + p.name; - } - } - signature = signature + ") throws java.rmi.RemoteException"; - axisSig = axisSig + ") throws java.rmi.RemoteException"; - skelSig = skelSig + ") throws java.rmi.RemoteException"; - if (parms.faultString != null) { - signature = signature + ", " + parms.faultString; - axisSig = axisSig + ", " + parms.faultString; - skelSig = skelSig + ", " + parms.faultString; - } - parms.signature = signature; - parms.axisSignature = axisSig; - parms.skelSignature = skelSig; - } // constructSignatures - - /** - * This method returns a vector containing the Java types (even indices) and - * names (odd indices) of the parts. - */ - protected void partStrings(Vector v, Collection parts, boolean literal) { - Iterator i = parts.iterator(); - - while (i.hasNext()) { - Part part = (Part) i.next(); - QName elementName = part.getElementName(); - QName typeName = part.getTypeName(); - if (literal) { - if (elementName != null) { - v.add(Utils.capitalizeFirstChar(elementName.getLocalPart())); - v.add(part.getName()); - } - } else { - // Encoded - if (typeName != null) { - // Handle the special "java" namespace for types - if (typeName.getNamespaceURI().equalsIgnoreCase("java")) { - v.add(typeName.getLocalPart()); - } else { - v.add(emitFactory.getType(typeName).getJavaName()); - } - v.add(part.getName()); - } else if (elementName != null) { - // Handle the special "java" namespace for types - if (elementName.getNamespaceURI().equalsIgnoreCase("java")) { - v.add(elementName.getLocalPart()); - } else { - v.add(emitFactory.getType(elementName).getJavaName()); - } - v.add(part.getName()); - } - } - } - } // partStrings - - /** * Generate the stubs and skeletons for all binding tags. */ protected void writeBindings() throws IOException { @@ -752,6 +403,8 @@ while (i.hasNext()) { Binding binding = (Binding) i.next(); + BindingEntry bEntry = + symbolTable.getBindingEntry(binding.getQName()); // If the binding is undefined, then we're parsing a Definition // that didn't contain a binding, merely a service that referred @@ -759,12 +412,10 @@ if (!binding.isUndefined()) { // If this isn't a SOAP binding, skip it - if (wsdlAttr.getBindingType(binding) != WsdlAttributes.TYPE_SOAP) { + if (bEntry.getBindingType() != BindingEntry.TYPE_SOAP) { continue; } - - HashMap operationParameters = (HashMap) portTypesInfo.get(binding.getPortType().getQName()); - Writer writer = writerFactory.getWriter(binding, operationParameters); + Writer writer = writerFactory.getWriter(binding, symbolTable); writer.write(); } } @@ -779,7 +430,7 @@ while (i.hasNext()) { Service service = (Service) i.next(); - Writer writer = writerFactory.getWriter(service, portTypesInfo); + Writer writer = writerFactory.getWriter(service, symbolTable); writer.write(); } } @@ -794,12 +445,11 @@ * If generating serverside (skeleton) spit out beanmappings */ protected void writeTypes() throws IOException { - HashMap types = emitFactory.getTypes(); - Iterator i = types.values().iterator(); - while (i.hasNext()) { - Type type = (Type) i.next(); + Vector types = symbolTable.getTypes(); + for (int i = 0; i < types.size(); ++i) { + Type type = (Type) types.elementAt(i); if (type.isDefined() && type.getShouldEmit() && type.getBaseType() == null) { - Writer writer = writerFactory.getWriter(type); + Writer writer = writerFactory.getWriter(type, symbolTable); writer.write(); } } @@ -818,8 +468,4 @@ public Namespaces getNamespaces() { return namespaces; } // getNamespaces - - public TypeFactory getTypeFactory() { - return emitFactory; - } // getTypeFactory } 1.1 xml-axis/java/src/org/apache/axis/wsdl/SymTabEntry.java Index: SymTabEntry.java =================================================================== /* * The Apache Software License, Version 1.1 * * * Copyright (c) 2001 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The names "Axis" and "Apache Software Foundation" must * not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact apache@apache.org. * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * . */ package org.apache.axis.wsdl; import java.util.HashMap; import javax.wsdl.QName; /** * SymTabEntry is the base class for all symbol table entries. It contains four things: * - a QName * - space for a Writer-specific name (for example, in Wsdl2java, this will be the Java name) * - isReferenced flag indicating whether this entry is referenced by other entries * - dynamicVars; a mechanism for Writers to add additional context information onto entries. */ public abstract class SymTabEntry { // The QName of this entry is immutable. There is no setter for it. protected QName qname; // The name is Writer implementation dependent. For example, in Wsdl2java, this will become // the Java name. protected String name; // Is this entry referenced by any other entry? private boolean isReferenced = true; private HashMap dynamicVars = new HashMap(); protected SymTabEntry(QName qname) { this.qname = qname; } // ctor protected SymTabEntry(QName qname, String name) { this.qname = qname; this.name = name; } // ctor /** * Get the QName of this entry. */ public QName getQName() { return qname; } // getQName /** * Get the name of this entry. The name is Writer-implementation-dependent. For example, in * Wsdl2java, this will become the Java name. */ public String getName() { return name; } // getName /** * Set the name of this entry. This method is not called by the framework, it is only called * by the Writer implementation. */ public void setName(String name) { this.name = name; } // setName /** * Is this entry referenced by any other entry in the symbol table? */ public boolean isReferenced() { return isReferenced; } // isReferenced /** * Set the isReferenced variable, default value is true. */ protected void setIsReferenced(boolean isReferenced) { this.isReferenced = isReferenced; } // setIsReferenced /** * There may be information that does not exist in WSDL4J/DOM structures and does not exist in * our additional structures, but that thw Writer implementation will need. This information is * most likely context-relative, so the DynamicVar map is provided for the Writers to store/ * retrieve their particular information. */ public Object getDynamicVar(Object key) { return dynamicVars.get(key); } // getDynamicVar public void setDynamicVar(Object key, Object value) { dynamicVars.put(key, value); } // setDynamicVar /** * Collate the info in this object in string form. */ public String toString() { return "QName: " + qname + '\n' + "name: " + name + '\n' + "isReferenced? " + isReferenced + '\n'; } // toString } // abstract class SymTabEntry 1.1 xml-axis/java/src/org/apache/axis/wsdl/SymbolTable.java Index: SymbolTable.java =================================================================== /* * The Apache Software License, Version 1.1 * * * Copyright (c) 2001 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The names "Axis" and "Apache Software Foundation" must * not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact apache@apache.org. * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * . */ package org.apache.axis.wsdl; import java.io.IOException; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Vector; import javax.wsdl.Binding; import javax.wsdl.BindingFault; import javax.wsdl.BindingOperation; import javax.wsdl.Definition; import javax.wsdl.Fault; import javax.wsdl.Input; import javax.wsdl.Message; import javax.wsdl.Operation; import javax.wsdl.Output; import javax.wsdl.Part; import javax.wsdl.PortType; import javax.wsdl.QName; import javax.wsdl.Service; import com.ibm.wsdl.extensions.http.HTTPBinding; import com.ibm.wsdl.extensions.soap.SOAPBinding; import com.ibm.wsdl.extensions.soap.SOAPBody; import org.apache.axis.utils.JavaUtils; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.w3c.dom.NodeList; /** * This class represents a table of all of the top-level symbols from a set of WSDL Definitions and * DOM Documents: XML types; WSDL messages, portTypes, bindings, and services. * * This symbolTable contains entries of the form where key is of type QName and value is * of type Vector. The Vector's elements are all of the objects that have the given QName. This is * necessary since names aren't unique among the WSDL types. message, portType, binding, service, * could all have the same QName and are differentiated merely by type. SymbolTable contains * type-specific getters to bypass the Vector layer: * public PortTypeEntry getPortTypeEntry(QName name), etc. */ public class SymbolTable { // Mapping from Namespace to Java Package private Namespaces namespaces; // The actual symbol table. This symbolTable contains entries of the form // where key is of type QName and value is of type Vector. The // Vector's elements are all of the objects that have the given QName. This // is necessary since names aren't unique among the WSDL types. message, // portType, binding, service, could all have the same QName and are // differentiated merely by type. SymbolTable contains type-specific // getters to bypass the Vector layer: // public PortTypeEntry getPortTypeEntry(QName name), etc. private HashMap symbolTable = new HashMap(); // A list of the Type elements in the symbol table private Vector types = new Vector(); /** * Construct a symbol table with the given Namespaces. */ public SymbolTable(Namespaces namespaces) { this.namespaces = namespaces; } // ctor /** * Add the given Definition and Document information to the symbol table, populating it with * SymTabEntries for each of the top-level symbols. */ protected void add(Definition def, Document doc) throws IOException { if (doc != null) { populateTypes(doc); } if (def != null) { populateMessages(def); populatePortTypes(def); populateBindings(def); populateServices(def); } } // add /** * Populate the symbol table with all of the Types from the Document. */ private void populateTypes(Document doc) { addTypes(doc); } // populateTypes /** * Utility method which walks the Document and creates Type objects for * each complexType, simpleType, or element referenced or defined. */ private void addTypes(Node node) { if (node == null) { return; } // Get the kind of node (complexType, wsdl:part, etc.) QName nodeKind = Utils.getNodeQName(node); if (nodeKind != null) { if (nodeKind.getLocalPart().equals("complexType") && Utils.isSchemaNS(nodeKind.getNamespaceURI())) { // This is a definition of a complex type. // Create a Type. createTypeFromDef(node, false); } if (nodeKind.getLocalPart().equals("simpleType") && Utils.isSchemaNS(nodeKind.getNamespaceURI())) { // This is a definition of a simple type, which could be an enum // Create a Type. createTypeFromDef(node, false); } else if (nodeKind.getLocalPart().equals("element") && Utils.isSchemaNS(nodeKind.getNamespaceURI())) { // If the element has a type/ref attribute, create // a Type representing the referenced type. if (Utils.getAttribute(node, "type") != null || Utils.getAttribute(node, "ref") != null) { createTypeFromRef(node); } // Create a type representing an element. (This may // seem like overkill, but is necessary to support ref= // and element=. createTypeFromDef(node, true); } else if (nodeKind.getLocalPart().equals("part") && Utils.isWsdlNS(nodeKind.getNamespaceURI())) { // This is a wsdl part. Create an Type representing the reference createTypeFromRef(node); } } // Recurse through children nodes NodeList children = node.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { addTypes(children.item(i)); } } // addTypes /** * Create a Type from the indicated node, which defines a type * that represents a complexType, simpleType or element (for ref=). */ private void createTypeFromDef(Node node, boolean isElement) { // If this is not an element, make sure it is not an anonymous type. // If it is, the the existing ElementType will be used. If // not, create a new type. if (!isElement && Utils.getAttribute(node, "name") == null) { return; } // Get the QName of the node's name attribute value QName qName = Utils.getNodeNameQName(node); if (qName != null) { map(qName.getNamespaceURI()); // If the node has a type or ref attribute, get the // ultimate ref'd type QName refQName = Utils.getNodeTypeRefQName(node); if (refQName != null) { Type refType = null; while (refQName != null) { refType = getTypeEntry(refQName); refQName = null; if (refType != null && refType.getNode() != null) { refQName = Utils.getNodeTypeRefQName(refType.getNode()); } } // Create a type from the referenced type symbolTablePut(new ElementType(qName, refType, node)); } else { // See if this is an array definition. QName arrayQName = getArrayElementQName(node); if (arrayQName != null) { String javaName = getJavaName(arrayQName)+"[]"; Type arrayType = null; if (isElement) { arrayType = new ElementType(qName, javaName, node); } else { arrayType = new DefinedType(qName, javaName, node); } symbolTablePut(arrayType); arrayType.setShouldEmit(false); } else { // Create a Type representing a base type or non-base type String baseJavaName = Utils.getBaseJavaName(qName); if (baseJavaName != null) { symbolTablePut(new BaseJavaType(qName)); } else if (isElement) { symbolTablePut(new ElementType(qName, getJavaName(qName), node)); } else { symbolTablePut(new DefinedType(qName, getJavaName(qName), node)); } } } } } // createTypeFromDef /** * Node may contain a reference (via type=, ref=, or element= attributes) to * another type. Create a Type object representing this referenced type. */ private void createTypeFromRef(Node node) { // Get the QName of the node's type attribute value QName qName = Utils.getNodeTypeRefQName(node); if (qName != null) { String javaName = getJavaName(qName); Type type = getTypeEntry(qName); if (type == null) { // Type not defined, add a base java type or a refdType String baseJavaName = Utils.getBaseJavaName(qName); if (baseJavaName != null) symbolTablePut(new BaseJavaType(qName)); else symbolTablePut(new RefdType(qName, javaName)); } else { // Type exists, update shouldEmit flag if necessary if (type instanceof ElementType && type.isDefined() && type.getJavaName().indexOf("[") < 0 && ((ElementType) type).getDefinedDirectly()) { type.setShouldEmit(true); } } } } // createTypeFromRef /** * If the specified node represents an array encoding of one of the following * forms, then return the qname repesenting the element type of the array. * * JAX-RPC Style 2: * * * * * * * * * JAX-RPC Style 3: * * * * * * * * * * */ private QName getArrayElementQName(Node node) { if (node == null) { return null; } // If the node kind is an element, dive into it. QName nodeKind = Utils.getNodeQName(node); if (nodeKind != null && nodeKind.getLocalPart().equals("element") && Utils.isSchemaNS(nodeKind.getNamespaceURI())) { NodeList children = node.getChildNodes(); Node complexNode = null; for (int j = 0; j < children.getLength() && complexNode == null; j++) { QName complexKind = Utils.getNodeQName(children.item(j)); if (complexKind != null && complexKind.getLocalPart().equals("complexType") && Utils.isSchemaNS(complexKind.getNamespaceURI())) { complexNode = children.item(j); node = complexNode; } } } // Get the node kind, expecting a schema complexType nodeKind = Utils.getNodeQName(node); if (nodeKind != null && nodeKind.getLocalPart().equals("complexType") && Utils.isSchemaNS(nodeKind.getNamespaceURI())) { // Under the complexType there should be a complexContent. // (There may be other #text nodes, which we will ignore). NodeList children = node.getChildNodes(); Node complexContentNode = null; for (int j = 0; j < children.getLength() && complexContentNode == null; j++) { QName complexContentKind = Utils.getNodeQName(children.item(j)); if (complexContentKind != null && complexContentKind.getLocalPart().equals("complexContent") && Utils.isSchemaNS(complexContentKind.getNamespaceURI())) complexContentNode = children.item(j); } // Under the complexContent there should be a restriction. // (There may be other #text nodes, which we will ignore). Node restrictionNode = null; if (complexContentNode != null) { children = complexContentNode.getChildNodes(); for (int j = 0; j < children.getLength() && restrictionNode == null; j++) { QName restrictionKind = Utils.getNodeQName(children.item(j)); if (restrictionKind != null && restrictionKind.getLocalPart().equals("restriction") && Utils.isSchemaNS(restrictionKind.getNamespaceURI())) restrictionNode = children.item(j); } } // The restriction node must have a base of soapenc:Array. QName baseType = null; if (restrictionNode != null) { baseType = Utils.getNodeTypeRefQName(restrictionNode, "base"); if (baseType != null && baseType.getLocalPart().equals("Array") && Utils.isSoapEncodingNS(baseType.getNamespaceURI())) ; // Okay else baseType = null; // Did not find base=soapenc:Array } // Under the restriction there should be an attribute OR a sequence/all group node. // (There may be other #text nodes, which we will ignore). Node groupNode = null; Node attributeNode = null; if (baseType != null) { children = restrictionNode.getChildNodes(); for (int j = 0; j < children.getLength() && groupNode == null && attributeNode == null; j++) { QName kind = Utils.getNodeQName(children.item(j)); if (kind != null && (kind.getLocalPart().equals("sequence") || kind.getLocalPart().equals("all")) && Utils.isSchemaNS(kind.getNamespaceURI())) { groupNode = children.item(j); } if (kind != null && kind.getLocalPart().equals("attribute") && Utils.isSchemaNS(kind.getNamespaceURI())) { attributeNode = children.item(j); } } } // If there is an attribute node, it must have a ref of soapenc:array and // a wsdl:arrayType attribute. if (attributeNode != null) { QName refQName = Utils.getNodeTypeRefQName(attributeNode, "ref"); if (refQName != null && refQName.getLocalPart().equals("arrayType") && Utils.isSoapEncodingNS(refQName.getNamespaceURI())) ; // Okay else refQName = null; // Did not find ref="soapenc:arrayType" String wsdlArrayTypeValue = null; if (refQName != null) { Vector attrs = Utils.getAttributesWithLocalName(attributeNode, "arrayType"); for (int i=0; i < attrs.size() && wsdlArrayTypeValue == null; i++) { Node attrNode = (Node) attrs.elementAt(i); String attrName = attrNode.getNodeName(); QName attrQName = Utils.getQNameFromPrefixedName(attributeNode, attrName); if (Utils.isWsdlNS(attrQName.getNamespaceURI())) { wsdlArrayTypeValue = attrNode.getNodeValue(); } } } // The value should have [] on the end, strip these off. // The convert the prefixed name into a qname, and return if (wsdlArrayTypeValue != null) { int i = wsdlArrayTypeValue.indexOf("["); if (i > 0) { String prefixedName = wsdlArrayTypeValue.substring(0,i); return Utils.getQNameFromPrefixedName(restrictionNode, prefixedName); } } } else if (groupNode != null) { // Get the first element node under the group node. NodeList elements = groupNode.getChildNodes(); Node elementNode = null; for (int i=0; i < elements.getLength() && elementNode == null; i++) { QName elementKind = Utils.getNodeQName(elements.item(i)); if (elementKind != null && elementKind.getLocalPart().equals("element") && Utils.isSchemaNS(elementKind.getNamespaceURI())) { elementNode = elements.item(i); } } // The element node should have maxOccurs="unbounded" and // a type if (elementNode != null) { String maxOccursValue = Utils.getAttribute(elementNode, "maxOccurs"); if (maxOccursValue != null && maxOccursValue.equalsIgnoreCase("unbounded")) { return Utils.getNodeTypeRefQName(elementNode); } } } } return null; } /** * Convert the specified QName into a full Java Name. */ public String getJavaName(QName qName) { // The QName may represent a base java name, so check this first String fullJavaName = Utils.getBaseJavaName(qName); if (fullJavaName != null) return fullJavaName; // Use the namespace uri to get the appropriate package String pkg = getPackage(qName.getNamespaceURI()); if (pkg != null) { fullJavaName = pkg + "." + Utils.xmlNameToJava(qName.getLocalPart()); } else { fullJavaName = Utils.xmlNameToJava(qName.getLocalPart()); } return fullJavaName; } // getJavaName /** * Populate the symbol table with all of the MessageEntry's from the Definition. */ private void populateMessages(Definition def) { Iterator i = def.getMessages().values().iterator(); while (i.hasNext()) { Message message = (Message) i.next(); MessageEntry mEntry = new MessageEntry(message); symbolTablePut(mEntry); } } // populateMessages /** * Populate the symbol table with all of the PortTypeEntry's from the Definition. */ private void populatePortTypes(Definition def) throws IOException { Iterator i = def.getPortTypes().values().iterator(); while (i.hasNext()) { PortType portType = (PortType) i.next(); // If the portType is undefined, then we're parsing a Definition // that didn't contain a portType, merely a binding that referred // to a non-existent port type. Don't bother with it. if (!portType.isUndefined()) { HashMap parameters = new HashMap(); // Remove Duplicates - happens with only a few WSDL's. No idea why!!! // (like http://www.xmethods.net/tmodels/InteropTest.wsdl) // TODO: Remove this patch... // NOTE from RJB: this is a WSDL4J bug and the WSDL4J guys have been notified. Iterator operations = (new HashSet(portType.getOperations())).iterator(); while(operations.hasNext()) { Operation operation = (Operation) operations.next(); String namespace = portType.getQName().getNamespaceURI(); Parameters parms = parameters(operation, namespace); parameters.put(operation.getName(), parms); } PortTypeEntry ptEntry = new PortTypeEntry(portType, parameters); symbolTablePut(ptEntry); } } } // populatePortTypes /** * For the given operation, this method returns the parameter info conveniently collated. * There is a bit of processing that is needed to write the interface, stub, and skeleton. * Rather than do that processing 3 times, it is done once, here, and stored in the * Parameters object. */ private Parameters parameters(Operation operation, String namespace) throws IOException { Parameters parameters = new Parameters(); // The input and output Vectors, when filled in, will be of the form: // {, , , , ..., , } Vector inputs = new Vector(); Vector outputs = new Vector(); List parameterOrder = operation.getParameterOrdering(); // Handle parameterOrder="", which is techinically illegal if (parameterOrder != null && parameterOrder.isEmpty()) { parameterOrder = null; } // All input parts MUST be in the parameterOrder list. It is an error otherwise. if (parameterOrder != null) { Input input = operation.getInput(); if (input != null) { Message inputMsg = input.getMessage(); Map allInputs = inputMsg.getParts(); Collection orderedInputs = inputMsg.getOrderedParts(parameterOrder); if (allInputs.size() != orderedInputs.size()) { throw new IOException(JavaUtils.getMessage("emitFail00", operation.getName())); } } } // Collect all the input parameters Input input = operation.getInput(); if (input != null) { partStrings(inputs, input.getMessage().getOrderedParts(null)/*, (wsdlAttr.getInputBodyType(operation) == BindingEntry.USE_LITERAL)*/); } // Collect all the output parameters Output output = operation.getOutput(); if (output != null) { partStrings(outputs, output.getMessage().getOrderedParts(null)/*, (wsdlAttr.getOutputBodyType(operation) == BindingEntry.USE_LITERAL)*/); } if (parameterOrder != null) { // Construct a list of the parameters in the parameterOrder list, determining the // mode of each parameter and preserving the parameterOrder list. for (int i = 0; i < parameterOrder.size(); ++i) { String name = (String) parameterOrder.get(i); // index in the inputs Vector of the given name, -1 if it doesn't exist. int index = getPartIndex(name, inputs); // index in the outputs Vector of the given name, -1 if it doesn't exist. int outdex = getPartIndex(name, outputs); if (index > 0) { // The mode of this parameter is either in or inout addInishParm(inputs, outputs, index, outdex, parameters, true); } else if (outdex > 0) { addOutParm(outputs, outdex, parameters, true); } else { System.err.println(JavaUtils.getMessage("noPart00", name)); } } } // Get the mode info about those parts that aren't in the parameterOrder list. // Since they're not in the parameterOrder list, the order doesn't matter. // Add the input and inout parts first, then add the output parts. for (int i = 1; i < inputs.size(); i += 2) { int outdex = getPartIndex((String) inputs.get(i), outputs); addInishParm(inputs, outputs, i, outdex, parameters, false); } // Now that the remaining in and inout parameters are collected, the first entry in the // outputs Vector is the return value. The rest are out parameters. if (outputs.size() > 0) { parameters.returnType = (String) outputs.get(0); parameters.returnName = (String) outputs.get(1); ++parameters.outputs; for (int i = 3; i < outputs.size(); i += 2) { addOutParm(outputs, i, parameters, false); } } // Collect the list of faults into a single string, separated by commas. Map faults = operation.getFaults(); Iterator i = faults.values().iterator(); while (i.hasNext()) { Fault fault = (Fault) i.next(); String exceptionName = Utils.capitalizeFirstChar(Utils.xmlNameToJava((String) fault.getName())); if (parameters.faultString == null) parameters.faultString = exceptionName; else parameters.faultString = parameters.faultString + ", " + exceptionName; } if (parameters.returnType == null) parameters.returnType = "void"; return parameters; } // parameters /** * Return the index of the given name in the given Vector, -1 if it doesn't exist. */ private int getPartIndex(String name, Vector v) { for (int i = 1; i < v.size(); i += 2) { if (name.equals(v.get(i))) { return i; } } return -1; } // getPartIndex /** * Add an in or inout parameter to the parameters object. */ private void addInishParm(Vector inputs, Vector outputs, int index, int outdex, Parameters parameters, boolean trimInput) { Parameters.Parameter p = new Parameters.Parameter(); p.name = (String) inputs.get(index); p.type = (String) inputs.get(index - 1); // Should we remove the given parameter type/name entries from the Vector? if (trimInput) { inputs.remove(index); inputs.remove(index - 1); } // At this point we know the name and type of the parameter, and that it's at least an // in parameter. Now check to see whether it's also in the outputs Vector. If it is, // then it's an inout parameter. if (outdex > 0 && p.type.equals(outputs.get(outdex - 1))) { outputs.remove(outdex); outputs.remove(outdex - 1); p.mode = Parameters.Parameter.INOUT; ++parameters.inouts; } else { ++parameters.inputs; } parameters.list.add(p); } // addInishParm /** * Add an output parameter to the parameters object. */ private void addOutParm(Vector outputs, int outdex, Parameters parameters, boolean trim) { Parameters.Parameter p = new Parameters.Parameter(); p.name = (String) outputs.get(outdex); p.type = (String) outputs.get(outdex - 1); if (trim) { outputs.remove(outdex); outputs.remove(outdex - 1); } p.mode = Parameters.Parameter.OUT; ++parameters.outputs; parameters.list.add(p); } // addOutParm /** * This method returns a vector containing the Java types (even indices) and * names (odd indices) of the parts. */ protected void partStrings(Vector v, Collection parts/*, boolean literal*/) { Iterator i = parts.iterator(); while (i.hasNext()) { Part part = (Part) i.next(); QName elementName = part.getElementName(); QName typeName = part.getTypeName(); /* The literal distinction doesn't belong here, it belongs in the writers - somewhere if (literal) { if (elementName != null) { v.add(Utils.capitalizeFirstChar(elementName.getLocalPart())); v.add(part.getName()); } } else { */ // Encoded if (typeName != null) { // Handle the special "java" namespace for types if (typeName.getNamespaceURI().equalsIgnoreCase("java")) { v.add(typeName.getLocalPart()); } else { v.add(((SymTabEntry) getTypeEntry(typeName)).getName()); } v.add(part.getName()); } else if (elementName != null) { // Handle the special "java" namespace for types if (elementName.getNamespaceURI().equalsIgnoreCase("java")) { v.add(elementName.getLocalPart()); } else { v.add(((SymTabEntry) getTypeEntry(elementName)).getName()); } v.add(part.getName()); } } // } } // partStrings /** * Populate the symbol table with all of the BindingEntry's from the Definition. */ private void populateBindings(Definition def) { Iterator i = def.getBindings().values().iterator(); while (i.hasNext()) { int bindingStyle = BindingEntry.STYLE_RPC; int bindingType = BindingEntry.TYPE_SOAP; Binding binding = (Binding) i.next(); Iterator extensibilityElementsIterator = binding.getExtensibilityElements().iterator(); while (extensibilityElementsIterator.hasNext()) { Object obj = extensibilityElementsIterator.next(); if (obj instanceof SOAPBinding) { bindingType = BindingEntry.TYPE_SOAP; SOAPBinding sb = (SOAPBinding) obj; String style = sb.getStyle(); if (style.equalsIgnoreCase("document")) { bindingStyle = BindingEntry.STYLE_DOCUMENT; } } else if (obj instanceof HTTPBinding) { HTTPBinding hb = (HTTPBinding) obj; if (hb.getVerb().equalsIgnoreCase("post")) { bindingType = BindingEntry.TYPE_HTTP_POST; } else { bindingType = BindingEntry.TYPE_HTTP_GET; } } } /* RJB: I'm not sure about this attribute. Waiting for Tom Jordahl's input. PortType port = binding.getPortType(); PortTypeEntry ptEntry = (PortTypeEntry)symbolTable.get(port.getQName()); if (bindingType != BindingEntry.TYPE_SOAP) { ptEntry.setIsInSoapBinding(true); } else { ptEntry.setIsInSoapBinding(false); } */ // Check the Binding Operations for use="literal" HashMap attributes = new HashMap(); List bindList = binding.getBindingOperations(); for (Iterator opIterator = bindList.iterator(); opIterator.hasNext();) { int inputBodyType = BindingEntry.USE_ENCODED; int outputBodyType = BindingEntry.USE_ENCODED; BindingOperation bindOp = (BindingOperation) opIterator.next(); // input if (bindOp.getBindingInput() != null) { if (bindOp.getBindingInput().getExtensibilityElements() != null) { Iterator inIter = bindOp.getBindingInput().getExtensibilityElements().iterator(); for (; inIter.hasNext();) { Object obj = inIter.next(); if (obj instanceof SOAPBody) { String use = ((SOAPBody) obj).getUse(); if (use.equalsIgnoreCase("literal")) { inputBodyType = BindingEntry.USE_LITERAL; } break; } } } } // output if (bindOp.getBindingOutput() != null) { if (bindOp.getBindingOutput().getExtensibilityElements() != null) { Iterator outIter = bindOp.getBindingOutput().getExtensibilityElements().iterator(); for (; outIter.hasNext();) { Object obj = outIter.next(); if (obj instanceof SOAPBody) { String use = ((SOAPBody) obj).getUse(); if (use.equalsIgnoreCase("literal")) { outputBodyType = BindingEntry.USE_LITERAL; } break; } } } } // faults HashMap faultMap = new HashMap(); Iterator faultMapIter = bindOp.getBindingFaults().values().iterator(); for (; faultMapIter.hasNext(); ) { BindingFault bFault = (BindingFault)faultMapIter.next(); // Set default entry for this fault String faultName = bFault.getName(); int faultBodyType = BindingEntry.USE_ENCODED; Iterator faultIter = bFault.getExtensibilityElements().iterator(); for (; faultIter.hasNext();) { Object obj = faultIter.next(); if (obj instanceof SOAPBody) { String use = ((SOAPBody) obj).getUse(); if (use.equalsIgnoreCase("literal")) { faultBodyType = BindingEntry.USE_LITERAL; } break; } } // Add this fault name and bodyType to the map faultMap.put(faultName, new Integer(faultBodyType)); } // Associate the portType operation that goes with this binding // with the body types. attributes.put(bindOp.getOperation(), new BindingEntry.OperationAttr(inputBodyType, outputBodyType, faultMap)); } // binding operations BindingEntry bEntry = new BindingEntry(binding, bindingType, bindingStyle, attributes); symbolTablePut(bEntry); } } // populateBindings /** * Populate the symbol table with all of the ServiceEntry's from the Definition. */ private void populateServices(Definition def) { Iterator i = def.getServices().values().iterator(); while (i.hasNext()) { Service service = (Service) i.next(); ServiceEntry sEntry = new ServiceEntry(service); symbolTablePut(sEntry); } } // populateServices /** * Put the given SymTabEntry into the symbol table, if appropriate. If */ private void symbolTablePut(SymTabEntry entry) { QName name = entry.getQName(); if (get(name, entry.getClass()) == null) { // An entry of the given qname of the given type doesn't exist yet. if (entry instanceof Type && get(name, RefdType.class) != null) { // A referenced entry exists in the symbol table, which means // that the type is used, but we don't yet have a definition for // the type. Now we DO have a definition for the type, so // replace the existing referenced type with the real type. Vector v = (Vector) symbolTable.get(name); for (int i = 0; i < v.size(); ++i) { Object oldEntry = v.elementAt(i); if (oldEntry instanceof RefdType) { // Replace it in the symbol table v.setElementAt(entry, i); // Replace it in the types Vector for (int j = 0; j < types.size(); ++j) { if (types.elementAt(j) == oldEntry) { types.setElementAt(entry, j); } } } } } else { // Add this entry to the symbol table Vector v = (Vector) symbolTable.get(name); if (v == null) { v = new Vector(); symbolTable.put(name, v); } v.add(entry); if (entry instanceof Type) { types.add(entry); } } } } // symbolTablePut /** * Get the raw symbol table HashMap. */ public HashMap getHashMap() { return symbolTable; } // getHashMap /** * Get the list of entries with the given QName. Since symbols can share QNames, this list is * necessary. This list will not contain any more than one element of any given SymTabEntry. */ public Vector getSymbols(QName qname) { return (Vector) symbolTable.get(qname); } // get /** * Get the entry with the given QName of the given class. If it does not exist, return null. */ private SymTabEntry get(QName qname, Class cls) { Vector v = (Vector) symbolTable.get(qname); if (v == null) { return null; } else { for (int i = 0; i < v.size(); ++i) { SymTabEntry entry = (SymTabEntry) v.elementAt(i); if (cls.isInstance(entry)) { return entry; } } return null; } } // get /** * Get the TypeEntry with the given QName. If it doesn't exist, return null. */ public Type getTypeEntry(QName qname) { return (Type) get(qname, Type.class); } // getTypeEntry /** * Get the MessageEntry with the given QName. If it doesn't exist, return null. */ public MessageEntry getMessageEntry(QName qname) { return (MessageEntry) get(qname, MessageEntry.class); } // getMessageEntry /** * Get the PortTypeEntry with the given QName. If it doesn't exist, return null. */ public PortTypeEntry getPortTypeEntry(QName qname) { return (PortTypeEntry) get(qname, PortTypeEntry.class); } // getPortTypeEntry /** * Get the BindingEntry with the given QName. If it doesn't exist, return null. */ public BindingEntry getBindingEntry(QName qname) { return (BindingEntry) get(qname, BindingEntry.class); } // getBindingEntry /** * Get the ServiceEntry with the given QName. If it doesn't exist, return null. */ public ServiceEntry getServiceEntry(QName qname) { return (ServiceEntry) get(qname, ServiceEntry.class); } // getServiceEntry /** * Get the list of all the XML schema types in the symbol table. In other words, all entries * that are instances of TypeEntry. */ public Vector getTypes() { return types; } // getTypes /** * Invoke this method to associate a namespace URI with a autogenerated Java Package * name, if an entry is not already present * */ public void map (String namespace) { if (namespaces.get(namespace) == null) { namespaces.put(namespace, Utils.makePackageName(namespace)); } } /** * Invoke this method to associate a namespace URI with a particular Java Package */ public void map (String namespace, String pkg) { namespaces.put(namespace, pkg); } public void setNamespaceMap(HashMap map) { namespaces.putAll(map); } /** * Get the Package name for the specified namespace */ public String getPackage(String namespace) { return (String) namespaces.getCreate(namespace); } /** * Get the Package name for the specified QName */ public String getPackage(QName qName) { return getPackage(qName.getNamespaceURI()); } } // class SymbolTable 1.1 xml-axis/java/src/org/apache/axis/wsdl/ServiceEntry.java Index: ServiceEntry.java =================================================================== /* * The Apache Software License, Version 1.1 * * * Copyright (c) 2001 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The names "Axis" and "Apache Software Foundation" must * not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact apache@apache.org. * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * . */ package org.apache.axis.wsdl; import javax.wsdl.QName; import javax.wsdl.Service; /** * This class represents a WSDL service. It simply encompasses the WSDL4J Service object so it can * reside in the SymbolTable. */ public class ServiceEntry extends SymTabEntry { private Service service; /** * Construct a ServiceEntry from a WSDL4J Service object. */ public ServiceEntry(Service service) { super(service.getQName()); this.service = service; } // ctor /** * Get this entry's Service object. */ public Service getService() { return service; } // getService } // class ServiceEntry 1.1 xml-axis/java/src/org/apache/axis/wsdl/PortTypeEntry.java Index: PortTypeEntry.java =================================================================== /* * The Apache Software License, Version 1.1 * * * Copyright (c) 2001 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The names "Axis" and "Apache Software Foundation" must * not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact apache@apache.org. * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * . */ package org.apache.axis.wsdl; import java.util.HashMap; import javax.wsdl.PortType; import javax.wsdl.QName; /** * This class represents a WSDL portType. It encompasses the WSDL4J PortType object so it can * reside in the SymbolTable. It also adds the parameter information, which is missing from the * WSDL4J PortType object. */ public class PortTypeEntry extends SymTabEntry { private PortType portType; private HashMap parameters = new HashMap (); /** * Construct a PortTypeEntry from a WSDL4J PortType object and a HashMap of Parameters objects, * keyed off of the operation name. */ public PortTypeEntry(PortType portType, HashMap parameters) { super(portType.getQName()); this.portType = portType; this.parameters = parameters; } // ctor /** * Get this entry's PortType object. */ public PortType getPortType() { return portType; } // getPortType /** * Get the Parameters object for the given operation. */ public Parameters getParameters(String operationName) { return (Parameters) parameters.get(operationName); } // getParameters } // class PortTypeEntry 1.1 xml-axis/java/src/org/apache/axis/wsdl/NoopWriter.java Index: NoopWriter.java =================================================================== /* * The Apache Software License, Version 1.1 * * * Copyright (c) 2001 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The names "Axis" and "Apache Software Foundation" must * not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact apache@apache.org. * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * . */ package org.apache.axis.wsdl; import java.io.IOException; /** * This writer doesn't do anything. Wsdl2java doesn't write anything for messages, but since * the WriterFactory interface requires that getWriter(Message, SymbolTable) return a Writer, it * has to return something. Ergo this class. */ public class NoopWriter implements Writer { /** * Do a whole lot of nothing. */ public void write() throws IOException { } // write } // class NoopWriter 1.1 xml-axis/java/src/org/apache/axis/wsdl/MessageEntry.java Index: MessageEntry.java =================================================================== /* * The Apache Software License, Version 1.1 * * * Copyright (c) 2001 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The names "Axis" and "Apache Software Foundation" must * not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact apache@apache.org. * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * . */ package org.apache.axis.wsdl; import javax.wsdl.Message; import javax.wsdl.QName; /** * This class represents a WSDL message. It simply encompasses the WSDL4J Message object so it can * reside in the SymbolTable. */ public class MessageEntry extends SymTabEntry { private Message message; /** * Construct a MessageEntry from a WSDL4J Message object. */ public MessageEntry(Message message) { super(message.getQName()); this.message = message; } // ctor /** * Get this entry's Message object. */ public Message getMessage() { return message; } // getMessage } // class MessageEntry 1.1 xml-axis/java/src/org/apache/axis/wsdl/BindingEntry.java Index: BindingEntry.java =================================================================== /* * The Apache Software License, Version 1.1 * * * Copyright (c) 2001 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The names "Axis" and "Apache Software Foundation" must * not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact apache@apache.org. * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * . */ package org.apache.axis.wsdl; import java.util.HashMap; import javax.wsdl.Binding; import javax.wsdl.Operation; import javax.wsdl.QName; /** * This class represents a WSDL binding. It encompasses the WSDL4J Binding object so it can * reside in the SymbolTable. It also adds a few bits of information that are a nuisance to get * from the WSDL4J Binding object: binding type, binding style, input/output/fault body types. */ public class BindingEntry extends SymTabEntry { // Binding styles public static final int STYLE_RPC = 0; public static final int STYLE_DOCUMENT = 1; // Binding types public static final int TYPE_SOAP = 0; public static final int TYPE_HTTP_GET = 1; public static final int TYPE_HTTP_POST = 2; // Binding Operation use types public static final int USE_ENCODED = 0; public static final int USE_LITERAL = 1; private Binding binding; private int bindingType; private int bindingStyle; private HashMap attributes; /** * Construct a BindingEntry from a WSDL4J Binding object and the additional binding info: * binding type, binding style, and the attributes which contain the input/output/fault body * type information. */ public BindingEntry(Binding binding, int bindingType, int bindingStyle, HashMap attributes) { super(binding.getQName()); this.binding = binding; this.bindingType = bindingType; this.bindingStyle = bindingStyle; this.attributes = attributes; } // ctor /** * Get this entry's WSDL4J Binding object. */ public Binding getBinding() { return binding; } // getBinding /** * Get this entry's binding type. One of BindingEntry.TYPE_SOAP, BindingEntry.TYPE_HTTP_GET, * BindingEntry.TYPE_HTTP_POST. */ public int getBindingType() { return bindingType; } // getBindingType /** * Get this entry's binding style. One of BindingEntry.STYLE_RPC, BindingEntry.STYLE_DOCUMENT. */ public int getBindingStyle() { return bindingStyle; } // getBindingStyle /** * Get the input body type for the given operation. One of BindingEntry.USE_ENCODED, * BindingEntry.USE_LITERAL. */ public int getInputBodyType(Operation operation) { OperationAttr attr = (OperationAttr) attributes.get(operation); if (attr == null) { return USE_ENCODED; // should really create an exception for this. } else { return attr.getInputBodyType(); } } // getInputBodyType /** * Get the output body type for the given operation. One of BindingEntry.USE_ENCODED, * BindingEntry.USE_LITERAL. */ public int getOutputBodyType(Operation operation) { OperationAttr attr = (OperationAttr) attributes.get(operation); if (attr == null) { return USE_ENCODED; // should really create an exception for this. } else { return attr.getOutputBodyType(); } } // getOutputBodyType /** * Get the fault body type for the given fault of the given operation. One of * BindingEntry.USE_ENCODED, BindingEntry.USE_LITERAL. */ public int getFaultBodyType(Operation operation, String faultName) { OperationAttr attr = (OperationAttr) attributes.get(operation); if (attr == null) { return 0; // should really create an exception for this. } else { HashMap m = attr.getFaultBodyTypeMap(); // Default to encoded if we didn't have a soap:body for the fault if ( ! m.containsKey(faultName) ) { return USE_ENCODED; } return ((Integer) m.get(faultName)).intValue(); } } /** * Contains attributes for Operations * - Body type: encoded or literal */ protected static class OperationAttr { private int inputBodyType; private int outputBodyType; private HashMap faultBodyTypeMap; public OperationAttr(int inputBodyType, int outputBodyType, HashMap faultBodyTypeMap) { this.inputBodyType = inputBodyType; this.outputBodyType = outputBodyType; this.faultBodyTypeMap = faultBodyTypeMap; } public int getInputBodyType() { return inputBodyType; } public int getOutputBodyType() { return outputBodyType; } public HashMap getFaultBodyTypeMap() { return faultBodyTypeMap; } } // class OperationAttr } // class BindingEntry