You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by de...@apache.org on 2006/09/21 14:22:32 UTC
svn commit: r448529 - in /webservices/axis2/trunk/java/modules:
adb-codegen/src/org/apache/axis2/schema/writer/
kernel/src/org/apache/axis2/description/
Author: deepal
Date: Thu Sep 21 05:22:32 2006
New Revision: 448529
URL: http://svn.apache.org/viewvc?view=rev&rev=448529
Log:
fixing AXIS2-937
- generating code for SOAP 1.2 (I think need to test some more)
Modified:
webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisOperation.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java
Modified: webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java?view=diff&rev=448529&r1=448528&r2=448529
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java Thu Sep 21 05:22:32 2006
@@ -1,44 +1,28 @@
package org.apache.axis2.schema.writer;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Iterator;
-import javax.xml.namespace.QName;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.Templates;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.stream.StreamSource;
-
-import org.apache.axis2.schema.BeanWriterMetaInfoHolder;
-import org.apache.axis2.schema.CompilerOptions;
-import org.apache.axis2.schema.SchemaCompilationException;
-import org.apache.axis2.schema.SchemaCompiler;
-import org.apache.axis2.schema.SchemaConstants;
+import org.apache.axis2.schema.*;
import org.apache.axis2.schema.i18n.SchemaCompilerMessages;
import org.apache.axis2.schema.typemap.JavaTypeMap;
import org.apache.axis2.schema.util.PrimitiveTypeFinder;
import org.apache.axis2.schema.util.SchemaPropertyLoader;
-import org.apache.axis2.util.JavaUtils;
-import org.apache.axis2.util.PrettyPrinter;
-import org.apache.axis2.util.URLProcessor;
-import org.apache.axis2.util.XSLTTemplateProcessor;
-import org.apache.axis2.util.XSLTUtils;
+import org.apache.axis2.util.*;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.ws.commons.schema.XmlSchemaComplexType;
import org.apache.ws.commons.schema.XmlSchemaElement;
import org.apache.ws.commons.schema.XmlSchemaSimpleType;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
+import javax.xml.namespace.QName;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.Templates;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamSource;
+import java.io.*;
+import java.util.*;
+
/*
* Copyright 2004,2005 The Apache Software Foundation.
*
@@ -111,10 +95,10 @@
* This returns a map of Qnames vs DOMDocument models. One can use this
* method to obtain the raw DOMmodels used to write the classes. This has no
* meaning when the classes are supposed to be wrapped so the
- *
- * @see org.apache.axis2.schema.writer.BeanWriter#getModelMap()
+ *
* @return Returns Map.
* @throws SchemaCompilationException
+ * @see BeanWriter#getModelMap()
*/
public Map getModelMap() {
return modelMap;
@@ -159,7 +143,7 @@
//set helper mode
this.isHelperMode = options.isHelperMode();
//set mapper class package if present
- if (options.isMapperClassPackagePresent()){
+ if (options.isMapperClassPackagePresent()) {
this.mappingClassPackage = options.getMapperClassPackage();
}
@@ -196,11 +180,10 @@
* @param complexType
* @param typeMap
* @param metainf
- * @param fullyQualifiedClassName
- * the name returned by makeFullyQualifiedClassName() or null if
- * it wasn't called
+ * @param fullyQualifiedClassName the name returned by makeFullyQualifiedClassName() or null if
+ * it wasn't called
* @throws org.apache.axis2.schema.SchemaCompilationException
- *
+ *
* @see BeanWriter#write(org.apache.ws.commons.schema.XmlSchemaComplexType,
* java.util.Map, org.apache.axis2.schema.BeanWriterMetaInfoHolder)
*/
@@ -258,7 +241,7 @@
BeanWriterMetaInfoHolder metainf) throws SchemaCompilationException {
try {
QName qName = simpleType.getQName();
- if(qName == null) {
+ if (qName == null) {
qName = (QName) simpleType.getMetaInfoMap().get(SchemaConstants.SchemaCompilerInfoHolder.FAKE_QNAME);
}
metainf.addtStatus(qName, SchemaConstants.SIMPLE_TYPE);
@@ -289,9 +272,8 @@
/**
* Make the fully qualified class name for an element or named type
- *
- * @param qName
- * the qualified Name for this element or type in the schema
+ *
+ * @param qName the qualified Name for this element or type in the schema
* @return the appropriate fully qualified class name to use in generated
* code
*/
@@ -339,14 +321,13 @@
/**
* A util method that holds common code for the complete schema that the
* generated XML complies to look under other/beanGenerationSchema.xsd
- *
+ *
* @param qName
* @param metainf
* @param typeMap
* @param isElement
- * @param fullyQualifiedClassName
- * the name returned by makeFullyQualifiedClassName() or null if
- * it wasn't called
+ * @param fullyQualifiedClassName the name returned by makeFullyQualifiedClassName() or null if
+ * it wasn't called
* @return Returns String.
* @throws Exception
*/
@@ -509,7 +490,6 @@
}
/**
- *
* @param metainf
* @param model
* @param rootElt
@@ -530,7 +510,6 @@
}
/**
- *
* @param metainf
* @param model
* @param rootElt
@@ -542,57 +521,56 @@
Document model, Element rootElt, ArrayList propertyNames,
Map typeMap, boolean isInherited) throws SchemaCompilationException {
// go in the loop and add the part elements
- QName[] qName;
- String javaClassNameForElement;
+ QName[] qName;
+ String javaClassNameForElement;
ArrayList missingQNames = new ArrayList();
ArrayList qNames = new ArrayList();
-
+
BeanWriterMetaInfoHolder parentMetaInf = metainf.getParent();
-
+
if (metainf.isOrdered()) {
qName = metainf.getOrderedQNameArray();
} else {
- qName= metainf.getQNameArray();
+ qName = metainf.getQNameArray();
}
-
+
for (int i = 0; i < qName.length; i++) {
- qNames.add(qName[i]);
+ qNames.add(qName[i]);
}
//adding missing QNames to the end, including elements & attributes.
if (metainf.isRestriction()) {
- addMissingQNames(metainf, qNames, missingQNames);
+ addMissingQNames(metainf, qNames, missingQNames);
}
QName name;
for (int i = 0; i < qNames.size(); i++) {
- name = (QName) qNames.get(i);
- Element property = XSLTUtils.addChildElement(model, "property",rootElt);
-
+ name = (QName) qNames.get(i);
+ Element property = XSLTUtils.addChildElement(model, "property", rootElt);
+
String xmlName = name.getLocalPart();
XSLTUtils.addAttribute(model, "name", xmlName, property);
- XSLTUtils.addAttribute(model, "nsuri", name.getNamespaceURI(),property);
+ XSLTUtils.addAttribute(model, "nsuri", name.getNamespaceURI(), property);
String javaName = makeUniqueJavaClassName(propertyNames, xmlName);
XSLTUtils.addAttribute(model, "javaname", javaName, property);
if (parentMetaInf != null && metainf.isRestriction() && missingQNames.contains(name)) {
- javaClassNameForElement = parentMetaInf.getClassNameForQName(name);
- }
- else {
- javaClassNameForElement = metainf.getClassNameForQName(name);
+ javaClassNameForElement = parentMetaInf.getClassNameForQName(name);
+ } else {
+ javaClassNameForElement = metainf.getClassNameForQName(name);
}
-
+
if (javaClassNameForElement == null) {
javaClassNameForElement = SchemaCompiler.DEFAULT_CLASS_NAME;
log.warn(SchemaCompilerMessages
.getMessage("schema.typeMissing", name.toString()));
}
-
+
if (metainf.isRestriction() && typeChanged(name, missingQNames, metainf)) {
- XSLTUtils.addAttribute(model, "typeChanged", "yes", property);
- //XSLTUtils.addAttribute(model, "restricted", "yes", property);
+ XSLTUtils.addAttribute(model, "typeChanged", "yes", property);
+ //XSLTUtils.addAttribute(model, "restricted", "yes", property);
}
-
- XSLTUtils.addAttribute(model, "type", javaClassNameForElement,property);
+
+ XSLTUtils.addAttribute(model, "type", javaClassNameForElement, property);
if (PrimitiveTypeFinder.isPrimitive(javaClassNameForElement)) {
XSLTUtils.addAttribute(model, "primitive", "yes", property);
@@ -615,7 +593,7 @@
}
if (metainf.getOptionalAttributeStatusForQName(name)) {
- XSLTUtils.addAttribute(model, "optional", "yes", property);
+ XSLTUtils.addAttribute(model, "optional", "yes", property);
}
String shortTypeName;
@@ -629,13 +607,13 @@
} else {
shortTypeName = getShortTypeName(javaClassNameForElement);
}
- XSLTUtils.addAttribute(model, "shorttypename", shortTypeName,property);
+ XSLTUtils.addAttribute(model, "shorttypename", shortTypeName, property);
if (metainf.isRestriction() && missingQNames.contains(name)) {
- //XSLTUtils.addAttribute(model, "restricted", "yes", property);
- XSLTUtils.addAttribute(model, "removed", "yes", property);
+ //XSLTUtils.addAttribute(model, "restricted", "yes", property);
+ XSLTUtils.addAttribute(model, "removed", "yes", property);
}
-
+
if (isInherited) {
XSLTUtils.addAttribute(model, "inherited", "yes", property);
}
@@ -656,115 +634,122 @@
// not
long minOccurs = metainf.getMinOccurs(name);
XSLTUtils.addAttribute(model, "minOccurs", minOccurs + "", property);
-
+
//in the case the original element is an array but the derived one is not.
if (parentMetaInf != null && metainf.isRestriction() && !missingQNames.contains(name) &&
- (parentMetaInf.getArrayStatusForQName(name) && !metainf.getArrayStatusForQName(name))) {
-
- XSLTUtils.addAttribute(model, "rewrite", "yes", property);
- XSLTUtils.addAttribute(model, "occuranceChanged", "yes", property);
- }
- else if (metainf.isRestriction() && !missingQNames.contains(name) &&
- (minOccursChanged(name, missingQNames, metainf) || maxOccursChanged(name, missingQNames, metainf))) {
-
- XSLTUtils.addAttribute(model, "restricted", "yes", property);
- XSLTUtils.addAttribute(model, "occuranceChanged", "yes", property);
+ (parentMetaInf.getArrayStatusForQName(name) && !metainf.getArrayStatusForQName(name))) {
+
+ XSLTUtils.addAttribute(model, "rewrite", "yes", property);
+ XSLTUtils.addAttribute(model, "occuranceChanged", "yes", property);
+ } else if (metainf.isRestriction() && !missingQNames.contains(name) &&
+ (minOccursChanged(name, missingQNames, metainf) || maxOccursChanged(name, missingQNames, metainf))) {
+
+ XSLTUtils.addAttribute(model, "restricted", "yes", property);
+ XSLTUtils.addAttribute(model, "occuranceChanged", "yes", property);
}
if (metainf.getArrayStatusForQName(name)) {
XSLTUtils.addAttribute(model, "array", "yes", property);
- XSLTUtils.addAttribute(model, "arrayBaseType",javaClassNameForElement.substring(0,javaClassNameForElement.indexOf("[")),property);
+
+ int endIndex = javaClassNameForElement.indexOf("[");
+ if (endIndex >= 0) {
+ XSLTUtils.addAttribute(model, "arrayBaseType",
+ javaClassNameForElement.substring(0, endIndex), property);
+ } else {
+ XSLTUtils.addAttribute(model, "arrayBaseType",
+ javaClassNameForElement, property);
+ }
long maxOccurs = metainf.getMaxOccurs(name);
if (maxOccurs == Long.MAX_VALUE) {
XSLTUtils.addAttribute(model, "unbound", "yes", property);
} else {
- XSLTUtils.addAttribute(model, "maxOccurs", maxOccurs + "",property);
+ XSLTUtils.addAttribute(model, "maxOccurs", maxOccurs + "", property);
}
}
if (metainf.isRestrictionBaseType(name)) {
- XSLTUtils.addAttribute(model, "restrictionBaseType", "yes", property);
+ XSLTUtils.addAttribute(model, "restrictionBaseType", "yes", property);
}
-
+
if (metainf.isExtensionBaseType(name)) {
- XSLTUtils.addAttribute(model, "extensionBaseType", "yes", property);
+ XSLTUtils.addAttribute(model, "extensionBaseType", "yes", property);
}
-
+
if (metainf.isRestrictionBaseType(name) && metainf.getLengthFacet() != -1) {
- XSLTUtils.addAttribute(model, "lenFacet", metainf.getLengthFacet() + "", property);
+ XSLTUtils.addAttribute(model, "lenFacet", metainf.getLengthFacet() + "", property);
}
-
+
if (metainf.isRestrictionBaseType(name) && metainf.getMaxLengthFacet() != -1) {
- XSLTUtils.addAttribute(model, "maxLenFacet", metainf.getMaxLengthFacet() + "", property);
+ XSLTUtils.addAttribute(model, "maxLenFacet", metainf.getMaxLengthFacet() + "", property);
}
-
+
if (metainf.isRestrictionBaseType(name) && metainf.getMinLengthFacet() != -1) {
- XSLTUtils.addAttribute(model, "minLenFacet", metainf.getMinLengthFacet() + "", property);
+ XSLTUtils.addAttribute(model, "minLenFacet", metainf.getMinLengthFacet() + "", property);
}
-
+
if (metainf.isRestrictionBaseType(name) && metainf.getMaxExclusiveFacet() != null) {
- XSLTUtils.addAttribute(model, "maxExFacet", metainf.getMaxExclusiveFacet() + "", property);
+ XSLTUtils.addAttribute(model, "maxExFacet", metainf.getMaxExclusiveFacet() + "", property);
}
-
+
if (metainf.isRestrictionBaseType(name) && metainf.getMinExclusiveFacet() != null) {
- XSLTUtils.addAttribute(model, "minExFacet", metainf.getMinExclusiveFacet() + "", property);
+ XSLTUtils.addAttribute(model, "minExFacet", metainf.getMinExclusiveFacet() + "", property);
}
-
+
if (metainf.isRestrictionBaseType(name) && metainf.getMaxInclusiveFacet() != null) {
- XSLTUtils.addAttribute(model, "maxInFacet", metainf.getMaxInclusiveFacet() + "", property);
+ XSLTUtils.addAttribute(model, "maxInFacet", metainf.getMaxInclusiveFacet() + "", property);
}
-
+
if (metainf.isRestrictionBaseType(name) && metainf.getMinInclusiveFacet() != null) {
- XSLTUtils.addAttribute(model, "minInFacet", metainf.getMinInclusiveFacet() + "", property);
+ XSLTUtils.addAttribute(model, "minInFacet", metainf.getMinInclusiveFacet() + "", property);
}
-
+
if (!metainf.getEnumFacet().isEmpty()) {
boolean validJava = true; // Assume all enum values are valid ids
Iterator iterator = metainf.getEnumFacet().iterator();
// Walk the values looking for invalid ids
- while(iterator.hasNext()) {
+ while (iterator.hasNext()) {
String value = (String) iterator.next();
if (!JavaUtils.isJavaId(value)) {
validJava = false;
}
}
-
+
int id = 0;
iterator = metainf.getEnumFacet().iterator();
- while(iterator.hasNext()) {
+ while (iterator.hasNext()) {
Element enumFacet = XSLTUtils.addChildElement(model, "enumFacet", property);
String attribValue = (String) iterator.next();
XSLTUtils.addAttribute(model, "value", attribValue, enumFacet);
- if(validJava) {
- XSLTUtils.addAttribute(model, "id", attribValue , enumFacet);
+ if (validJava) {
+ XSLTUtils.addAttribute(model, "id", attribValue, enumFacet);
} else {
id++;
XSLTUtils.addAttribute(model, "id", "value" + id, enumFacet);
}
}
}
-
+
if (metainf.isRestrictionBaseType(name) && metainf.getPatternFacet() != null) {
- XSLTUtils.addAttribute(model, "patternFacet", metainf.getPatternFacet(), property);
+ XSLTUtils.addAttribute(model, "patternFacet", metainf.getPatternFacet(), property);
}
}
}
private void addMissingQNames(BeanWriterMetaInfoHolder metainf, ArrayList qName, ArrayList missingQNames) {
-
- QName[] qNames = null;
+
+ QName[] qNames = null;
QName[] pQNames = null;
-
+
BeanWriterMetaInfoHolder parentMetaInf = metainf.getParent();
-
+
if (metainf.isOrdered()) {
qNames = metainf.getOrderedQNameArray();
} else {
qNames = metainf.getQNameArray();
}
-
+
if (parentMetaInf != null) {
if (parentMetaInf.isOrdered()) {
pQNames = parentMetaInf.getOrderedQNameArray();
@@ -772,146 +757,142 @@
pQNames = parentMetaInf.getQNameArray();
}
}
-
-
- for (int i=0; pQNames != null && i < pQNames.length; i++) {
- if (qNameNotFound(pQNames[i], metainf)) {
- missingQNames.add(pQNames[i]);
- }
- }
- //adding missing QNames to the end of list.
+
+
+ for (int i = 0; pQNames != null && i < pQNames.length; i++) {
+ if (qNameNotFound(pQNames[i], metainf)) {
+ missingQNames.add(pQNames[i]);
+ }
+ }
+ //adding missing QNames to the end of list.
if (!missingQNames.isEmpty()) {
- for (int i=0; i < missingQNames.size(); i++) {
- qName.add(missingQNames.get(i));
- }
- }
-
+ for (int i = 0; i < missingQNames.size(); i++) {
+ qName.add(missingQNames.get(i));
+ }
+ }
+
}
-
+
private boolean qNameNotFound(QName qname, BeanWriterMetaInfoHolder metainf) {
-
- boolean found = false;
- QName[] qNames;
-
- if (metainf.isOrdered()) {
- qNames = metainf.getOrderedQNameArray();
+
+ boolean found = false;
+ QName[] qNames;
+
+ if (metainf.isOrdered()) {
+ qNames = metainf.getOrderedQNameArray();
} else {
- qNames = metainf.getQNameArray();
+ qNames = metainf.getQNameArray();
}
-
+
for (int j = 0; j < qNames.length; j++) {
- if (qname.getLocalPart().equals(qNames[j].getLocalPart())) {
- found = true;
- }
+ if (qname.getLocalPart().equals(qNames[j].getLocalPart())) {
+ found = true;
+ }
}
return !found;
}
-
+
private boolean typeChanged(QName qname, ArrayList missingQNames, BeanWriterMetaInfoHolder metainf) {
-
- boolean typeChanged = false;
- QName[] pQNames;
-
- BeanWriterMetaInfoHolder parentMetainf = metainf.getParent();
-
- if (parentMetainf != null && !missingQNames.contains(qname)) {
-
- if (parentMetainf.isOrdered()) {
- pQNames = parentMetainf.getOrderedQNameArray();
- } else {
- pQNames = parentMetainf.getQNameArray();
- }
-
- for (int j = 0; j < pQNames.length; j++) {
- if (qname.getLocalPart().equals(pQNames[j].getLocalPart())) {
-
- String javaClassForParentElement = parentMetainf.getClassNameForQName(pQNames[j]);
- String javaClassForElement = metainf.getClassNameForQName(qname);
-
- if (!javaClassForParentElement.equals(javaClassForElement)) {
- if (javaClassForParentElement.endsWith("[]")) {
- if ((javaClassForParentElement.substring(0,javaClassForParentElement.indexOf('['))).equals(javaClassForElement)) {
- continue;
- }
- }
- else if (javaClassForElement.endsWith("[]")) {
- if ((javaClassForElement.substring(0,javaClassForElement.indexOf('['))).equals(javaClassForParentElement)) {
- continue;
- }
- }
- else {
- typeChanged = true;
- }
- }
- }
- }
- }
+
+ boolean typeChanged = false;
+ QName[] pQNames;
+
+ BeanWriterMetaInfoHolder parentMetainf = metainf.getParent();
+
+ if (parentMetainf != null && !missingQNames.contains(qname)) {
+
+ if (parentMetainf.isOrdered()) {
+ pQNames = parentMetainf.getOrderedQNameArray();
+ } else {
+ pQNames = parentMetainf.getQNameArray();
+ }
+
+ for (int j = 0; j < pQNames.length; j++) {
+ if (qname.getLocalPart().equals(pQNames[j].getLocalPart())) {
+
+ String javaClassForParentElement = parentMetainf.getClassNameForQName(pQNames[j]);
+ String javaClassForElement = metainf.getClassNameForQName(qname);
+
+ if (!javaClassForParentElement.equals(javaClassForElement)) {
+ if (javaClassForParentElement.endsWith("[]")) {
+ if ((javaClassForParentElement.substring(0, javaClassForParentElement.indexOf('['))).equals(javaClassForElement)) {
+ continue;
+ }
+ } else if (javaClassForElement.endsWith("[]")) {
+ if ((javaClassForElement.substring(0, javaClassForElement.indexOf('['))).equals(javaClassForParentElement)) {
+ continue;
+ }
+ } else {
+ typeChanged = true;
+ }
+ }
+ }
+ }
+ }
return typeChanged;
}
-
+
private boolean minOccursChanged(QName qname, ArrayList missingQNames, BeanWriterMetaInfoHolder metainf) throws SchemaCompilationException {
-
- boolean minChanged = false;
- QName[] pQNames;
-
- BeanWriterMetaInfoHolder parentMetainf = metainf.getParent();
-
- if (parentMetainf != null && !missingQNames.contains(qname)) {
-
- if (parentMetainf.isOrdered()) {
- pQNames = parentMetainf.getOrderedQNameArray();
- } else {
- pQNames = parentMetainf.getQNameArray();
- }
-
- for (int j = 0; j < pQNames.length; j++) {
- if (qname.getLocalPart().equals(pQNames[j].getLocalPart())) {
-
- if (metainf.getMinOccurs(qname) > parentMetainf.getMinOccurs(pQNames[j])) {
- minChanged = true;
- }
- else if(metainf.getMinOccurs(qname) < parentMetainf.getMinOccurs(pQNames[j])) {
- throw new SchemaCompilationException(SchemaCompilerMessages.getMessage("minOccurs Wrong!"));
- }
-
- }
- }
- }
+
+ boolean minChanged = false;
+ QName[] pQNames;
+
+ BeanWriterMetaInfoHolder parentMetainf = metainf.getParent();
+
+ if (parentMetainf != null && !missingQNames.contains(qname)) {
+
+ if (parentMetainf.isOrdered()) {
+ pQNames = parentMetainf.getOrderedQNameArray();
+ } else {
+ pQNames = parentMetainf.getQNameArray();
+ }
+
+ for (int j = 0; j < pQNames.length; j++) {
+ if (qname.getLocalPart().equals(pQNames[j].getLocalPart())) {
+
+ if (metainf.getMinOccurs(qname) > parentMetainf.getMinOccurs(pQNames[j])) {
+ minChanged = true;
+ } else if (metainf.getMinOccurs(qname) < parentMetainf.getMinOccurs(pQNames[j])) {
+ throw new SchemaCompilationException(SchemaCompilerMessages.getMessage("minOccurs Wrong!"));
+ }
+
+ }
+ }
+ }
return minChanged;
}
-
+
private boolean maxOccursChanged(QName qname, ArrayList missingQNames, BeanWriterMetaInfoHolder metainf) throws SchemaCompilationException {
-
- boolean maxChanged = false;
- QName[] pQNames;
-
- BeanWriterMetaInfoHolder parentMetainf = metainf.getParent();
-
- if (parentMetainf != null && !missingQNames.contains(qname)) {
- if (parentMetainf.isOrdered()) {
- pQNames = parentMetainf.getOrderedQNameArray();
- } else {
- pQNames = parentMetainf.getQNameArray();
- }
-
- for (int j = 0; j < pQNames.length; j++) {
- if (qname.getLocalPart().equals(pQNames[j].getLocalPart())) {
-
- if (metainf.getMaxOccurs(qname) < parentMetainf.getMaxOccurs(pQNames[j])) {
- maxChanged = true;
- }
- else if(metainf.getMaxOccurs(qname) > parentMetainf.getMaxOccurs(pQNames[j])) {
- throw new SchemaCompilationException(SchemaCompilerMessages.getMessage("maxOccurs Wrong!"));
- }
- }
- }
- }
+
+ boolean maxChanged = false;
+ QName[] pQNames;
+
+ BeanWriterMetaInfoHolder parentMetainf = metainf.getParent();
+
+ if (parentMetainf != null && !missingQNames.contains(qname)) {
+ if (parentMetainf.isOrdered()) {
+ pQNames = parentMetainf.getOrderedQNameArray();
+ } else {
+ pQNames = parentMetainf.getQNameArray();
+ }
+
+ for (int j = 0; j < pQNames.length; j++) {
+ if (qname.getLocalPart().equals(pQNames[j].getLocalPart())) {
+
+ if (metainf.getMaxOccurs(qname) < parentMetainf.getMaxOccurs(pQNames[j])) {
+ maxChanged = true;
+ } else if (metainf.getMaxOccurs(qname) > parentMetainf.getMaxOccurs(pQNames[j])) {
+ throw new SchemaCompilationException(SchemaCompilerMessages.getMessage("maxOccurs Wrong!"));
+ }
+ }
+ }
+ }
return maxChanged;
}
-
+
/**
* Test whether the given class name matches the default
- *
+ *
* @param javaClassNameForElement
* @return
*/
@@ -926,7 +907,7 @@
* Given the xml name, make a unique class name taking into account that
* some file systems are case sensitive and some are not. -Consider the
* Jax-WS spec for this
- *
+ *
* @param listOfNames
* @param xmlName
* @return Returns String.
@@ -978,7 +959,7 @@
/**
* Creates the output file
- *
+ *
* @param packageName
* @param fileName
* @throws Exception
@@ -991,7 +972,7 @@
/**
* Writes the output file
- *
+ *
* @param doc
* @param outputFile
* @throws Exception
@@ -1011,9 +992,8 @@
* prefix - if the given URI is already mapped in this serialization, we
* return the previous prefix. If it is not mapped, we will add a new
* mapping and return a generated prefix of the form "ns<num>".
- *
- * @param uri
- * is the namespace uri
+ *
+ * @param uri is the namespace uri
* @return Returns prefix.
*/
public String getPrefixForURI(String uri) {
@@ -1071,19 +1051,21 @@
/**
* Get the mapper class name - there is going to be only one
* mapper class for the whole
+ *
* @return
*/
- private String getFullyQualifiedMapperClassName(){
- if (wrapClasses || !writeClasses){
+ private String getFullyQualifiedMapperClassName() {
+ if (wrapClasses || !writeClasses) {
return EXTENSION_MAPPER_CLASSNAME;
- }else{
- return mappingClassPackage + "." + EXTENSION_MAPPER_CLASSNAME;
+ } else {
+ return mappingClassPackage + "." + EXTENSION_MAPPER_CLASSNAME;
}
}
/**
* get the mapper class package name
* May be ignored by the implementer
+ *
* @return
*/
public String getExtensionMapperPackageName() {
@@ -1093,6 +1075,7 @@
/**
* Sets the mapping class name of this writer. A mapping class
* package set by the options may be overridden at the this point
+ *
* @param mapperPackageName
*/
public void registerExtensionMapperPackageName(String mapperPackageName) {
@@ -1102,26 +1085,27 @@
/**
* Write the extension classes - this is needed to process
* the hierarchy of classes
+ *
* @param metainfArray
* @return
*/
- public void writeExtensionMapper(BeanWriterMetaInfoHolder[] metainfArray) throws SchemaCompilationException{
+ public void writeExtensionMapper(BeanWriterMetaInfoHolder[] metainfArray) throws SchemaCompilationException {
//generate the element
try {
String mapperClassName = getFullyQualifiedMapperClassName();
- Document model =XSLTUtils.getDocument();
+ Document model = XSLTUtils.getDocument();
Element rootElt = XSLTUtils.getElement(model, "mapper");
String mapperName = mapperClassName.substring(mapperClassName.lastIndexOf(".") + 1);
- XSLTUtils.addAttribute(model, "name",mapperName, rootElt);
+ XSLTUtils.addAttribute(model, "name", mapperName, rootElt);
String basePackageName = "";
- if (mapperClassName.indexOf(".")!=-1){
+ if (mapperClassName.indexOf(".") != -1) {
basePackageName = mapperClassName.substring(0, mapperClassName.lastIndexOf("."));
- XSLTUtils.addAttribute(model, "package",basePackageName, rootElt);
- }else {
- XSLTUtils.addAttribute(model, "package","", rootElt);
+ XSLTUtils.addAttribute(model, "package", basePackageName, rootElt);
+ } else {
+ XSLTUtils.addAttribute(model, "package", "", rootElt);
}
if (!wrapClasses) {
@@ -1132,26 +1116,26 @@
XSLTUtils.addAttribute(model, "skip-write", "yes", rootElt);
}
- if (isHelperMode){
- XSLTUtils.addAttribute(model, "helpermode", "yes", rootElt);
+ if (isHelperMode) {
+ XSLTUtils.addAttribute(model, "helpermode", "yes", rootElt);
}
for (int i = 0; i < metainfArray.length; i++) {
QName ownQname = metainfArray[i].getOwnQname();
String className = metainfArray[i].getOwnClassName();
//do not add when the qname is not availble
- if (ownQname!=null){
- Element typeChild = XSLTUtils.addChildElement(model,"type",rootElt);
+ if (ownQname != null) {
+ Element typeChild = XSLTUtils.addChildElement(model, "type", rootElt);
XSLTUtils.addAttribute(model, "nsuri", ownQname.getNamespaceURI(), typeChild);
- XSLTUtils.addAttribute(model, "classname", className==null?"":className, typeChild);
- XSLTUtils.addAttribute(model, "shortname", ownQname==null?"":
+ XSLTUtils.addAttribute(model, "classname", className == null ? "" : className, typeChild);
+ XSLTUtils.addAttribute(model, "shortname", ownQname == null ? "" :
ownQname.getLocalPart(), typeChild);
}
}
model.appendChild(rootElt);
- if (!templateLoaded){
+ if (!templateLoaded) {
loadTemplate();
}
@@ -1172,16 +1156,15 @@
}
} catch (ParserConfigurationException e) {
- throw new SchemaCompilationException(SchemaCompilerMessages.getMessage("schema.docuement.error"),e);
- } catch (Exception e){
+ throw new SchemaCompilationException(SchemaCompilerMessages.getMessage("schema.docuement.error"), e);
+ } catch (Exception e) {
e.printStackTrace();
throw new SchemaCompilationException(e);
}
-
}
-
+
}
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisOperation.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisOperation.java?view=diff&rev=448529&r1=448528&r2=448529
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisOperation.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisOperation.java Thu Sep 21 05:22:32 2006
@@ -278,8 +278,6 @@
return operation;
}
-
-
/**
* Returns as existing OperationContext related to this message if one exists.
@@ -306,10 +304,10 @@
configContext.getOperationContext(msgContext.getRelatesTo().getValue());
if (null == operationContext && log.isDebugEnabled()) {
- log.debug("Cannot correlate inbound message RelatesTo value ["+msgContext.getRelatesTo()+"] to in-progree MEP");
- }
+ log.debug("Cannot correlate inbound message RelatesTo value [" + msgContext.getRelatesTo() + "] to in-progree MEP");
+ }
}
-
+
return operationContext;
}
@@ -522,7 +520,9 @@
public abstract void setRemainingPhasesInFlow(ArrayList list);
public void setStyle(String style) {
- this.style = style;
+ if (!"".equals(style)) {
+ this.style = style;
+ }
}
public void setWsamappingList(ArrayList wsamappingList) {
@@ -556,16 +556,16 @@
this.soapAction = soapAction;
}
- public String getInputAction(){
+ public String getInputAction() {
String result = getSoapAction();
- if(result==null || "".equals(result)){
- if(wsamappingList!=null && !wsamappingList.isEmpty()){
+ if (result == null || "".equals(result)) {
+ if (wsamappingList != null && !wsamappingList.isEmpty()) {
result = wsamappingList.get(0).toString();
}
}
return result;
}
-
+
public String getOutputAction() {
return outputAction;
}
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java?view=diff&rev=448529&r1=448528&r2=448529
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java Thu Sep 21 05:22:32 2006
@@ -102,7 +102,7 @@
private static int prefixCounter = 0;
public static final String NAMESPACE_URI = "namespace";
public static final String TRAGET_NAMESPACE = "targetNamespace";
-
+
/**
* keep track of whether setup code related to the entire wsdl is complete.
* Note that WSDL11ToAllAxisServices will call setup multiple times, so this
@@ -235,16 +235,17 @@
throw new AxisFault(e);
}
}
-
+
/**
* contains all code which gathers non-service specific information from the wsdl.
- * <p>
+ * <p/>
* After all the setup completes successfully, the setupComplete field is set so that
* any subsequent calls to setup() will result in a no-op.
* Note that subclass WSDL11ToAllAxisServicesBuilder will call populateService for
* each port in the WSDL. Separating the non-service specific information here allows
* WSDL11ToAllAxisServicesBuilder to only do this work 1 time per WSDL, instead of for
* each port on each service.
+ *
* @throws WSDLException if readInTheWSDLFile fails
*/
protected void setup() throws WSDLException {
@@ -269,9 +270,8 @@
setupComplete = true; // if any part of setup fails, don't mark setupComplete
return;
}
-
-
+
/**
* Populate a map of targetNamespace vs DOM schema element
* This is used to grab the correct schema element when adding
@@ -282,7 +282,7 @@
private Map populateSchemaMap(Types wsdl4jTypes) {
Map schemaMap = new HashMap();
- if (wsdl4jTypes!=null){
+ if (wsdl4jTypes != null) {
List typesExtensibilityElements = wsdl4jTypes.getExtensibilityElements();
for (int i = 0; i < typesExtensibilityElements.size(); i++) {
Object o = typesExtensibilityElements.get(i);
@@ -318,7 +318,7 @@
if (services.size() > 0) {
//pick the first service - we don't really have a choice here
service = (Service) services.values().toArray()[0];
- }
+ }
}
if (service != null) {
copyExtensibleElements(service.getExtensibilityElements(), dif,
@@ -343,9 +343,9 @@
}
}
}
-
+
axisService.setName(service.getQName().getLocalPart());
-
+
if (port != null) {
copyExtensibleElements(port.getExtensibilityElements(), dif,
axisService, PORT);
@@ -579,9 +579,26 @@
break;
} else if (extElement instanceof UnknownExtensibilityElement) {
- //in the case of unknown extensibilty elements we'll have to look at the
- //SOAP 1.2 namespace
+ if (WSDLConstants.WSDL11Constants.SOAP_12_BODY.equals(extElement
+ .getElementType())) {
+ if (isWrapped) {
+ //The schema for this should be already made ! Find the QName from
+ //the list and add it - the name for this is just the
+ inMessage.setElementQName((QName) resolvedRpcWrappedElementMap.get(wsdl4jOperation.getName()));
+ } else {
+ //pick the first part from the list and take that as the relevant part
+ //it is somewhat questionnable whether the first part gets picked
+ //but we'll have to take a chance here
+ Map wsdl4jPartsMap = wsdl4jMessage.getParts();
+ if (!wsdl4jPartsMap.isEmpty()) {
+ Part wsdl4jPart = (Part) wsdl4jPartsMap.values().toArray()[0];
+ if (wsdl4jPart.getElementName() != null) {
+ inMessage.setElementQName(wsdl4jPart.getElementName());
+ }
+ }
+ }
+ }
//todo - add the code here to process the SOAP 1.2 body
break;
}
@@ -608,10 +625,10 @@
}
QName name = wsdl4jMessagePart.getElementName();
if (name == null) {
- name = wsdl4jMessagePart.getTypeName();
+ name = wsdl4jMessagePart.getTypeName();
}
if (name == null) {
- throw new WSDLProcessingException("Element reference / Type name missing for " + bindingPartsList.get(0) + "!" );
+ throw new WSDLProcessingException("Element reference / Type name missing for " + bindingPartsList.get(0) + "!");
}
inMessage.setElementQName(wsdl4jMessagePart.getElementName());
@@ -674,9 +691,26 @@
break;
} else if (extElement instanceof UnknownExtensibilityElement) {
- //in the case of unknown extensibilty elements we'll have to look at the
- //SOAP 1.2 namespace
+ if (WSDLConstants.WSDL11Constants.SOAP_12_BODY.equals(extElement
+ .getElementType())) {
+ if (isWrapped) {
+ //The schema for this should be already made ! Find the QName from
+ //the list and add it - the name for this is just the
+ outMessage.setElementQName((QName) resolvedRpcWrappedElementMap.get(wsdl4jOperation.getName()));
+ } else {
+ //pick the first part from the list and take that as the relevant part
+ //it is somewhat questionnable whether the first part gets picked
+ //but we'll have to take a chance here
+ Map wsdl4jPartsMap = wsdl4jMessage.getParts();
+ if (!wsdl4jPartsMap.isEmpty()) {
+ Part wsdl4jPart = (Part) wsdl4jPartsMap.values().toArray()[0];
+ if (wsdl4jPart.getElementName() != null) {
+ outMessage.setElementQName(wsdl4jPart.getElementName());
+ }
+ }
+ }
+ }
//todo - add the code here to process the SOAP 1.2 body
break;
}
@@ -767,8 +801,8 @@
String MEP = getMEP(wsdl4jOperation);
axisOperation = AxisOperationFactory.getOperationDescription(MEP);
axisOperation.setName(opName);
-
- // setting the PolicyInclude property of the AxisOperation
+
+ // setting the PolicyInclude property of the AxisOperation
PolicyInclude policyInclude = new PolicyInclude(axisOperation);
axisOperation.setPolicyInclude(policyInclude);
}
@@ -1264,8 +1298,8 @@
schemaElement.setAttributeNS(XML_NAMESPACE_URI,
NAMESPACE_DECLARATION_PREFIX + namespacePrefixMap.get(s).toString(), s);
}
-
- if(schemaElement.getAttributeNS(XML_NAMESPACE_URI, xsdPrefix).length()==0){
+
+ if (schemaElement.getAttributeNS(XML_NAMESPACE_URI, xsdPrefix).length() == 0) {
schemaElement.setAttributeNS(XML_NAMESPACE_URI,
NAMESPACE_DECLARATION_PREFIX + xsdPrefix, XMLSCHEMA_NAMESPACE_URI);
}
@@ -1374,7 +1408,7 @@
wsdl4jDefinition.getNamespaces().putAll(namespaces);
//copy types
Types t = importedDef.getTypes();
- if(t != null){
+ if (t != null) {
List typesList = t.getExtensibilityElements();
for (int j = 0; j < typesList.size(); j++) {
Types types = wsdl4JDefinition.getTypes();
@@ -1385,7 +1419,7 @@
types
.addExtensibilityElement((ExtensibilityElement) typesList
.get(j));
-
+
}
}
@@ -1506,17 +1540,17 @@
"location"));
} else if (WSDLConstants.WSDL11Constants.POLICY
.equals(unknown.getElementType())) {
-
+
Policy policy = (Policy) PolicyUtil.getPolicyComponent(unknown.getElement());
addPolicy(description, originOfExtensibilityElements,
policy);
} else if (WSDLConstants.WSDL11Constants.POLICY_REFERENCE.equals(unknown
.getElementType())) {
-
+
PolicyReference policyReference = (PolicyReference) PolicyUtil.getPolicyComponent(unknown.getElement());
addPolicyRef(description, originOfExtensibilityElements, policyReference);
-
+
} else if (AddressingConstants.Final.WSAW_USING_ADDRESSING
.equals(unknown.getElementType())
|| AddressingConstants.Submission.WSAW_USING_ADDRESSING
@@ -1538,8 +1572,8 @@
} else if (AddressingConstants.Final.WSAW_ANONYMOUS.equals(unknown.getElementType())) {
if (originOfExtensibilityElements.equals(BINDING_OPERATION)) {
AxisOperation axisOperation = (AxisOperation) description;
- if(unknown.getElement().getFirstChild()!=null &&
- unknown.getElement().getFirstChild().getNodeType() == Node.TEXT_NODE){
+ if (unknown.getElement().getFirstChild() != null &&
+ unknown.getElement().getFirstChild().getNodeType() == Node.TEXT_NODE) {
String anonymousValue = unknown.getElement().getFirstChild().getNodeValue();
AddressingHelper.setAnonymousParameterValue(axisOperation, anonymousValue);
}
@@ -1886,11 +1920,11 @@
for (Iterator iterator = extAttributes.keySet().iterator(); iterator
.hasNext();) {
key = (QName) iterator.next();
-
+
if (Constants.URI_POLICY_NS.equals(key
.getNamespaceURI())
&& "PolicyURIs".equals(key.getLocalPart())) {
-
+
value = (QName) extAttributes.get(key);
String policyURIs = value.getLocalPart();
@@ -1901,7 +1935,7 @@
for (int i = 0; i < uris.length; i++) {
ref = new PolicyReference();
ref.setURI(uris[i]);
-
+
if (PORT_TYPE.equals(origin)) {
PolicyInclude include = description
.getPolicyInclude();
@@ -1929,14 +1963,14 @@
if (extElement instanceof UnknownExtensibilityElement) {
UnknownExtensibilityElement unknown = (UnknownExtensibilityElement) extElement;
if (WSDLConstants.WSDL11Constants.POLICY.equals(unknown.getElementType())) {
-
+
Policy policy = (Policy) PolicyUtil.getPolicyComponent(unknown.getElement());
-
+
String key;
if ((key = policy.getName()) != null || (key = policy.getId()) != null) {
registry.register(key, policy);
}
-
+
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org