You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by da...@apache.org on 2007/12/08 02:35:33 UTC
svn commit: r602291 [1/3] - in /openejb/trunk/openejb3:
container/openejb-jee/src/main/java/org/apache/openejb/jee/
server/openejb-axis/
server/openejb-axis/src/main/java/org/apache/openejb/server/axis/
server/openejb-axis/src/main/java/org/apache/open...
Author: dain
Date: Fri Dec 7 17:35:30 2007
New Revision: 602291
URL: http://svn.apache.org/viewvc?rev=602291&view=rev
Log:
Added alternate schema loader based on WS Commons XmlSchema
Redesigned schema loading
Added schema parsing test cases
Added:
openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/CommonsSchemaInfoBuilder.java
- copied, changed from r601187, openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/XmlBeansSchemaInfoBuilder.java
openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/CommonsSchemaLoader.java
- copied, changed from r601187, openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/XmlBeansSchemaLoader.java
openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/XmlElementInfo.java
- copied, changed from r601187, openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/XmlNestedElementInfo.java
openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/XmlTypeInfo.java
openejb/trunk/openejb3/server/openejb-axis/src/main/resources/
openejb/trunk/openejb3/server/openejb-axis/src/main/resources/META-INF/
openejb/trunk/openejb3/server/openejb-axis/src/main/resources/META-INF/schema/
openejb/trunk/openejb3/server/openejb-axis/src/main/resources/META-INF/schema/soap_encoding_1_1.xsd
openejb/trunk/openejb3/server/openejb-axis/src/test/java/org/apache/openejb/server/axis/assembler/
openejb/trunk/openejb3/server/openejb-axis/src/test/java/org/apache/openejb/server/axis/assembler/SchemaInfoBuilderTest.java
openejb/trunk/openejb3/server/openejb-axis/src/test/java/org/apache/openejb/server/axis/assembler/TypeInfoTestUtil.java
openejb/trunk/openejb3/server/openejb-axis/src/test/resources/schema/
openejb/trunk/openejb3/server/openejb-axis/src/test/resources/schema/ComplexAllElement.xsd
openejb/trunk/openejb3/server/openejb-axis/src/test/resources/schema/ComplexAllType.xsd
openejb/trunk/openejb3/server/openejb-axis/src/test/resources/schema/ComplexSequenceElement.xsd
openejb/trunk/openejb3/server/openejb-axis/src/test/resources/schema/ComplexSequenceType.xsd
openejb/trunk/openejb3/server/openejb-axis/src/test/resources/schema/JaxRpcSpecExample.xsd
openejb/trunk/openejb3/server/openejb-axis/src/test/resources/schema/SimpleElement.xsd
openejb/trunk/openejb3/server/openejb-axis/src/test/resources/schema/SimpleType.xsd
openejb/trunk/openejb3/server/openejb-axis/src/test/resources/schema/SoapArrayByAttribute.xsd
openejb/trunk/openejb3/server/openejb-axis/src/test/resources/schema/SoapArrayByRestriction.xsd
openejb/trunk/openejb3/server/openejb-axis/src/test/resources/schema/foo.xsd
Removed:
openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/XmlNestedElementInfo.java
Modified:
openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/JavaXmlTypeMapping.java
openejb/trunk/openejb3/server/openejb-axis/pom.xml
openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/JavaServiceDescBuilder.java
openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/HeavyweightOperationInfoBuilder.java
openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/HeavyweightTypeInfoBuilder.java
openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/JaxRpcFieldInfo.java
openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/JaxRpcTypeInfo.java
openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/LightweightTypeInfoBuilder.java
openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/XmlBeansSchemaInfoBuilder.java
openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/XmlBeansSchemaLoader.java
openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/XmlSchemaInfo.java
Modified: openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/JavaXmlTypeMapping.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/JavaXmlTypeMapping.java?rev=602291&r1=602290&r2=602291&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/JavaXmlTypeMapping.java (original)
+++ openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/JavaXmlTypeMapping.java Fri Dec 7 17:35:30 2007
@@ -81,15 +81,6 @@
return anonymousTypeQname;
}
- public QName getAnonymousTypeQnameQName() {
- int pos = anonymousTypeQname.lastIndexOf(":");
- if (pos == -1) {
- throw new IllegalArgumentException("anon QName is invalid, no final ':' " + anonymousTypeQname);
- }
- QName qname = new QName(anonymousTypeQname.substring(0, pos), anonymousTypeQname.substring(pos + 1));
- return qname;
- }
-
public void setAnonymousTypeQname(String value) {
this.anonymousTypeQname = value;
}
Modified: openejb/trunk/openejb3/server/openejb-axis/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-axis/pom.xml?rev=602291&r1=602290&r2=602291&view=diff
==============================================================================
--- openejb/trunk/openejb3/server/openejb-axis/pom.xml (original)
+++ openejb/trunk/openejb3/server/openejb-axis/pom.xml Fri Dec 7 17:35:30 2007
@@ -53,5 +53,10 @@
<artifactId>xmlbeans</artifactId>
<version>2.3.0</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.ws.commons.schema</groupId>
+ <artifactId>XmlSchema</artifactId>
+ <version>1.3.1</version>
+ </dependency>
</dependencies>
</project>
Modified: openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/JavaServiceDescBuilder.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/JavaServiceDescBuilder.java?rev=602291&r1=602290&r2=602291&view=diff
==============================================================================
--- openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/JavaServiceDescBuilder.java (original)
+++ openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/JavaServiceDescBuilder.java Fri Dec 7 17:35:30 2007
@@ -258,8 +258,9 @@
throw new OpenEJBException("Could not load class for JaxRpc mapping " + type.javaType);
}
- Class serializerFactoryClass;
- Class deserializerFactoryClass;
+ // Default uses the generic Java Beans serializer/deserializer
+ Class serializerFactoryClass = BeanSerializerFactory.class;
+ Class deserializerFactoryClass = BeanDeserializerFactory.class;
switch (type.serializerType) {
case ARRAY:
serializerFactoryClass = ArraySerializerFactory.class;
@@ -274,22 +275,19 @@
deserializerFactoryClass = SimpleListDeserializerFactory.class;
break;
default:
-
- Class clazz = SOAP_TYPE_MAPPING.getClassForQName(type.xmlType, null, null);
- if (null != clazz) {
- // Built in SOAP type
- serializerFactoryClass = SOAP_TYPE_MAPPING.getSerializer(clazz, type.xmlType).getClass();
- deserializerFactoryClass = SOAP_TYPE_MAPPING.getDeserializer(clazz, type.xmlType, null).getClass();
- } else {
- clazz = JAXRPC_TYPE_MAPPING.getClassForQName(type.xmlType, null, null);
+ if (type.simpleBaseType != null) {
+ Class clazz = SOAP_TYPE_MAPPING.getClassForQName(type.simpleBaseType, null, null);
if (null != clazz) {
- // Built in XML schema type
- serializerFactoryClass = JAXRPC_TYPE_MAPPING.getSerializer(clazz, type.xmlType).getClass();
- deserializerFactoryClass = JAXRPC_TYPE_MAPPING.getDeserializer(clazz, type.xmlType, null).getClass();
+ // Built in SOAP type
+ serializerFactoryClass = SOAP_TYPE_MAPPING.getSerializer(clazz, type.simpleBaseType).getClass();
+ deserializerFactoryClass = SOAP_TYPE_MAPPING.getDeserializer(clazz, type.simpleBaseType, null).getClass();
} else {
- // Unknown type so use the generic Java Beans serializer
- serializerFactoryClass = BeanSerializerFactory.class;
- deserializerFactoryClass = BeanDeserializerFactory.class;
+ clazz = JAXRPC_TYPE_MAPPING.getClassForQName(type.simpleBaseType, null, null);
+ if (null != clazz) {
+ // Built in XML schema type
+ serializerFactoryClass = JAXRPC_TYPE_MAPPING.getSerializer(clazz, type.simpleBaseType).getClass();
+ deserializerFactoryClass = JAXRPC_TYPE_MAPPING.getDeserializer(clazz, type.simpleBaseType, null).getClass();
+ }
}
}
break;
Copied: openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/CommonsSchemaInfoBuilder.java (from r601187, openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/XmlBeansSchemaInfoBuilder.java)
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/CommonsSchemaInfoBuilder.java?p2=openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/CommonsSchemaInfoBuilder.java&p1=openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/XmlBeansSchemaInfoBuilder.java&r1=601187&r2=602291&rev=602291&view=diff
==============================================================================
--- openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/XmlBeansSchemaInfoBuilder.java (original)
+++ openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/CommonsSchemaInfoBuilder.java Fri Dec 7 17:35:30 2007
@@ -20,266 +20,277 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.openejb.OpenEJBException;
-import org.apache.xmlbeans.SchemaField;
-import org.apache.xmlbeans.SchemaGlobalElement;
-import org.apache.xmlbeans.SchemaLocalAttribute;
-import org.apache.xmlbeans.SchemaParticle;
-import org.apache.xmlbeans.SchemaProperty;
-import org.apache.xmlbeans.SchemaType;
-import org.apache.xmlbeans.SchemaTypeSystem;
-import org.apache.xmlbeans.soap.SOAPArrayType;
-import org.apache.xmlbeans.soap.SchemaWSDLArrayType;
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaAttribute;
+import org.apache.ws.commons.schema.XmlSchemaChoice;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.ws.commons.schema.XmlSchemaComplexContentRestriction;
+import org.apache.ws.commons.schema.XmlSchemaComplexType;
+import org.apache.ws.commons.schema.XmlSchemaContent;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.ws.commons.schema.XmlSchemaEnumerationFacet;
+import org.apache.ws.commons.schema.XmlSchemaGroupBase;
+import org.apache.ws.commons.schema.XmlSchemaObject;
+import org.apache.ws.commons.schema.XmlSchemaObjectCollection;
+import org.apache.ws.commons.schema.XmlSchemaParticle;
+import org.apache.ws.commons.schema.XmlSchemaSequence;
+import org.apache.ws.commons.schema.XmlSchemaSimpleType;
+import org.apache.ws.commons.schema.XmlSchemaSimpleTypeContent;
+import org.apache.ws.commons.schema.XmlSchemaSimpleTypeList;
+import org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction;
+import org.apache.ws.commons.schema.XmlSchemaType;
+import org.apache.ws.commons.schema.XmlSchemaContentModel;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
import javax.xml.namespace.QName;
import java.net.URI;
import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import java.util.jar.JarFile;
-public class XmlBeansSchemaInfoBuilder {
+public class CommonsSchemaInfoBuilder {
private static final Log log = LogFactory.getLog(XmlBeansSchemaInfoBuilder.class);
+ private static final String XML_SCHEMA_NS = "http://www.w3.org/2001/XMLSchema";
+ private static final String XML_NS_NS = "http://www.w3.org/2000/xmlns/";
private static final String SOAP_ENCODING_NS = "http://schemas.xmlsoap.org/soap/encoding/";
+ private static final QName SOAP_ARRAY = new QName(SOAP_ENCODING_NS, "Array");
+ private static final QName SOAP_ARRAY_TYPE = new QName(SOAP_ENCODING_NS, "arrayType");
+ private static final QName WSDL_ARRAY_TYPE = new QName("http://schemas.xmlsoap.org/wsdl/", "arrayType");
- private final JarFile moduleFile;
- private final URI wsdlUri;
+ private final XmlSchemaCollection xmlSchemaCollection;
- public XmlBeansSchemaInfoBuilder(JarFile moduleFile, URI wsdlUri) throws OpenEJBException {
+ private final Map<QName, XmlTypeInfo> xmlTypes = new HashMap<QName, XmlTypeInfo>();
+ private final Map<QName, XmlElementInfo> xmlElements = new HashMap<QName, XmlElementInfo>();
+
+ public CommonsSchemaInfoBuilder(JarFile moduleFile, URI wsdlUri) throws OpenEJBException {
if (moduleFile == null) throw new NullPointerException("moduleFile is null");
if (wsdlUri == null) throw new NullPointerException("wsdlUri is null");
- this.moduleFile = moduleFile;
- this.wsdlUri = wsdlUri;
+ CommonsSchemaLoader schemaLoader = new CommonsSchemaLoader(wsdlUri, moduleFile);
+ xmlSchemaCollection = schemaLoader.loadSchema();
+ }
+
+ public CommonsSchemaInfoBuilder(XmlSchemaCollection xmlSchemaCollection) {
+ if (xmlSchemaCollection == null) throw new NullPointerException("schemaTypeSystem is null");
+ this.xmlSchemaCollection = xmlSchemaCollection;
}
public XmlSchemaInfo createSchemaInfo() throws OpenEJBException {
- XmlBeansSchemaLoader schemaLoader = new XmlBeansSchemaLoader(wsdlUri, moduleFile);
- SchemaTypeSystem schemaTypeSystem = schemaLoader.loadSchema();
- List<XmlTypeInfo> list = buildSchemaTypeKeyToSchemaTypeMap(schemaTypeSystem);
+ buildXmlTypeInfos();
XmlSchemaInfo schemaInfo = new XmlSchemaInfo();
- for (XmlTypeInfo type : list) {
- schemaInfo.types.put(type.qname, type);
- }
+ schemaInfo.types.putAll(xmlTypes);
+ schemaInfo.elements.putAll(xmlElements);
return schemaInfo;
}
/**
* builds a map of SchemaTypeKey containing jaxrpc-style fake QName and context info to xmlbeans SchemaType object.
- *
- * @param schemaTypeSystem
- * @return Map of SchemaTypeKey to xmlbeans SchemaType object.
*/
- private List<XmlTypeInfo> buildSchemaTypeKeyToSchemaTypeMap(SchemaTypeSystem schemaTypeSystem) {
- List<XmlTypeInfo> types = new ArrayList<XmlTypeInfo>();
+ private void buildXmlTypeInfos() {
+ for (XmlSchema schema : xmlSchemaCollection.getXmlSchemas()) {
+ // Global Elements
+ for (Iterator iterator = schema.getElements().getValues(); iterator.hasNext();) {
+ XmlSchemaElement globalElement = (XmlSchemaElement) iterator.next();
+ addGlobalElement(globalElement);
+ }
- SchemaType[] globalTypes = schemaTypeSystem.globalTypes();
- for (SchemaType globalType : globalTypes) {
- QName typeQName = globalType.getName();
- addSchemaType(typeQName, globalType, false, types);
+ // Global Types
+ for (Iterator iterator = schema.getSchemaTypes().getValues(); iterator.hasNext();) {
+ XmlSchemaType globalType = (XmlSchemaType) iterator.next();
+ addType(globalType.getQName(), globalType);
+ }
}
+ }
- SchemaGlobalElement[] globalElements = schemaTypeSystem.globalElements();
- for (SchemaGlobalElement globalElement : globalElements) {
- addElement(globalElement, null, types);
+ private void addGlobalElement(XmlSchemaElement element) {
+ // Nested anonymous type
+ QName xmlType = element.getSchemaTypeName();
+ if (xmlType == null) {
+ // Rule 1.b: Anonymous type inside an element ">E"
+ xmlType = new QName(element.getQName().getNamespaceURI(), ">" + element.getQName().getLocalPart());
+ addType(xmlType, element.getSchemaType());
}
- return types;
+ // create the XmlElementInfo
+ XmlElementInfo elementInfo = createXmlElementInfo(element.getQName(), xmlType, element);
+ xmlElements.put(element.getQName(), elementInfo);
+
}
- private void addElement(SchemaField element, XmlTypeInfo type, List<XmlTypeInfo> types) {
- //TODO is this null if element is a ref?
- QName elementName = element.getName();
- String elementNamespace = elementName.getNamespaceURI();
- //"" namespace means local element with elementFormDefault="unqualified"
- if (elementNamespace == null || elementNamespace.equals("")) {
- elementNamespace = type.qname.getNamespaceURI();
- }
- SchemaType schemaType = element.getType();
+ private static XmlElementInfo createXmlElementInfo(QName qname, QName xmlType, XmlSchemaElement element) {
+ XmlElementInfo elementInfo = new XmlElementInfo();
- String elementQNameLocalName;
- XmlTypeInfo elementType;
- if (type == null) {
- //top level. rule 2.a,
- elementQNameLocalName = elementName.getLocalPart();
- elementType = createXmlTypeInfo(elementName, false, elementName, schemaType);
- } else {
- //not top level. rule 2.b, key will be for enclosing Type.
- QName enclosingTypeQName = type.qname;
- String enclosingTypeLocalName = enclosingTypeQName.getLocalPart();
- elementQNameLocalName = enclosingTypeLocalName + ">" + elementName.getLocalPart();
- QName subElementName = new QName(elementNamespace, elementQNameLocalName);
- elementType = createXmlTypeInfo(subElementName, true, elementName, schemaType);
- }
- types.add(elementType);
-
-// new Exception("Adding: " + elementKey.getqName().getLocalPart()).printStackTrace();
- //check if it's an array. maxOccurs is null if unbounded
- //element should always be a SchemaParticle... this is a workaround for XMLBEANS-137
- if (element instanceof SchemaParticle) {
- addArrayForms((SchemaParticle) element, elementType.qname, types, schemaType);
- } else {
- log.warn("element is not a schemaParticle! " + element);
- }
- //now, name for type. Rule 1.b, type inside an element
- String typeQNameLocalPart = ">" + elementQNameLocalName;
- QName typeQName = new QName(elementNamespace, typeQNameLocalPart);
- boolean isAnonymous = true;
- addSchemaType(typeQName, schemaType, isAnonymous, types);
- }
-
- private void addSchemaType(QName typeQName, SchemaType schemaType, boolean anonymous, List<XmlTypeInfo> types) {
- XmlTypeInfo type = createXmlTypeInfo(typeQName, anonymous, null, schemaType);
- types.add(type);
-// new Exception("Adding: " + typeKey.getqName().getLocalPart()).printStackTrace();
- //TODO xmlbeans recommends using summary info from getElementProperties and getAttributeProperties instead of traversing the content model by hand.
- SchemaParticle schemaParticle = schemaType.getContentModel();
- if (schemaParticle != null) {
- addSchemaParticle(schemaParticle, type, types);
- }
- }
+ elementInfo.qname = qname;
+ elementInfo.xmlType = xmlType;
+ elementInfo.minOccurs = element.getMinOccurs();
+ elementInfo.maxOccurs = element.getMaxOccurs();
+ elementInfo.nillable = element.isNillable();
+ return elementInfo;
+ }
- private void addSchemaParticle(SchemaParticle schemaParticle, XmlTypeInfo type, List<XmlTypeInfo> types) {
- if (schemaParticle.getParticleType() == SchemaParticle.ELEMENT) {
- SchemaType elementType = schemaParticle.getType();
- SchemaField element = elementType.getContainerField();
- //element will be null if the type is defined elsewhere, such as a built in type.
- if (element != null) {
- addElement(element, type, types);
- } else {
- QName keyQName = type.qname;
- //TODO I can't distinguish between 3.a and 3.b, so generate names both ways.
- //3.b
- String localPart = schemaParticle.getName().getLocalPart();
- QName elementName = new QName(keyQName.getNamespaceURI(), localPart);
- addArrayForms(schemaParticle, elementName, types, elementType);
- //3.a
- localPart = keyQName.getLocalPart() + ">" + schemaParticle.getName().getLocalPart();
- elementName = new QName(keyQName.getNamespaceURI(), localPart);
- addArrayForms(schemaParticle, elementName, types, elementType);
- }
- } else {
- try {
- for (SchemaParticle child : schemaParticle.getParticleChildren()) {
- addSchemaParticle(child, type, types);
- }
- } catch (NullPointerException e) {
- //ignore xmlbeans bug
+ private void addType(QName typeQName, XmlSchemaType type) {
+ // skip built in xml schema types
+ if (XML_SCHEMA_NS.equals(typeQName.getNamespaceURI())) {
+ return;
+ }
+
+ XmlTypeInfo typeInfo = createXmlTypeInfo(typeQName, type);
+ xmlTypes.put(typeQName, typeInfo);
+
+ if (type instanceof XmlSchemaComplexType) {
+ XmlSchemaComplexType complexType = (XmlSchemaComplexType) type;
+
+ // process elements nested inside of this element
+ List<XmlSchemaElement> elements = getNestedElements(complexType);
+ for (XmlSchemaElement element : elements) {
+ addNestedElement(element, typeInfo);
}
}
}
- private void addArrayForms(SchemaParticle schemaParticle, QName keyName, List<XmlTypeInfo> types, SchemaType elementType) {
- //it may be a ref or a built in type. If it's an array (maxOccurs >1) form a type for it.
- if (schemaParticle.getIntMaxOccurs() > 1) {
- String maxOccurs = schemaParticle.getMaxOccurs() == null ? "unbounded" : "" + schemaParticle.getIntMaxOccurs();
- int minOccurs = schemaParticle.getIntMinOccurs();
- QName elementName = schemaParticle.getName();
- String arrayQNameLocalName = keyName.getLocalPart() + "[" + minOccurs + "," + maxOccurs + "]";
- String elementNamespace = elementName.getNamespaceURI();
+ private void addNestedElement(XmlSchemaElement element, XmlTypeInfo enclosingType) {
+ QName elementQName;
+ QName typeQName;
+ if (element.getRefName() == null) {
+ //
+ // Normal element in a type
+ //
+
+ // Element Name with namespace
+ String elementNamespace = element.getQName().getNamespaceURI();
if (elementNamespace == null || elementNamespace.equals("")) {
- elementNamespace = keyName.getNamespaceURI();
+ elementNamespace = enclosingType.qname.getNamespaceURI();
}
- QName arrayName = new QName(elementNamespace, arrayQNameLocalName);
- XmlTypeInfo arrayType = createXmlTypeInfo(arrayName, true, elementName, elementType);
- //TODO not clear we want the schemaType as the value
- types.add(arrayType);
-// new Exception("Adding: " + arrayKey.getqName().getLocalPart()).printStackTrace();
- if (minOccurs == 1) {
- arrayQNameLocalName = keyName.getLocalPart() + "[," + maxOccurs + "]";
- arrayName = new QName(elementNamespace, arrayQNameLocalName);
- arrayType = createXmlTypeInfo(arrayName, true, elementName, elementType);
- //TODO not clear we want the schemaType as the value
- types.add(arrayType);
+ elementQName = new QName(elementNamespace, element.getQName().getLocalPart());
+
+ // Type name
+ if (element.getSchemaTypeName() != null) {
+ // Global type
+ typeQName = element.getSchemaTypeName();
+ } else {
+ // Anonymous type, so we need to declare it
+
+ // Rule 2.b: Anonymous element absolute name ÒT>NÓ
+ String anonymoustName = enclosingType.qname.getLocalPart() + ">" + elementQName.getLocalPart();
+ QName anonymousQName = new QName(elementNamespace, anonymoustName);
+
+ // Rule 1.b: Anonymous type name ">E"
+ typeQName = new QName(elementNamespace, ">" + anonymousQName.getLocalPart());
+ addType(typeQName, element.getSchemaType());
}
+ } else {
+ //
+ // Referenced global element
+ //
+
+ // Local the referenced global element
+ XmlSchemaElement refElement = xmlSchemaCollection.getElementByQName(element.getRefName());
+
+ // The name and type of the nested element are determined by the referenced element
+ elementQName = refElement.getQName();
+ typeQName = refElement.getSchemaTypeName();
}
+
+ // Add element to enclosing type
+ XmlElementInfo nestedElement = createXmlElementInfo(elementQName, typeQName, element);
+ enclosingType.elements.put(nestedElement.qname, nestedElement);
}
- public static XmlTypeInfo createXmlTypeInfo(QName name, // schema type name, element name or generated anonymous name
- boolean anonymous, //
- QName elementQName, //
- SchemaType schemaType) {
-
- if (name == null) throw new NullPointerException("qname is null");
- if (schemaType == null) throw new NullPointerException("schemaType is null");
-
- XmlTypeInfo type = new XmlTypeInfo();
- type.qname = name;
- type.anonymous = anonymous;
- type.elementQName = elementQName;
-
- type.simpleType = schemaType.isSimpleType();
- type.xmlType = schemaType.getName();
- type.restriction = schemaType.getDerivationType() == SchemaType.DT_RESTRICTION;
-
- type.arrayComponentType = extractArrayComponentType(schemaType);
-
- // Map type QName to declaration (including nested types)
- if (schemaType.getContentModel() != null) {
- int particleType = schemaType.getContentModel().getParticleType();
- if (SchemaParticle.ELEMENT == particleType) {
- XmlNestedElementInfo nestedElement = createXmlNestedElementInfo(schemaType.getContentModel());
- type.nestedElements.put(nestedElement.qname, nestedElement);
- } else if (particleType == SchemaParticle.SEQUENCE || particleType == SchemaParticle.ALL) {
- for (SchemaParticle parameter : schemaType.getContentModel().getParticleChildren()) {
- // ignore non-element types
- if (parameter.getParticleType() == SchemaParticle.ELEMENT) {
- XmlNestedElementInfo nestedElement = createXmlNestedElementInfo(parameter);
- type.nestedElements.put(nestedElement.qname, nestedElement);
+ public static XmlTypeInfo createXmlTypeInfo(QName qname, XmlSchemaType type) {
+ if (qname == null) throw new NullPointerException("qname is null");
+ if (type == null) throw new NullPointerException("type is null");
+
+ XmlTypeInfo typeInfo = new XmlTypeInfo();
+ typeInfo.qname = qname;
+ typeInfo.anonymous = qname.getLocalPart().indexOf('>') >= 0;
+
+ if (type instanceof XmlSchemaSimpleType) {
+ XmlSchemaSimpleType simpleType = (XmlSchemaSimpleType) type;
+ XmlSchemaSimpleTypeContent content = simpleType.getContent();
+ if (content instanceof XmlSchemaSimpleTypeList) {
+ XmlSchemaSimpleTypeList list = (XmlSchemaSimpleTypeList) content;
+ typeInfo.simpleBaseType = list.getItemType().getQName();
+
+ // this is a list
+ typeInfo.listType = true;
+ } else if(content instanceof XmlSchemaSimpleTypeRestriction) {
+ XmlSchemaSimpleTypeRestriction restriction = (XmlSchemaSimpleTypeRestriction) content;
+ typeInfo.simpleBaseType = restriction.getBaseTypeName();
+
+ // is this an enumeration?
+ for (Iterator iterator = restriction.getFacets().getIterator(); iterator.hasNext();) {
+ if (iterator.next() instanceof XmlSchemaEnumerationFacet) {
+ typeInfo.enumType = true;
+ break;
}
+
}
- } else {
- throw new IllegalArgumentException("Only all, choice and sequence particle types are supported." + " SchemaType name =" + schemaType.getName());
}
- }
+ } else if (type instanceof XmlSchemaComplexType) {
+ XmlSchemaComplexType complexType = (XmlSchemaComplexType) type;
+
+ // SOAP array component type
+ typeInfo.arrayComponentType = extractSoapArrayComponentType(complexType);
- // Index attributes by name
- if (schemaType.getAttributeModel() != null) {
- for (SchemaLocalAttribute attribute : schemaType.getAttributeModel().getAttributes()) {
- Object old = type.attributeTypes.put(attribute.getName().getLocalPart(), attribute.getType().getName());
- if (old != null) {
- throw new IllegalArgumentException("Complain to your expert group member, spec does not support attributes with the same local name and differing namespaces: original: " + old + ", duplicate local name: " + attribute);
+ // process attributes (skip soap arrays which have non-mappable attributes)
+ if (!isSoapArray(complexType)) {
+ XmlSchemaObjectCollection attributes = complexType.getAttributes();
+ for (Iterator iterator = attributes.getIterator(); iterator.hasNext();) {
+ Object item = iterator.next();
+ if (item instanceof XmlSchemaAttribute) {
+ XmlSchemaAttribute attribute = (XmlSchemaAttribute) item;
+ Object old = typeInfo.attributes.put(attribute.getQName().getLocalPart(), attribute.getSchemaTypeName());
+ if (old != null) {
+ throw new IllegalArgumentException("Complain to your expert group member, spec does not support attributes with the same local name and differing namespaces: original: " + old + ", duplicate local name: " + attribute);
+ }
+ }
}
}
+ } else {
+ log.warn("Unknown schema type class " + typeInfo.getClass().getName());
}
- //
- // Blah
- //
- type.enumType = schemaType.getEnumerationValues() != null;
- type.listType = schemaType.getSimpleVariety() == SchemaType.LIST;
-
- QName baseType = null;
- if (schemaType.isSimpleType()) {
- if (schemaType.getSimpleVariety() == SchemaType.ATOMIC) {
- baseType = schemaType.getPrimitiveType().getName();
- } else if (schemaType.getSimpleVariety() == SchemaType.LIST) {
- // not needed but we could use it
- // baseType = schemaType.getListItemType().getName();
- }
- } else {
- if (SchemaType.SIMPLE_CONTENT == schemaType.getContentType()) {
- baseType = schemaType.getBaseType().getName();
- } else if (SchemaType.EMPTY_CONTENT == schemaType.getContentType() ||
- SchemaType.ELEMENT_CONTENT == schemaType.getContentType() ||
- SchemaType.MIXED_CONTENT == schemaType.getContentType()) {
- baseType = schemaType.getName();
- }
+ return typeInfo;
+ }
+
+ private static boolean isSoapArray(XmlSchemaComplexType complexType) {
+ // Soap arrays are based on complex content restriction
+ XmlSchemaContentModel contentModel = complexType.getContentModel();
+ if (contentModel == null) {
+ return false;
+ }
+ XmlSchemaContent content = contentModel.getContent();
+ if (!(content instanceof XmlSchemaComplexContentRestriction)) {
+ return false;
}
- type.baseType = baseType;
- return type;
+ XmlSchemaComplexContentRestriction restriction = (XmlSchemaComplexContentRestriction) content;
+ return SOAP_ARRAY.equals(restriction.getBaseTypeName());
}
/**
* Extract the nested component type of an Array from the XML Schema Type.
* @return the QName of the nested component type or null if the schema type can not be determined
- * @throws org.apache.openejb.OpenEJBException if the XML Schema Type can not represent an Array
- * @param schemaType
+ * @throws org.apache.openejb.OpenEJBException if the XML Schema Type can not represent an Array @param complexType
*/
- private static QName extractArrayComponentType(SchemaType schemaType) {
+ private static QName extractSoapArrayComponentType(XmlSchemaComplexType complexType) {
+ // Soap arrays are based on complex content restriction
+ if (!isSoapArray(complexType)) {
+ return null;
+ }
+
+ XmlSchemaComplexContentRestriction restriction = (XmlSchemaComplexContentRestriction) complexType.getContentModel().getContent();
+
//First, handle case that looks like this:
// <complexType name="ArrayOfstring">
// <complexContent>
@@ -288,19 +299,38 @@
// </restriction>
// </complexContent>
// </complexType>
- SchemaLocalAttribute arrayTypeAttribute = schemaType.getAttributeModel().getAttribute(new QName(SOAP_ENCODING_NS, "arrayType"));
- if (arrayTypeAttribute != null) {
- SchemaWSDLArrayType wsdlArrayType = (SchemaWSDLArrayType) arrayTypeAttribute;
- SOAPArrayType soapArrayType = wsdlArrayType.getWSDLArrayType();
- if (soapArrayType != null) {
- QName componentType = soapArrayType.getQName();
- log.debug("Extracted componentType " + componentType + " from schemaType " + schemaType);
- return componentType;
- } else {
- log.info("No SOAPArrayType for component from schemaType " + schemaType);
+ XmlSchemaObjectCollection attributes = restriction.getAttributes();
+ for (Iterator iterator = attributes.getIterator(); iterator.hasNext();) {
+ Object item = iterator.next();
+ if (item instanceof XmlSchemaAttribute) {
+ XmlSchemaAttribute attribute = (XmlSchemaAttribute) item;
+ if (attribute.getRefName().equals(SOAP_ARRAY_TYPE)) {
+ for (Attr attr : attribute.getUnhandledAttributes()) {
+ QName attQName = new QName(attr.getNamespaceURI(), attr.getLocalName());
+ if (WSDL_ARRAY_TYPE.equals(attQName)) {
+ // value is a namespace prefixed xsd type
+ String value = attr.getValue();
+
+ // extract local part
+ int pos = value.lastIndexOf(":");
+ QName componentType;
+ if (pos < 0) {
+ componentType = new QName("", value);
+ } else {
+ String localPart = value.substring(pos + 1);
+
+ // resolve the namespace prefix
+ String prefix = value.substring(0, pos);
+ String namespace = getNamespaceForPrefix(prefix, attr.getOwnerElement());
+
+ componentType = new QName(namespace, localPart);
+ }
+ log.debug("determined component type from element type");
+ return componentType;
+ }
+ }
+ }
}
- } else {
- log.warn("No soap array info for schematype: " + schemaType);
}
// If that didn't work, try to handle case like this:
@@ -313,37 +343,67 @@
// </restriction>
// </complexContent>
// </complexType>
- if (schemaType.getBaseType().getName().equals(new QName(SOAP_ENCODING_NS, "Array"))) {
- SchemaProperty[] properties = schemaType.getDerivedProperties();
- if (properties.length != 1) {
- throw new IllegalArgumentException("more than one element inside array definition: " + schemaType);
- }
- QName componentType = properties[0].getType().getName();
- log.debug("determined component type from element type");
- return componentType;
+ XmlSchemaParticle particle = restriction.getParticle();
+ if (particle instanceof XmlSchemaSequence) {
+ XmlSchemaSequence sequence = (XmlSchemaSequence) particle;
+ if (sequence.getItems().getCount() != 1) {
+ throw new IllegalArgumentException("more than one element inside array definition: " + complexType);
+ }
+ XmlSchemaObject item = sequence.getItems().getItem(0);
+ if (item instanceof XmlSchemaElement) {
+ XmlSchemaElement element = (XmlSchemaElement) item;
+ QName componentType = element.getSchemaTypeName();
+ log.debug("determined component type from element type");
+ return componentType;
+ }
}
return null;
}
- private static XmlNestedElementInfo createXmlNestedElementInfo(SchemaParticle particle) {
- XmlNestedElementInfo nestedElementInfo = new XmlNestedElementInfo();
+ private static String getNamespaceForPrefix(String prefix, Element element) {
+ NamedNodeMap attributes = element.getAttributes();
+ for (int i = 0; i < attributes.getLength(); i++) {
+ Node node = attributes.item(i);
+ if (node instanceof Attr) {
+ Attr attr = (Attr) node;
+ if (XML_NS_NS.equals(attr.getNamespaceURI())) {
+ // this is a namespace declaration, is it the one we are looking for?
+ if (attr.getLocalName().equals(prefix)) {
+ return attr.getValue();
+ }
+ }
+ }
+ }
- nestedElementInfo.qname = particle.getName();
- nestedElementInfo.xmlType = particle.getType().getName();
- nestedElementInfo.simpleType = particle.getType().isSimpleType();
-
- SchemaType baseType = particle.getType().getBaseType();
- if (baseType != null) {
- nestedElementInfo.baseType = particle.getType().getBaseType().getName();
- } else {
- nestedElementInfo.baseType = null;
+ // try parent
+ if (element.getParentNode() instanceof Element) {
+ return getNamespaceForPrefix(prefix, (Element) element.getParentNode());
}
- nestedElementInfo.minOccurs = particle.getIntMinOccurs();
- nestedElementInfo.maxOccurs = particle.getIntMaxOccurs();
- nestedElementInfo.nillable = particle.isNillable();
+ // didn't find it - just use prefix as the namespace
+ return prefix;
+ }
+
- return nestedElementInfo;
+ private static List<XmlSchemaElement> getNestedElements(XmlSchemaComplexType complexType) {
+ List<XmlSchemaElement> elements = new ArrayList<XmlSchemaElement>();
+ XmlSchemaParticle particle = complexType.getParticle();
+ if (particle instanceof XmlSchemaElement) {
+ XmlSchemaElement element = (XmlSchemaElement) particle;
+ elements.add(element);
+ } else if (particle instanceof XmlSchemaGroupBase && !(particle instanceof XmlSchemaChoice)) {
+ XmlSchemaGroupBase groupBase = (XmlSchemaGroupBase) particle;
+ for (Iterator iterator = groupBase.getItems().getIterator(); iterator.hasNext();) {
+ XmlSchemaParticle child = (XmlSchemaParticle) iterator.next();
+ if (child instanceof XmlSchemaElement) {
+ XmlSchemaElement element = (XmlSchemaElement) child;
+ elements.add(element);
+ }
+ }
+ } else {
+ // ignore all other types... you can have these other types, but JAX-RPC doesn't support them
+ }
+ return elements;
}
-}
+}
\ No newline at end of file
Copied: openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/CommonsSchemaLoader.java (from r601187, openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/XmlBeansSchemaLoader.java)
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/CommonsSchemaLoader.java?p2=openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/CommonsSchemaLoader.java&p1=openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/XmlBeansSchemaLoader.java&r1=601187&r2=602291&rev=602291&view=diff
==============================================================================
--- openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/XmlBeansSchemaLoader.java (original)
+++ openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/CommonsSchemaLoader.java Fri Dec 7 17:35:30 2007
@@ -22,18 +22,9 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.openejb.OpenEJBException;
-import org.apache.xmlbeans.SchemaTypeSystem;
-import org.apache.xmlbeans.XmlBeans;
-import org.apache.xmlbeans.XmlCursor;
-import org.apache.xmlbeans.XmlError;
-import org.apache.xmlbeans.XmlException;
-import org.apache.xmlbeans.XmlObject;
-import org.apache.xmlbeans.XmlOptions;
-import org.apache.xmlbeans.impl.xb.xsdschema.SchemaDocument;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
import org.w3c.dom.Element;
-import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
import javax.wsdl.Definition;
import javax.wsdl.Import;
@@ -49,106 +40,31 @@
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
-import java.net.URISyntaxException;
import java.util.ArrayList;
-import java.util.Collection;
-import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.jar.JarFile;
import java.util.zip.ZipEntry;
-public class XmlBeansSchemaLoader {
+public class CommonsSchemaLoader {
private static final Log log = LogFactory.getLog(XmlBeansSchemaInfoBuilder.class);
- private static final SchemaTypeSystem basicTypeSystem;
-
- private static XmlOptions createXmlOptions(Collection errors) {
- XmlOptions options = new XmlOptions();
- options.setLoadLineNumbers();
- options.setErrorListener(errors);
- return options;
- }
-
- static {
- InputStream is = XmlBeansSchemaInfoBuilder.class.getClassLoader().getResourceAsStream("META-INF/schema/soap_encoding_1_1.xsd");
- if (is == null) {
- throw new RuntimeException("Could not locate soap encoding schema");
- }
- ArrayList errors = new ArrayList();
- XmlOptions xmlOptions = createXmlOptions(errors);
- try {
- SchemaDocument parsed = SchemaDocument.Factory.parse(is, xmlOptions);
- if (errors.size() != 0) {
- throw new XmlException(errors.toArray().toString());
- }
-
- basicTypeSystem = XmlBeans.compileXsd(new XmlObject[]{parsed}, XmlBeans.getBuiltinTypeSystem(), xmlOptions);
- if (errors.size() > 0) {
- throw new RuntimeException("Could not compile schema type system: errors: " + errors);
- }
- } catch (XmlException e) {
- throw new RuntimeException("Could not compile schema type system", e);
- } catch (IOException e) {
- throw new RuntimeException("Could not compile schema type system", e);
- } finally {
- try {
- is.close();
- } catch (IOException ignore) {
- // ignore
- }
- }
- }
private final URI wsdlUri;
private final JarFile moduleFile;
- private final LinkedList<URI> uris = new LinkedList<URI>();
-
+ private final XmlSchemaCollection xmlSchemaCollection = new XmlSchemaCollection();
- public XmlBeansSchemaLoader(URI wsdlUri, JarFile moduleFile) {
+ public CommonsSchemaLoader(URI wsdlUri, JarFile moduleFile) {
this.wsdlUri = wsdlUri;
this.moduleFile = moduleFile;
- uris.addFirst(wsdlUri);
}
- public SchemaTypeSystem loadSchema() throws OpenEJBException {
+ public XmlSchemaCollection loadSchema() throws OpenEJBException {
Definition definition = readWsdl(wsdlUri);
-
- List<XmlObject> schemaList = new ArrayList<XmlObject>();
- addImportsFromDefinition(definition, schemaList);
-// System.out.println("Schemas: " + schemaList);
- Collection<XmlError> errors = new ArrayList<XmlError>();
- XmlOptions xmlOptions = new XmlOptions();
- xmlOptions.setErrorListener(errors);
- xmlOptions.setEntityResolver(new JarEntityResolver());
- XmlObject[] schemas = schemaList.toArray(new XmlObject[schemaList.size()]);
- try {
- SchemaTypeSystem schemaTypeSystem = XmlBeans.compileXsd(schemas, basicTypeSystem, xmlOptions);
- if (errors.size() > 0) {
- boolean wasError = false;
- for (XmlError xmlError : errors) {
- if (xmlError.getSeverity() == XmlError.SEVERITY_ERROR) {
- log.error(xmlError);
- wasError = true;
- } else if (xmlError.getSeverity() == XmlError.SEVERITY_WARNING) {
- log.warn(xmlError);
- } else if (xmlError.getSeverity() == XmlError.SEVERITY_INFO) {
- log.debug(xmlError);
- }
- }
- if (wasError) {
- throw new OpenEJBException("Could not compile schema type system, see log for errors");
- }
- }
- return schemaTypeSystem;
- } catch (XmlException e) {
- throw new OpenEJBException("Could not compile schema type system: " + schemaList, e);
- }
+ addImportsFromDefinition(definition);
+ return xmlSchemaCollection;
}
- private void addImportsFromDefinition(Definition definition, List<XmlObject> schemaList) throws OpenEJBException {
- //noinspection unchecked
- Map<String,String> namespaceMap = definition.getNamespaces();
-
+ private void addImportsFromDefinition(Definition definition) throws OpenEJBException {
Types types = definition.getTypes();
if (types != null) {
for (Object extensibilityElement : types.getExtensibilityElements()) {
@@ -157,7 +73,7 @@
QName elementType = unknownExtensibilityElement.getElementType();
if (new QName("http://www.w3.org/2001/XMLSchema", "schema").equals(elementType)) {
Element element = unknownExtensibilityElement.getElement();
- addSchemaElement(element, namespaceMap, schemaList);
+ xmlSchemaCollection.read(element);
}
} else if (extensibilityElement instanceof UnknownExtensibilityElement) {
//This is allegedly obsolete as of axis-wsdl4j-1.2-RC3.jar which includes the Schema extension above.
@@ -167,7 +83,7 @@
String elementNamespace = element.getNamespaceURI();
String elementLocalName = element.getNodeName();
if ("http://www.w3.org/2001/XMLSchema".equals(elementNamespace) && "schema".equals(elementLocalName)) {
- addSchemaElement(element, namespaceMap, schemaList);
+ xmlSchemaCollection.read(element);
}
}
}
@@ -182,19 +98,9 @@
for (Import anImport : importList) {
//according to the 1.1 jwsdl mr shcema imports are supposed to show up here,
//but according to the 1.0 spec there is supposed to be no Definition.
- Definition definition1 = anImport.getDefinition();
- if (definition1 != null) {
- try {
- URI uri = new URI(definition1.getDocumentBaseURI());
- uris.addFirst(uri);
- } catch (URISyntaxException e) {
- throw new OpenEJBException("Could not locate definition", e);
- }
- try {
- addImportsFromDefinition(definition1, schemaList);
- } finally {
- uris.removeFirst();
- }
+ Definition importedDef = anImport.getDefinition();
+ if (importedDef != null) {
+ addImportsFromDefinition(importedDef);
} else {
log.warn("Missing definition in import for namespace " + namespaceURI);
}
@@ -203,34 +109,6 @@
}
}
- private void addSchemaElement(Element element, Map<String,String> namespaceMap, List<XmlObject> schemaList) throws OpenEJBException {
- try {
- XmlObject xmlObject = parseWithNamespaces(element, namespaceMap);
- schemaList.add(xmlObject);
- } catch (XmlException e) {
- throw new OpenEJBException("Could not parse schema element", e);
- }
- }
-
- static XmlObject parseWithNamespaces(Element element, Map<String,String> namespaceMap) throws XmlException {
- ArrayList errors = new ArrayList();
- XmlOptions xmlOptions = createXmlOptions(errors);
- SchemaDocument parsed = SchemaDocument.Factory.parse(element, xmlOptions);
- if (errors.size() != 0) {
- throw new XmlException(errors.toArray().toString());
- }
- XmlCursor cursor = parsed.newCursor();
- try {
- cursor.toFirstContentToken();
- for (Map.Entry<String,String> entry : namespaceMap.entrySet()) {
- cursor.insertNamespace(entry.getKey(), entry.getValue());
- }
- } finally {
- cursor.dispose();
- }
- return parsed;
- }
-
private Definition readWsdl(URI wsdlURI) throws OpenEJBException {
Definition definition;
WSDLFactory wsdlFactory;
@@ -285,22 +163,6 @@
return definition;
}
- private class JarEntityResolver implements EntityResolver {
-
- private final static String PROJECT_URL_PREFIX = "project://local/";
-
- public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
- //seems like this must be a bug in xmlbeans...
- if (systemId.indexOf(PROJECT_URL_PREFIX) > -1) {
- systemId = systemId.substring(PROJECT_URL_PREFIX.length());
- }
- URI location = uris.peek().resolve(systemId);
- ZipEntry entry = moduleFile.getEntry(location.toString());
- InputStream wsdlInputStream = moduleFile.getInputStream(entry);
- return new InputSource(wsdlInputStream);
- }
- }
-
class JarWSDLLocator implements WSDLLocator {
private final List<InputStream> streams = new ArrayList<InputStream>();
@@ -364,4 +226,4 @@
streams.clear();
}
}
-}
+}
\ No newline at end of file
Modified: openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/HeavyweightOperationInfoBuilder.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/HeavyweightOperationInfoBuilder.java?rev=602291&r1=602290&r2=602291&view=diff
==============================================================================
--- openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/HeavyweightOperationInfoBuilder.java (original)
+++ openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/HeavyweightOperationInfoBuilder.java Fri Dec 7 17:35:30 2007
@@ -191,10 +191,13 @@
// Validate output mapping is complete
if (outputMessage != null && bindingStyle.isWrapped()) {
Part inputPart = getWrappedPart(outputMessage);
- QName name = inputPart.getElementName();
+
+ QName wrapperName = inputPart.getElementName();
+ XmlElementInfo wraperElement = schemaInfo.elements.get(wrapperName);
+ XmlTypeInfo wrapperType = schemaInfo.types.get(wraperElement.xmlType);
Set<String> expectedOutParams = new HashSet<String>();
- for (XmlNestedElementInfo expectedOutParam : schemaInfo.types.get(name).nestedElements.values()) {
+ for (XmlElementInfo expectedOutParam : wrapperType.elements.values()) {
expectedOutParams.add(expectedOutParam.qname.getLocalPart());
}
if (!outParamNames.equals(expectedOutParams)) {
@@ -245,10 +248,13 @@
if (bindingStyle.isWrapped()) {
// verify that all child elements have a parameter mapping
Part inputPart = getWrappedPart(inputMessage);
- QName name = inputPart.getElementName();
+
+ QName wrapperName = inputPart.getElementName();
+ XmlElementInfo wrapperElement = schemaInfo.elements.get(wrapperName);
+ XmlTypeInfo wrapperType = schemaInfo.types.get(wrapperElement.xmlType);
Set<String> expectedInParams = new HashSet<String>();
- for (XmlNestedElementInfo expectedInParam : schemaInfo.types.get(name).nestedElements.values()) {
+ for (XmlElementInfo expectedInParam : wrapperType.elements.values()) {
expectedInParams.add(expectedInParam.qname.getLocalPart());
}
if (!inParamNames.equals(expectedInParams)) {
@@ -289,10 +295,11 @@
}
Part part = null;
- XmlNestedElementInfo inParameter = null;
+ XmlElementInfo inParameter = null;
if (bindingStyle.isWrapped()) {
Part inPart = getWrappedPart(inputMessage);
- // the local name of the global element refered by the part is equal to the operation name
+
+ // operation name == wraper element name
QName name = inPart.getElementName();
if (!name.getLocalPart().equals(operationName)) {
throw new OpenEJBException("message " + inputMessage.getQName() + " refers to a global element named " +
@@ -309,13 +316,15 @@
}
paramQName = new QName("", part.getName());
+
+ // RPC can only use type
paramXmlType = part.getTypeName();
} else {
part = inputMessage.getPart(wsdlMessagePartName);
if (part == null) {
throw new OpenEJBException("No part for wsdlMessagePartName " + wsdlMessagePartName + " in input message for operation " + operationName);
}
-
+ // Document should use element, but type is allowed
paramQName = getPartName(part);
paramXmlType = paramQName;
}
@@ -328,7 +337,7 @@
if (bindingStyle.isWrapped()) {
// Verify output message supports this inout parameter
Part outPart = getWrappedPart(outputMessage);
- XmlNestedElementInfo outParameter = getWrapperChild(outPart, wsdlMessagePartName);
+ XmlElementInfo outParameter = getWrapperChild(outPart, wsdlMessagePartName);
if (inParameter.xmlType != outParameter.xmlType) {
throw new OpenEJBException("The wrapper children " + wsdlMessagePartName + " do not have the same type for operation " + operationName);
}
@@ -370,7 +379,7 @@
if (bindingStyle.isWrapped()) {
Part outPart = getWrappedPart(outputMessage);
- XmlNestedElementInfo outParameter = getWrapperChild(outPart, wsdlMessagePartName);
+ XmlElementInfo outParameter = getWrapperChild(outPart, wsdlMessagePartName);
paramQName = new QName("", outParameter.qname.getLocalPart());
paramXmlType = outParameter.xmlType;
@@ -381,6 +390,8 @@
}
paramQName = new QName("", part.getName());
+
+ // RPC can only use type
paramXmlType = part.getTypeName();
} else {
Part part = outputMessage.getPart(wsdlMessagePartName);
@@ -464,7 +475,7 @@
if (bindingStyle.isWrapped()) {
Part outPart = getWrappedPart(outputMessage);
- XmlNestedElementInfo returnParticle = getWrapperChild(outPart, wsdlMessagePartName);
+ XmlElementInfo returnParticle = getWrapperChild(outPart, wsdlMessagePartName);
returnQName = new QName("", returnParticle.qname.getLocalPart());
returnXmlType = returnParticle.xmlType;
@@ -475,6 +486,8 @@
}
returnQName = new QName("", part.getName());
+
+ // RPC can only use type
returnXmlType = part.getTypeName();
} else {
Part part = outputMessage.getPart(wsdlMessagePartName);
@@ -518,19 +531,26 @@
// Determine the fault qname and xml schema type
QName faultQName;
XmlTypeInfo faultTypeInfo;
- if (part.getElementName() == null) {
- if (part.getTypeName() == null) {
- throw new OpenEJBException("Neither type nor element name supplied for part: " + part);
+ if (part.getElementName() != null) {
+ XmlElementInfo elementInfo = schemaInfo.elements.get(part.getElementName());
+ if (elementInfo == null) {
+ throw new OpenEJBException("Can not find element: " + part.getElementName() + ", known elements: " + schemaInfo.elements.keySet());
+ }
+ faultTypeInfo = schemaInfo.types.get(elementInfo.xmlType);
+ if (faultTypeInfo == null) {
+ throw new OpenEJBException("Can not find type " + elementInfo.xmlType + " for element " + elementInfo.qname + ", known types: " + schemaInfo.types.keySet());
}
- faultQName = new QName("", fault.getName());
- faultTypeInfo = schemaInfo.types.get(part.getTypeName());
- } else {
+
faultQName = part.getElementName();
- faultTypeInfo = schemaInfo.types.get(part.getElementName());
- }
+ } else if (part.getTypeName() != null) {
+ faultTypeInfo = schemaInfo.types.get(part.getTypeName());
+ if (faultTypeInfo == null) {
+ throw new OpenEJBException("Can not find type: " + part.getTypeName() + ", known elements: " + schemaInfo.types.keySet());
+ }
- if (faultTypeInfo == null) {
- throw new OpenEJBException("Can not find type for: element: " + part.getElementName() + ", known elements: " + schemaInfo.types.keySet());
+ faultQName = new QName("", fault.getName());
+ } else {
+ throw new OpenEJBException("Neither type nor element name supplied for part: " + part);
}
//
@@ -538,76 +558,58 @@
//
JaxRpcFaultInfo faultInfo = new JaxRpcFaultInfo();
faultInfo.qname = faultQName;
- faultInfo.xmlType = faultTypeInfo.xmlType;
+ faultInfo.xmlType = faultTypeInfo.qname;
faultInfo.javaType = exceptionMapping.getExceptionType();
- faultInfo.complex = !faultTypeInfo.simpleType;
+ faultInfo.complex = faultTypeInfo.simpleBaseType == null;
//
// Map exception class constructor args
//
if (exceptionMapping.getConstructorParameterOrder() != null) {
- if (!faultInfo.complex) {
- throw new OpenEJBException("ConstructorParameterOrder can only be set for complex types, not " + faultTypeInfo.xmlType);
+ if (faultTypeInfo.simpleBaseType != null) {
+ throw new OpenEJBException("ConstructorParameterOrder can only be set for complex types, not " + faultTypeInfo.qname);
}
- Map<String, XmlNestedElementInfo> elements = new HashMap<String, XmlNestedElementInfo>();
- for (XmlNestedElementInfo element : faultTypeInfo.nestedElements.values()) {
+ Map<String, XmlElementInfo> elements = new HashMap<String, XmlElementInfo>();
+ for (XmlElementInfo element : faultTypeInfo.elements.values()) {
elements.put(element.qname.getLocalPart(), element);
}
ConstructorParameterOrder constructorParameterOrder = exceptionMapping.getConstructorParameterOrder();
for (int i = 0; i < constructorParameterOrder.getElementName().size(); i++) {
- String elementName = constructorParameterOrder.getElementName().get(i);
- XmlNestedElementInfo elementType = elements.get(elementName);
- QName argXmlType = elementType.qname;
-
- // Determine argument java type
- String argJavaType;
- if (argXmlType != null) {
- if (elementType.simpleType) {
- // Simple type with a spec defined java class mapping
- argJavaType = qnameToJavaType.get(argXmlType);
- if (argJavaType == null) {
- throw new OpenEJBException("Unknown type: " + elementType + " of name: " + elementName + " and QName: " + argXmlType);
- }
- } else {
- // Complex type, so java type mapping must be declared
- argJavaType= publicTypes.get(argXmlType);
- if (argJavaType == null) {
- throw new OpenEJBException("No class mapped for element type: " + elementType);
- }
- }
- } else {
- // anonymous type
+ String paramName = constructorParameterOrder.getElementName().get(i);
- // qname is constructed using rules 1.b and 2.b
- String anonymousQName = faultTypeInfo.xmlType.getNamespaceURI() + ":>" + faultTypeInfo.xmlType.getLocalPart() + ">" + elementName;
+ // get the parameter element
+ XmlElementInfo paramElementInfo = elements.get(paramName);
+ if (paramElementInfo == null) {
+ throw new OpenEJBException("Can not find element " + paramName + " in fault type " + faultTypeInfo.qname + ", known elements: " + elements.keySet());
+ }
- // Check for a declared type mapping for this anonymous type
- argJavaType = anonymousTypes.get(anonymousQName);
- if (argJavaType == null) {
- // this must be a simple type...
- if (!elementType.simpleType) {
- throw new OpenEJBException("No class mapped for anonymous type: " + anonymousQName);
- }
-
- // and must have a spec defined java class mapping
- QName simpleTypeQName = elementType.baseType;
- argJavaType = qnameToJavaType.get(simpleTypeQName);
- if (argJavaType == null) {
- throw new OpenEJBException("Unknown simple type: " + elementType + " of name: " + elementName + " and QName: " + simpleTypeQName);
- }
+ // Java Type
+ String paramJavaType = null;
+ XmlTypeInfo paramTypeInfo = schemaInfo.types.get(paramElementInfo.xmlType);
+ if (paramTypeInfo != null) {
+ if (paramTypeInfo.anonymous) {
+ paramJavaType = anonymousTypes.get(paramTypeInfo.qname.getLocalPart());
+ } else {
+ paramJavaType = publicTypes.get(paramTypeInfo.qname);
}
}
+ // if we don't have a java type yet, check the simple types
+ if (paramJavaType == null) {
+ paramJavaType = qnameToJavaType.get(paramElementInfo.xmlType);
+ }
+ if (paramJavaType == null) {
+ throw new OpenEJBException("No class mapped for element type: " + paramElementInfo.xmlType);
+ }
JaxRpcParameterInfo parameterInfo = new JaxRpcParameterInfo();
- // todo faultTypeQName is speculative
- parameterInfo.qname = faultTypeInfo.xmlType;
+ parameterInfo.qname = paramElementInfo.qname;
parameterInfo.mode = Mode.OUT;
// todo could be a soap header
parameterInfo.soapHeader = false;
- parameterInfo.xmlType = argXmlType;
- parameterInfo.javaType = argJavaType;
+ parameterInfo.xmlType = paramElementInfo.xmlType;
+ parameterInfo.javaType = paramJavaType;
faultInfo.parameters.add(parameterInfo);
}
@@ -631,23 +633,30 @@
return (Part) parts.iterator().next();
}
- private XmlNestedElementInfo getWrapperChild(Part part, String wsdlMessagePartName) throws OpenEJBException {
+ private XmlElementInfo getWrapperChild(Part part, String wsdlMessagePartName) throws OpenEJBException {
// get the part name
- QName name = part.getElementName();
- wrapperElementQNames.add(name);
+ QName elementName = part.getElementName();
+ wrapperElementQNames.add(elementName);
- // get the part type
- XmlTypeInfo operationTypeInfo = schemaInfo.types.get(name);
- if (operationTypeInfo == null) {
- throw new OpenEJBException("No global element named " + name + " for operation " + operationName);
+ // get the wrapper element
+ XmlElementInfo wrapperElement = schemaInfo.elements.get(elementName);
+ if (wrapperElement == null) {
+ throw new OpenEJBException("No global element named " + elementName + " for operation " + operationName);
}
- for (XmlNestedElementInfo element : operationTypeInfo.nestedElements.values()) {
- if (element.qname.getLocalPart().equals(wsdlMessagePartName)) {
- return element;
+ // get the wrapper type
+ XmlTypeInfo wrapperType = schemaInfo.types.get(wrapperElement.xmlType);
+ if (wrapperType == null) {
+ throw new OpenEJBException("Can not find type " + wrapperElement.xmlType + " for element " + wrapperElement.qname + ", known types: " + schemaInfo.types.keySet());
+ }
+
+ // get the part type
+ for (XmlElementInfo wrapperChild : wrapperType.elements.values()) {
+ if (wrapperChild.qname.getLocalPart().equals(wsdlMessagePartName)) {
+ return wrapperChild;
}
}
- throw new OpenEJBException("Global element named " + name + " does not define a child element named " + wsdlMessagePartName + " required by the operation " + operationName);
+ throw new OpenEJBException("Global element named " + elementName + " does not define a child element named " + wsdlMessagePartName + " required by the operation " + operationName);
}
//see jaxrpc 1.1 4.2.1
Modified: openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/HeavyweightTypeInfoBuilder.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/HeavyweightTypeInfoBuilder.java?rev=602291&r1=602290&r2=602291&view=diff
==============================================================================
--- openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/HeavyweightTypeInfoBuilder.java (original)
+++ openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/HeavyweightTypeInfoBuilder.java Fri Dec 7 17:35:30 2007
@@ -72,18 +72,16 @@
// Map types with explicity Java to XML mappings
//
for (JavaXmlTypeMapping javaXmlTypeMapping : mapping.getJavaXmlTypeMapping()) {
- QName typeQName;
- XmlTypeInfo xmlTypeInfo;
+ // get the QName for this mapping
+ QName qname;
if (javaXmlTypeMapping.getRootTypeQname() != null) {
- typeQName = javaXmlTypeMapping.getRootTypeQname();
+ qname = javaXmlTypeMapping.getRootTypeQname();
// Skip the wrapper elements.
- if (wrapperElementQNames.contains(typeQName)) {
+ if (wrapperElementQNames.contains(qname)) {
continue;
}
-
- xmlTypeInfo = schemaInfo.types.get(typeQName);
- } else if (javaXmlTypeMapping != null) {
+ } else if (javaXmlTypeMapping.getAnonymousTypeQname() != null) {
String anonTypeQNameString = javaXmlTypeMapping.getAnonymousTypeQname();
// this appears to be ignored...
@@ -91,30 +89,46 @@
if (pos == -1) {
throw new OpenEJBException("anon QName is invalid, no final ':' " + anonTypeQNameString);
}
- typeQName = new QName(anonTypeQNameString.substring(0, pos), anonTypeQNameString.substring(pos + 1));
+ String namespace = anonTypeQNameString.substring(0, pos);
+ String localPart = anonTypeQNameString.substring(pos + 1);
+ qname = new QName(namespace, localPart);
// Skip the wrapper elements.
// todo why is this +2
- if (wrapperElementQNames.contains(new QName(anonTypeQNameString.substring(0, pos), anonTypeQNameString.substring(pos + 2)))) {
+ if (wrapperElementQNames.contains(new QName(namespace, anonTypeQNameString.substring(pos + 2)))) {
continue;
}
-
- xmlTypeInfo = schemaInfo.types.get(typeQName);
} else {
throw new OpenEJBException("either root type qname or anonymous type qname must be set");
}
-// SchemaType schemaType = schemaTypeKeyToSchemaTypeMap.get(key);
+ // get the xml type qname of this mapping
+ QName xmlTypeQName;
+ if ("element".equals(javaXmlTypeMapping.getQNameScope())) {
+ XmlElementInfo elementInfo = schemaInfo.elements.get(qname);
+ if (elementInfo == null) {
+ log.warn("Element [" + qname + "] not been found in schema, known elements: " + schemaInfo.elements.keySet());
+ }
+ xmlTypeQName = elementInfo.xmlType;
+ } else {
+ xmlTypeQName = qname;
+ }
+
+ // finally, get the xml type info for the mapping
+ XmlTypeInfo xmlTypeInfo = schemaInfo.types.get(xmlTypeQName);
if (xmlTypeInfo == null) {
// if this is a built in type then assume this is a redundant mapping
if (WebserviceNameSpaces.contains(xmlTypeInfo.qname.getNamespaceURI())) {
continue;
}
- log.warn("Schema type QName [" + typeQName + "] not been found in schema: " + schemaInfo.types.keySet());
+ log.warn("Schema type QName [" + qname + "] not been found in schema: " + schemaInfo.types.keySet());
continue;
}
+
+ // mark this type as mapped
mappedTypeQNames.add(xmlTypeInfo.qname);
+ // load the java class
Class clazz;
try {
clazz = Class.forName(javaXmlTypeMapping.getJavaType(), false, classLoader);
@@ -122,13 +136,8 @@
throw new OpenEJBException("Could not load java type " + javaXmlTypeMapping.getJavaType(), e);
}
- JaxRpcTypeInfo typeInfo = createTypeInfo(xmlTypeInfo, clazz);
-
- typeInfo.qname = xmlTypeInfo.elementQName;
- if (typeInfo.qname == null) {
- typeInfo.qname = xmlTypeInfo.qname;
- }
-
+ // create the jax-rpc type mapping
+ JaxRpcTypeInfo typeInfo = createTypeInfo(qname, xmlTypeInfo, clazz);
mapFields(clazz, xmlTypeInfo, javaXmlTypeMapping, typeInfo);
typeInfos.add(typeInfo);
@@ -160,7 +169,7 @@
continue;
}
-
+ // get the xml type info
XmlTypeInfo xmlTypeInfo = schemaInfo.types.get(xmlType);
if (xmlTypeInfo == null) {
log.warn("Type QName [" + xmlType + "] defined by operation [" + operationInfo + "] has not been found in schema: " + schemaInfo.types.keySet());
@@ -168,27 +177,25 @@
}
mappedTypeQNames.add(xmlTypeInfo.qname);
- Class<?> javaType;
+ // load the java class
+ Class<?> clazz;
try {
- javaType = classLoader.loadClass(parameterInfo.javaType);
+ clazz = classLoader.loadClass(parameterInfo.javaType);
} catch (ClassNotFoundException e) {
throw new OpenEJBException("Could not load paramter");
}
- if (!xmlTypeInfo.simpleType && !javaType.isArray()) {
- if (!mappedTypeQNames.contains(xmlTypeInfo.xmlType)) {
+ // we only process simpleTypes and arrays (not normal complex types)
+ if (xmlTypeInfo.simpleBaseType == null && !clazz.isArray()) {
+ if (!mappedTypeQNames.contains(xmlTypeInfo.qname)) {
// TODO: this lookup is not enough: the jaxrpc mapping file may define an anonymous mapping
log.warn("Operation " + operationInfo.name + "] uses XML type [" + xmlTypeInfo + "], whose mapping is not declared by the jaxrpc mapping file.\n Continuing deployment; " + "yet, the deployment is not-portable.");
}
continue;
}
- JaxRpcTypeInfo typeInfo = createTypeInfo(xmlTypeInfo, javaType);
- typeInfo.qname = xmlTypeInfo.elementQName;
- if (typeInfo.qname == null) {
- typeInfo.qname = xmlTypeInfo.qname;
- }
-
+ // create the jax-rpc type mapping
+ JaxRpcTypeInfo typeInfo = createTypeInfo(parameterInfo.qname, xmlTypeInfo, clazz);
typeInfos.add(typeInfo);
}
}
@@ -203,9 +210,8 @@
* @return the JaxRpcTypeInfo object
* @throws OpenEJBException if the schema is invalid
*/
- private JaxRpcTypeInfo createTypeInfo(XmlTypeInfo xmlTypeInfo, Class clazz) throws OpenEJBException {
+ private JaxRpcTypeInfo createTypeInfo(QName qname, XmlTypeInfo xmlTypeInfo, Class clazz) throws OpenEJBException {
SerializerType serializerType;
- QName xmlType = null;
if (xmlTypeInfo.listType) {
serializerType = SerializerType.LIST;
} else if (clazz.isArray()) {
@@ -214,16 +220,15 @@
serializerType = SerializerType.ENUM;
} else {
serializerType = SerializerType.OTHER;
- xmlType = xmlTypeInfo.baseType;
}
JaxRpcTypeInfo typeInfo = new JaxRpcTypeInfo();
+ typeInfo.qname = qname;
typeInfo.javaType = clazz.getName();
typeInfo.serializerType = serializerType;
- typeInfo.xmlType = xmlType;
- typeInfo.canSearchParents = xmlTypeInfo.restriction;
+ typeInfo.simpleBaseType = xmlTypeInfo.simpleBaseType;
- // If we understand the axis comments correctly, componentQName is never set for j2ee ws.
+ // If we understand the axis comments correctly, componentQName is never set for a webservice.
if (serializerType == SerializerType.ARRAY) {
typeInfo.componentType = xmlTypeInfo.arrayComponentType;
}
@@ -277,7 +282,7 @@
QName xmlName = new QName("", attributeLocalName);
fieldInfo.xmlName = xmlName;
- fieldInfo.xmlType = xmlTypeInfo.attributeTypes.get(attributeLocalName);
+ fieldInfo.xmlType = xmlTypeInfo.attributes.get(attributeLocalName);
if (fieldInfo.xmlType == null) {
throw new OpenEJBException("attribute " + xmlName + " not found in schema " + xmlTypeInfo.qname);
}
@@ -302,11 +307,11 @@
QName xmlName = new QName("", variableMapping.getXmlElementName());
- XmlNestedElementInfo nestedElement = xmlTypeInfo.nestedElements.get(xmlName);
+ XmlElementInfo nestedElement = xmlTypeInfo.elements.get(xmlName);
if (nestedElement == null) {
String ns = xmlTypeInfo.qname.getNamespaceURI();
xmlName = new QName(ns, variableMapping.getXmlElementName());
- nestedElement = xmlTypeInfo.nestedElements.get(xmlName);
+ nestedElement = xmlTypeInfo.elements.get(xmlName);
if (nestedElement == null) {
throw new OpenEJBException("element " + xmlName + " not found in schema " + xmlTypeInfo.qname);
}
@@ -332,8 +337,6 @@
if (javaType.isArray()) {
fieldInfo.minOccurs = nestedElement.minOccurs;
fieldInfo.maxOccurs = nestedElement.maxOccurs;
- //TODO axis seems to have the wrong name for this property based on how it is used
- fieldInfo.maxOccursUnbounded = nestedElement.maxOccurs > 1;
}
typeInfo.fields.add(fieldInfo);
Modified: openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/JaxRpcFieldInfo.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/JaxRpcFieldInfo.java?rev=602291&r1=602290&r2=602291&view=diff
==============================================================================
--- openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/JaxRpcFieldInfo.java (original)
+++ openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/JaxRpcFieldInfo.java Fri Dec 7 17:35:30 2007
@@ -21,13 +21,13 @@
public class JaxRpcFieldInfo {
public String name;
+ // is an element (or an attribute)
public boolean isElement;
+
public QName xmlName;
public QName xmlType;
+ public long minOccurs;
+ public long maxOccurs;
public boolean isNillable;
-
- public int minOccurs;
- public int maxOccurs;
- public boolean maxOccursUnbounded;
}
Modified: openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/JaxRpcTypeInfo.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/JaxRpcTypeInfo.java?rev=602291&r1=602290&r2=602291&view=diff
==============================================================================
--- openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/JaxRpcTypeInfo.java (original)
+++ openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/JaxRpcTypeInfo.java Fri Dec 7 17:35:30 2007
@@ -26,10 +26,9 @@
// QName is either the real QName or the generated anonymous name
//
public QName qname;
- public boolean canSearchParents;
- // this is the actual qname used to select the serializer and deserializer
- public QName xmlType;
+ // for simple type, the base xml type qname
+ public QName simpleBaseType;
public String javaType;
public SerializerType serializerType;
Modified: openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/LightweightTypeInfoBuilder.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/LightweightTypeInfoBuilder.java?rev=602291&r1=602290&r2=602291&view=diff
==============================================================================
--- openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/LightweightTypeInfoBuilder.java (original)
+++ openejb/trunk/openejb3/server/openejb-axis/src/main/java/org/apache/openejb/server/axis/assembler/LightweightTypeInfoBuilder.java Fri Dec 7 17:35:30 2007
@@ -45,7 +45,8 @@
List<JaxRpcTypeInfo> typeInfoList = new ArrayList<JaxRpcTypeInfo>();
for (XmlTypeInfo xmlTypeInfo : schemaInfo.types.values()) {
- if (!(xmlTypeInfo.elementQName != null) && !xmlTypeInfo.anonymous) {
+ // skip anonymous elements
+ if (!xmlTypeInfo.anonymous) {
QName typeQName = xmlTypeInfo.qname;
Class clazz = loadClass(typeQName, mapping);
@@ -58,8 +59,7 @@
typeInfo.qname = typeQName;
typeInfo.javaType = clazz.getName();
typeInfo.serializerType = serializerType;
- typeInfo.xmlType = typeQName;
- typeInfo.canSearchParents = xmlTypeInfo.restriction;
+ typeInfo.simpleBaseType = xmlTypeInfo.simpleBaseType;
mapFields(clazz, xmlTypeInfo, typeInfo);
@@ -82,7 +82,7 @@
}
// Map the elements nexted in the XML Schema Type
- for (XmlNestedElementInfo nestedElement : xmlTypeInfo.nestedElements.values()) {
+ for (XmlElementInfo nestedElement : xmlTypeInfo.elements.values()) {
String fieldName = nestedElement.qname.getLocalPart();
Class javaType = propertyToClass.get(fieldName);
if (javaType == null) {
@@ -98,7 +98,6 @@
if (javaType.isArray()) {
fieldInfo.minOccurs = nestedElement.minOccurs;
fieldInfo.maxOccurs = nestedElement.maxOccurs;
- fieldInfo.maxOccursUnbounded = nestedElement.maxOccurs > 1;
}
typeInfo.fields.add(fieldInfo);