You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by gd...@apache.org on 2003/12/15 21:10:29 UTC
cvs commit: ws-axis/java/test/wsdl/echo ComplexEchoServiceTestCase.java
gdaniels 2003/12/15 12:10:29
Modified: java/src/org/apache/axis/wsdl/fromJava Emitter.java
Types.java
java/test/wsdl/echo ComplexEchoServiceTestCase.java
Log:
Deal better with writing duplicate schema element declarations. Handle
it all inside writeElementDecl().
Fixes WSDL generation test for test/wsdl/echo
Revision Changes Path
1.109 +4 -11 ws-axis/java/src/org/apache/axis/wsdl/fromJava/Emitter.java
Index: Emitter.java
===================================================================
RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/wsdl/fromJava/Emitter.java,v
retrieving revision 1.108
retrieving revision 1.109
diff -u -r1.108 -r1.109
--- Emitter.java 15 Dec 2003 19:25:20 -0000 1.108
+++ Emitter.java 15 Dec 2003 20:10:29 -0000 1.109
@@ -1371,12 +1371,8 @@
// <xsd:any> for now.
// TODO: Support custom schema in WSDD for these operations
QName qname = oper.getElementQName();
- Element el = types.createElementDecl(qname.getLocalPart(),
- Object.class,
- Constants.XSD_ANYTYPE,
- false, false);
-
- types.writeSchemaTypeDecl(qname, el);
+ types.writeElementDecl(qname, Object.class,
+ Constants.XSD_ANYTYPE, false, false);
Part part = def.createPart();
@@ -1737,12 +1733,9 @@
param.setQName(qname);
}
- Element el = types.createElementDecl(qname.getLocalPart(),
- param.getJavaType(),
- param.getTypeQName(), false,
- false);
+ types.writeElementDecl(qname, param.getJavaType(),
+ param.getTypeQName(), false, false);
- types.writeSchemaElementDecl(qname, el);
part.setName(param.getName());
part.setElementName(qname);
msg.addPart(part);
1.87 +126 -118 ws-axis/java/src/org/apache/axis/wsdl/fromJava/Types.java
Index: Types.java
===================================================================
RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/wsdl/fromJava/Types.java,v
retrieving revision 1.86
retrieving revision 1.87
diff -u -r1.86 -r1.87
--- Types.java 9 Dec 2003 21:22:01 -0000 1.86
+++ Types.java 15 Dec 2003 20:10:29 -0000 1.87
@@ -103,7 +103,7 @@
* an XML Schema representation.
* <p/>
* It has utility methods to create a schema node, assosiate namespaces to the various types
- *
+ *
* @author unascribed
*/
public class Types {
@@ -178,14 +178,14 @@
/**
* This class serailizes a <code>Class</code> to XML Schema. The constructor
* provides the context for the streamed node within the WSDL document
- *
+ *
* @param def WSDL Definition Element to declare namespaces
* @param tm TypeMappingRegistry to handle known types
* @param defaultTM default TM
* @param namespaces user defined or autogenerated namespace and prefix maps
* @param targetNamespace targetNamespace of the document
- * @param stopClasses
- * @param serviceDesc
+ * @param stopClasses
+ * @param serviceDesc
*/
public Types(Definition def, TypeMapping tm, TypeMapping defaultTM,
Namespaces namespaces, String targetNamespace,
@@ -208,8 +208,8 @@
/**
* Return the namespaces object for the current context
- *
- * @return
+ *
+ * @return
*/
public Namespaces getNamespaces() {
return namespaces;
@@ -217,12 +217,12 @@
/**
* Loads the types from the input schema file.
- *
+ *
* @param inputSchema file or URL
- * @throws IOException
- * @throws WSDLException
- * @throws SAXException
- * @throws ParserConfigurationException
+ * @throws IOException
+ * @throws WSDLException
+ * @throws SAXException
+ * @throws ParserConfigurationException
*/
public void loadInputSchema(String inputSchema)
throws IOException, WSDLException, SAXException,
@@ -276,8 +276,8 @@
* Walk the type/element entries in the symbol table and
* add each one to the list of processed types. This prevents
* the types from being duplicated.
- *
- * @param symbolTable
+ *
+ * @param symbolTable
*/
private void processSymTabEntries(SymbolTable symbolTable) {
@@ -318,12 +318,12 @@
/**
* Load the types from the input wsdl file.
- *
+ *
* @param inputWSDL file or URL
- * @throws IOException
- * @throws WSDLException
- * @throws SAXException
- * @throws ParserConfigurationException
+ * @throws IOException
+ * @throws WSDLException
+ * @throws SAXException
+ * @throws ParserConfigurationException
*/
public void loadInputTypes(String inputWSDL)
throws IOException, WSDLException, SAXException,
@@ -385,14 +385,14 @@
/**
* Write out a type referenced by a part type attribute.
- *
+ *
* @param type <code>Class</code> to generate the XML Schema info for
* @param qname <code>QName</code> of the type. If null, qname is
* defaulted from the class.
* @return the QName of the generated Schema type, null if void,
* if the Class type cannot be converted to a schema type
* then xsd:anytype is returned.
- * @throws AxisFault
+ * @throws AxisFault
*/
public QName writeTypeForPart(Class type, QName qname) throws AxisFault {
@@ -433,12 +433,12 @@
/**
* Write out an element referenced by a part element attribute.
- *
+ *
* @param type <code>Class</code> to generate the XML Schema info for
* @param qname <code>QName</code> of the element. If null, qname is
* defaulted from the class.
* @return the QName of the generated Schema type, null if no element
- * @throws AxisFault
+ * @throws AxisFault
*/
public QName writeElementForPart(Class type, QName qname) throws AxisFault {
@@ -500,7 +500,7 @@
* request boolean is true. If the operation contains parameters, then
* we also generate a >sequence< node underneath the complexType,
* and return it for later use by writeWrappedParameter() below.
- *
+ *
* @param qname the desired element QName
* @param request true if we're writing the request wrapper, false if
* writing the response.
@@ -508,7 +508,7 @@
* node is needed
* @return a DOM Element for the sequence, inside which we'll write the
* parameters as elements, or null if there are no parameters
- * @throws AxisFault
+ * @throws AxisFault
*/
public Element writeWrapperElement(
QName qname, boolean request, boolean hasParams) throws AxisFault {
@@ -548,12 +548,12 @@
/**
* Write a parameter (a sub-element) into a sequence generated by
* writeWrapperElement() above.
- *
+ *
* @param sequence the <sequence> in which we're writing
* @param name is the name of an element to add to the wrapper element.
* @param type is the QName of the type of the element.
- * @param javaType
- * @throws AxisFault
+ * @param javaType
+ * @throws AxisFault
*/
public void writeWrappedParameter(
Element sequence, String name, QName type, Class javaType)
@@ -562,7 +562,7 @@
if (javaType == void.class) {
return;
}
-
+
if (javaType.isArray()) {
type = writeTypeForPart(javaType.getComponentType(), null);
}
@@ -593,7 +593,7 @@
String prefixedName = prefix + ":" + type.getLocalPart();
childElem.setAttribute("type", prefixedName);
-
+
if (javaType.isArray()) {
childElem.setAttribute("maxOccurs", "unbounded");
}
@@ -604,9 +604,9 @@
/**
* Method isAnonymousType
- *
- * @param type
- * @return
+ *
+ * @param type
+ * @return
*/
private boolean isAnonymousType(QName type) {
return type.getLocalPart().indexOf(SymbolTable.ANON_TOKEN) != -1;
@@ -614,11 +614,11 @@
/**
* Create a schema element for the given type
- *
+ *
* @param type the class type
- * @param qName
+ * @param qName
* @return the QName of the generated Element or problems occur
- * @throws AxisFault
+ * @throws AxisFault
*/
private QName writeTypeAsElement(Class type, QName qName) throws AxisFault {
@@ -643,7 +643,7 @@
/**
* write out the namespace declaration and return the type QName for the
* given <code>Class</code>
- *
+ *
* @param type input Class
* @param qName qname of the Class
* @return QName for the schema type representing the class
@@ -661,7 +661,7 @@
/**
* write out the namespace declaration.
- *
+ *
* @param namespaceURI qname of the type
*/
private void writeTypeNamespace(String namespaceURI) {
@@ -678,7 +678,7 @@
/**
* Return the QName of the specified javaType
- *
+ *
* @param javaType input javaType Class
* @return QName
*/
@@ -687,7 +687,7 @@
if(qName == null) {
qName = tm.getTypeQName(javaType);
}
-
+
// If the javaType is an array and the qName is
// SOAP_ARRAY, construct the QName using the
// QName of the component type
@@ -737,7 +737,7 @@
* Return a string suitable for representing a given QName in the context
* of this WSDL document. If the namespace of the QName is not yet
* registered, we will register it up in the Definitions.
- *
+ *
* @param qname a QName (typically a type)
* @return a String containing a standard "ns:localPart" rep of the QName
*/
@@ -750,7 +750,7 @@
/**
* Utility method to get the package name from a fully qualified java class name
- *
+ *
* @param full input class name
* @return package name
*/
@@ -765,7 +765,7 @@
/**
* Utility method to get the local class name from a fully qualified java class name
- *
+ *
* @param full input class name
* @return package name
*/
@@ -787,10 +787,10 @@
/**
* Method writeSchemaTypeDecl
- *
- * @param qname
- * @param element
- * @throws AxisFault
+ *
+ * @param qname
+ * @param element
+ * @throws AxisFault
*/
public void writeSchemaTypeDecl(QName qname, Element element)
throws AxisFault {
@@ -799,10 +799,10 @@
/**
* Method writeSchemaElementDecl
- *
- * @param qname
- * @param element
- * @throws AxisFault
+ *
+ * @param qname
+ * @param element
+ * @throws AxisFault
*/
public void writeSchemaElementDecl(QName qname, Element element)
throws AxisFault {
@@ -821,10 +821,10 @@
/**
* Write out the given Element into the appropriate schema node.
* If need be create the schema node as well
- *
+ *
* @param namespaceURI namespace this node should get dropped into
* @param element the Element to append to the Schema node
- * @throws AxisFault
+ * @throws AxisFault
*/
public void writeSchemaElement(String namespaceURI, Element element)
throws AxisFault {
@@ -911,10 +911,10 @@
* bean compliant accessor methods.
* <p/>
* Then return the qualified string representation of the generated type
- *
+ *
* @param type Class for which to generate schema
* @return a prefixed string for the schema type
- * @throws AxisFault
+ * @throws AxisFault
*/
public String writeType(Class type) throws AxisFault {
return writeType(type, null);
@@ -926,11 +926,11 @@
* bean compliant accessor methods.
* <p/>
* Then return the qualified string representation of the generated type
- *
+ *
* @param type Class for which to generate schema
* @param qName of the type to write
* @return a prefixed string for the schema type or null if problems occur
- * @throws AxisFault
+ * @throws AxisFault
*/
public String writeType(Class type, QName qName) throws AxisFault {
@@ -948,9 +948,9 @@
/**
* Method createArrayElement
- *
- * @param componentTypeName
- * @return
+ *
+ * @param componentTypeName
+ * @return
*/
public Element createArrayElement(String componentTypeName) {
@@ -976,40 +976,40 @@
return complexType;
}
-
+
/**
* Create an array which is a wrapper type for "item" elements
* of a component type. This is basically the unencoded parallel to
* a SOAP-encoded array.
- *
+ *
* @param componentType
* @param itemName
* @return
- */
+ */
public Element createLiteralArrayElement(String componentType,
QName itemName) {
Element complexType = docHolder.createElement("complexType");
Element sequence = docHolder.createElement("sequence");
-
+
complexType.appendChild(sequence);
-
+
Element elem = docHolder.createElement("element");
elem.setAttribute("name", "item");
elem.setAttribute("type", componentType);
elem.setAttribute("minOccurs", "0");
elem.setAttribute("maxOccurs", "unbounded");
-
+
sequence.appendChild(elem);
-
+
return complexType;
}
/**
* Returns true if indicated type matches the JAX-RPC enumeration class.
* Note: supports JSR 101 version 0.6 Public Draft
- *
- * @param cls
- * @return
+ *
+ * @param cls
+ * @return
*/
public static boolean isEnumClass(Class cls) {
@@ -1053,13 +1053,13 @@
/**
* Write Enumeration Complex Type
* (Only supports enumeration classes of string types)
- *
+ *
* @param qName QName of type.
* @param cls class of type
- * @return
- * @throws NoSuchMethodException
- * @throws IllegalAccessException
- * @throws AxisFault
+ * @return
+ * @throws NoSuchMethodException
+ * @throws IllegalAccessException
+ * @throws AxisFault
*/
public Element writeEnumType(QName qName, Class cls)
throws NoSuchMethodException, IllegalAccessException, AxisFault {
@@ -1110,19 +1110,27 @@
/**
* Create Element
- *
- * @param name
- * @param javaType
- * @param typeQName
+ *
+ * @param qname
+ * @param javaType
+ * @param typeQName
* @param nillable nillable attribute of the element
- * @param omittable
- * @return the created Element
- * @throws AxisFault
+ * @param omittable
+ * @throws AxisFault
*/
- public Element createElementDecl(
- String name, Class javaType, QName typeQName, boolean nillable, boolean omittable)
+ public void writeElementDecl(QName qname,
+ Class javaType,
+ QName typeQName,
+ boolean nillable,
+ boolean omittable)
throws AxisFault {
+ if (writtenElementQNames.contains(qname)) {
+ return;
+ }
+
+ String name = qname.getLocalPart();
+
Element element = docHolder.createElement("element");
// Generate an element name that matches the type.
@@ -1141,17 +1149,17 @@
// types appropriately.
makeTypeElement(javaType, typeQName, element);
- return element;
+ writeSchemaElementDecl(qname, element);
}
/**
* Create Element with a given name and type
- *
+ *
* @param elementName the name of the created element
* @param elementType schema type representation of the element
* @param nullable nullable attribute of the element
- * @param omittable
- * @param docHolder
+ * @param omittable
+ * @param docHolder
* @return the created Element
*/
public Element createElement(String elementName, String elementType,
@@ -1180,14 +1188,14 @@
/**
* Create Attribute Element with a given name and type
- *
+ *
* @param elementName the name of the created element
- * @param javaType
- * @param xmlType
+ * @param javaType
+ * @param xmlType
* @param nullable nullable attribute of the element
- * @param docHolder
+ * @param docHolder
* @return the created Element
- * @throws AxisFault
+ * @throws AxisFault
*/
public Element createAttributeElement(
String elementName, Class javaType, QName xmlType, boolean nullable, Document docHolder)
@@ -1210,7 +1218,7 @@
* Is the given class one of the simple types? In other words,
* do we have a mapping for this type which is in the xsd or
* soap-enc namespaces?
- *
+ *
* @param type input Class
* @return true if the type is a simple type
*/
@@ -1229,7 +1237,7 @@
/**
* Is the given class acceptable as an attribute
- *
+ *
* @param type input Class
* @return true if the type is a simple, enum type or extends SimpleType
*/
@@ -1240,7 +1248,7 @@
/**
* Does the class implement SimpleType
- *
+ *
* @param type input Class
* @return true if the type implements SimpleType
*/
@@ -1266,7 +1274,7 @@
*/
// *** NOT USED? ***
- //
+ //
// private String generateUniqueElementName(QName qName) {
// Integer count = (Integer)schemaUniqueElementNames.get(qName.getNamespaceURI());
// if (count == null)
@@ -1282,7 +1290,7 @@
* needs to be generated
* If the type already exists, just return false to indicate that the type is already
* generated in a previous iteration
- *
+ *
* @param qName of the type.
* @return if the type is added returns true,
* else if the type is already present returns false
@@ -1308,7 +1316,7 @@
types = new ArrayList();
types.add(qName.getLocalPart());
-
+
writeTypeNamespace(namespaceURI);
schemaTypes.put(namespaceURI, types);
@@ -1345,7 +1353,7 @@
* needs to be generated
* If the element already exists, just return false to indicate that the type is already
* generated in a previous iteration
- *
+ *
* @param qName the name space of the element
* @return if the type is added returns true, else if the type is already present returns false
*/
@@ -1380,7 +1388,7 @@
/**
* Determines if the field is nullable. All non-primitives except
* for byte[] are nillable.
- *
+ *
* @param type input Class
* @return true if nullable
*/
@@ -1447,8 +1455,8 @@
/**
* Inserts the type fragment into the given wsdl document
- *
- * @param doc
+ *
+ * @param doc
*/
public void insertTypesFragment(Document doc) {
@@ -1467,8 +1475,8 @@
/**
* Return the list of classes that we should not emit WSDL for.
- *
- * @return
+ *
+ * @return
*/
public List getStopClasses() {
return stopClasses;
@@ -1476,9 +1484,9 @@
/**
* Create a DOM Element in this context
- *
- * @param elementName
- * @return
+ *
+ * @param elementName
+ * @return
*/
public Element createElement(String elementName) {
return docHolder.createElement(elementName);
@@ -1486,12 +1494,12 @@
/**
* isBeanCompatible
- *
+ *
* @param javaType Class
* @param issueErrors if true, issue messages if not compatible
* Returns true if it appears that this class is a bean and
* can be mapped to a complexType
- * @return
+ * @return
*/
protected boolean isBeanCompatible(Class javaType, boolean issueErrors) {
@@ -1569,13 +1577,13 @@
/**
* Write an <element> with an anonymous internal ComplexType
- *
- * @param elementName
- * @param fieldType
- * @param omittable
- * @param ownerDocument
- * @return
- * @throws AxisFault
+ *
+ * @param elementName
+ * @param fieldType
+ * @param omittable
+ * @param ownerDocument
+ * @return
+ * @throws AxisFault
*/
public Element createElementWithAnonymousType(
String elementName, Class fieldType, boolean omittable, Document ownerDocument)
@@ -1607,7 +1615,7 @@
* definition underneath the Element which was passed as the container
* (typically a field of a higher-level type or a parameter in a wrapped
* operation).
- *
+ *
* @param type Java type to write
* @param qName the desired type QName
* @param containingElement a schema element ("element" or "attribute")
@@ -1615,7 +1623,7 @@
* (for named types) or a child element defining an anonymous
* type
* @return true if the type was already present or was added, false if there was a problem
- * @throws AxisFault
+ * @throws AxisFault
*/
private boolean makeTypeElement(
Class type, QName qName, Element containingElement)
1.4 +0 -2 ws-axis/java/test/wsdl/echo/ComplexEchoServiceTestCase.java
Index: ComplexEchoServiceTestCase.java
===================================================================
RCS file: /home/cvs/ws-axis/java/test/wsdl/echo/ComplexEchoServiceTestCase.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ComplexEchoServiceTestCase.java 15 Dec 2003 14:37:59 -0000 1.3
+++ ComplexEchoServiceTestCase.java 15 Dec 2003 20:10:29 -0000 1.4
@@ -12,14 +12,12 @@
super(name);
}
- /* FIXME: RUNTIME WSDL broken.
public void testComplexEchoServiceWSDL() throws Exception {
javax.xml.rpc.ServiceFactory serviceFactory = javax.xml.rpc.ServiceFactory.newInstance();
java.net.URL url = new java.net.URL(new test.wsdl.echo.ComplexEchoServiceLocator().getComplexEchoServiceAddress() + "?WSDL");
javax.xml.rpc.Service service = serviceFactory.createService(url, new test.wsdl.echo.ComplexEchoServiceLocator().getServiceName());
assertTrue(service != null);
}
- */
public void test1ComplexEchoServiceEcho() {
test.wsdl.echo.Echo binding;