You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@axis.apache.org by ki...@apache.org on 2013/10/27 06:48:36 UTC
svn commit: r1536050 [4/5] - in /axis/axis2/java/core/trunk/modules:
adb-codegen/ adb-codegen/src/org/apache/axis2/schema/
adb-codegen/src/org/apache/axis2/schema/template/
adb-codegen/test/org/apache/axis2/schema/
adb-codegen/test/org/apache/axis2/sch...
Modified: axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/builder/BuilderUtil.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/builder/BuilderUtil.java?rev=1536050&r1=1536049&r2=1536050&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/builder/BuilderUtil.java (original)
+++ axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/builder/BuilderUtil.java Sun Oct 27 05:48:34 2013
@@ -29,10 +29,8 @@ import org.apache.axiom.om.OMNamespace;
import org.apache.axiom.om.OMText;
import org.apache.axiom.om.OMXMLBuilderFactory;
import org.apache.axiom.om.OMXMLParserWrapper;
-import org.apache.axiom.om.impl.MTOMConstants;
import org.apache.axiom.om.impl.builder.StAXBuilder;
import org.apache.axiom.om.impl.builder.StAXOMBuilder;
-import org.apache.axiom.om.impl.builder.XOPAwareStAXOMBuilder;
import org.apache.axiom.om.util.StAXParserConfiguration;
import org.apache.axiom.om.util.StAXUtils;
import org.apache.axiom.soap.SOAP11Constants;
@@ -43,7 +41,6 @@ import org.apache.axiom.soap.SOAPEnvelop
import org.apache.axiom.soap.SOAPFactory;
import org.apache.axiom.soap.SOAPModelBuilder;
import org.apache.axiom.soap.SOAPProcessingException;
-import org.apache.axiom.soap.impl.builder.MTOMStAXSOAPModelBuilder;
import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
import org.apache.axis2.AxisFault;
import org.apache.axis2.Constants;
@@ -65,9 +62,9 @@ import org.apache.commons.logging.LogFac
import org.apache.ws.commons.schema.XmlSchemaAll;
import org.apache.ws.commons.schema.XmlSchemaComplexType;
import org.apache.ws.commons.schema.XmlSchemaElement;
-import org.apache.ws.commons.schema.XmlSchemaGroupBase;
import org.apache.ws.commons.schema.XmlSchemaParticle;
import org.apache.ws.commons.schema.XmlSchemaSequence;
+import org.apache.ws.commons.schema.XmlSchemaSequenceMember;
import org.apache.ws.commons.schema.XmlSchemaType;
import javax.activation.DataHandler;
@@ -84,7 +81,6 @@ import java.io.Reader;
import java.io.UnsupportedEncodingException;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
-import java.util.Iterator;
import java.util.Map;
public class BuilderUtil {
@@ -138,58 +134,50 @@ public class BuilderUtil {
XmlSchemaComplexType complexType = ((XmlSchemaComplexType)schemaType);
XmlSchemaParticle particle = complexType.getParticle();
if (particle instanceof XmlSchemaSequence || particle instanceof XmlSchemaAll) {
- XmlSchemaGroupBase xmlSchemaGroupBase = (XmlSchemaGroupBase)particle;
- Iterator iterator = xmlSchemaGroupBase.getItems().getIterator();
- // now we need to know some information from the binding operation.
-
- while (iterator.hasNext()) {
- XmlSchemaElement innerElement = (XmlSchemaElement)iterator.next();
- QName qName = innerElement.getQName();
- // ignoring the elements without proper type and minoccurs zero
- if ((innerElement.getSchemaTypeName() == null) && (innerElement.getMinOccurs() == 0)){
- continue;
- }
- if (qName == null && innerElement.getSchemaTypeName()
- .equals(org.apache.ws.commons.schema.constants.Constants.XSD_ANYTYPE)) {
- createSOAPMessageWithoutSchema(soapFactory, bodyFirstChild,
- requestParameterMap);
- break;
- }
- long minOccurs = innerElement.getMinOccurs();
- boolean nillable = innerElement.isNillable();
- String name =
- qName != null ? qName.getLocalPart() : innerElement.getName();
- Object value;
- OMNamespace ns = (qName == null ||
- qName.getNamespaceURI() == null
- || qName.getNamespaceURI().length() == 0) ?
- null : soapFactory.createOMNamespace(
- qName.getNamespaceURI(), null);
-
- // FIXME changed
- while ((value = requestParameterMap.get(name)) != null) {
- addRequestParameter(soapFactory,
- bodyFirstChild, ns, name, value);
- minOccurs--;
+ if (particle instanceof XmlSchemaSequence) {
+ XmlSchemaSequence sequence = (XmlSchemaSequence) particle;
+ // now we need to know some information from the binding operation.
+
+ for (XmlSchemaSequenceMember sequenceMember : sequence.getItems()) {
+
+ XmlSchemaElement innerElement = (XmlSchemaElement) sequenceMember;
+ QName qName = innerElement.getQName();
+ // ignoring the elements without proper type and minoccurs zero
+ if ((innerElement.getSchemaTypeName() == null) &&
+ (innerElement.getMinOccurs() == 0)) {
+ continue;
+ }
+ if (qName == null && innerElement.getSchemaTypeName()
+ .equals(org.apache.ws.commons.schema.constants.Constants.XSD_ANYTYPE)) {
+ createSOAPMessageWithoutSchema(soapFactory, bodyFirstChild,
+ requestParameterMap);
+ break;
+ }
+ checkMinOccurs(innerElement, qName, soapFactory, requestParameterMap,
+ bodyFirstChild);
}
- if (minOccurs > 0) {
- if (nillable) {
-
- OMNamespace xsi = soapFactory.createOMNamespace(
- Constants.URI_DEFAULT_SCHEMA_XSI,
- Constants.NS_PREFIX_SCHEMA_XSI);
- OMAttribute omAttribute =
- soapFactory.createOMAttribute("nil", xsi, "true");
- soapFactory.createOMElement(name, ns,
- bodyFirstChild)
- .addAttribute(omAttribute);
-
- } else {
- throw new AxisFault("Required element " + qName +
- " defined in the schema can not be" +
- " found in the request");
+ } else {
+ XmlSchemaAll sequence = (XmlSchemaAll) particle;
+ // now we need to know some information from the binding operation.
+
+ for (XmlSchemaSequenceMember sequenceMember : sequence.getItems()) {
+
+ XmlSchemaElement innerElement = (XmlSchemaElement) sequenceMember;
+ QName qName = innerElement.getQName();
+ // ignoring the elements without proper type and minoccurs zero
+ if ((innerElement.getSchemaTypeName() == null) &&
+ (innerElement.getMinOccurs() == 0)) {
+ continue;
+ }
+ if (qName == null && innerElement.getSchemaTypeName()
+ .equals(org.apache.ws.commons.schema.constants.Constants.XSD_ANYTYPE)) {
+ createSOAPMessageWithoutSchema(soapFactory, bodyFirstChild,
+ requestParameterMap);
+ break;
}
+ checkMinOccurs(innerElement, qName, soapFactory, requestParameterMap,
+ bodyFirstChild);
}
}
}
@@ -202,6 +190,48 @@ public class BuilderUtil {
return soapEnvelope;
}
+ private static void checkMinOccurs(XmlSchemaElement innerElement, QName qName,
+ SOAPFactory soapFactory,
+ MultipleEntryHashMap requestParameterMap,
+ OMElement bodyFirstChild)
+ throws AxisFault {
+ long minOccurs = innerElement.getMinOccurs();
+ boolean nillable = innerElement.isNillable();
+ String name =
+ qName != null ? qName.getLocalPart() : innerElement.getName();
+ Object value;
+ OMNamespace ns = (qName == null ||
+ qName.getNamespaceURI() == null
+ || qName.getNamespaceURI().length() == 0) ?
+ null : soapFactory.createOMNamespace(
+ qName.getNamespaceURI(), null);
+
+ // FIXME changed
+ while ((value = requestParameterMap.get(name)) != null) {
+ addRequestParameter(soapFactory,
+ bodyFirstChild, ns, name, value);
+ minOccurs--;
+ }
+ if (minOccurs > 0) {
+ if (nillable) {
+
+ OMNamespace xsi = soapFactory.createOMNamespace(
+ Constants.URI_DEFAULT_SCHEMA_XSI,
+ Constants.NS_PREFIX_SCHEMA_XSI);
+ OMAttribute omAttribute =
+ soapFactory.createOMAttribute("nil", xsi, "true");
+ soapFactory.createOMElement(name, ns,
+ bodyFirstChild)
+ .addAttribute(omAttribute);
+
+ } else {
+ throw new AxisFault("Required element " + qName +
+ " defined in the schema can not be" +
+ " found in the request");
+ }
+ }
+ }
+
public static void createSOAPMessageWithoutSchema(SOAPFactory soapFactory,
OMElement bodyFirstChild,
MultipleEntryHashMap requestParameterMap) {
Modified: axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/AxisMessage.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/AxisMessage.java?rev=1536050&r1=1536049&r2=1536050&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/AxisMessage.java (original)
+++ axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/AxisMessage.java Sun Oct 27 05:48:34 2013
@@ -28,13 +28,16 @@ import org.apache.axis2.util.PolicyUtil;
import org.apache.axis2.wsdl.SOAPHeaderMessage;
import org.apache.neethi.Policy;
import org.apache.neethi.PolicyComponent;
-import org.apache.ws.commons.schema.*;
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.ws.commons.schema.XmlSchemaImport;
+import org.apache.ws.commons.schema.XmlSchemaInclude;
+import org.apache.ws.commons.schema.XmlSchemaObject;
import javax.xml.namespace.QName;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
-import java.util.Iterator;
import java.util.List;
@@ -145,23 +148,17 @@ public class AxisMessage extends AxisDes
xmlSchemaElement = schema.getElementByName(this.elementQname);
if (xmlSchemaElement == null) {
// try to find in an import or an include
- XmlSchemaObjectCollection includes = schema.getIncludes();
- if (includes != null) {
- Iterator includesIter = includes.getIterator();
- Object object;
- while (includesIter.hasNext()) {
- object = includesIter.next();
- if (object instanceof XmlSchemaImport) {
- XmlSchema schema1 = ((XmlSchemaImport) object).getSchema();
- xmlSchemaElement = getSchemaElement(schema1);
- }
- if (object instanceof XmlSchemaInclude) {
- XmlSchema schema1 = ((XmlSchemaInclude) object).getSchema();
- xmlSchemaElement = getSchemaElement(schema1);
- }
- if (xmlSchemaElement != null){
- break;
- }
+ for (XmlSchemaObject external : schema.getExternals()) {
+ if (external instanceof XmlSchemaImport) {
+ XmlSchema schema1 = ((XmlSchemaImport) external).getSchema();
+ xmlSchemaElement = getSchemaElement(schema1);
+ }
+ if (external instanceof XmlSchemaInclude) {
+ XmlSchema schema1 = ((XmlSchemaInclude) external).getSchema();
+ xmlSchemaElement = getSchemaElement(schema1);
+ }
+ if (xmlSchemaElement != null) {
+ break;
}
}
}
Modified: axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/AxisService.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/AxisService.java?rev=1536050&r1=1536049&r2=1536050&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/AxisService.java (original)
+++ axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/AxisService.java Sun Oct 27 05:48:34 2013
@@ -72,7 +72,6 @@ import org.apache.woden.wsdl20.Descripti
import org.apache.ws.commons.schema.XmlSchema;
import org.apache.ws.commons.schema.XmlSchemaElement;
import org.apache.ws.commons.schema.XmlSchemaExternal;
-import org.apache.ws.commons.schema.XmlSchemaObjectCollection;
import org.apache.ws.commons.schema.utils.NamespaceMap;
import org.apache.ws.commons.schema.utils.NamespacePrefixList;
@@ -107,6 +106,7 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
+import java.io.UnsupportedEncodingException;
import java.lang.reflect.Method;
import java.net.SocketException;
import java.net.URISyntaxException;
@@ -988,8 +988,13 @@ public class AxisService extends AxisDes
public void printSchema(OutputStream out) throws AxisFault {
for (int i = 0; i < schemaList.size(); i++) {
XmlSchema schema = addNameSpaces(i);
- schema.write(out);
- }
+ try {
+ schema.write(out);
+ } catch (UnsupportedEncodingException e) {
+ log.error("Error while printing schema ", e);
+ throw new AxisFault(e.getMessage(), e);
+ }
+ }
}
public XmlSchema getSchema(int index) {
@@ -1291,17 +1296,12 @@ public class AxisService extends AxisDes
}
private void updateSchemaLocation(XmlSchema schema) throws AxisFault {
- XmlSchemaObjectCollection includes = schema.getIncludes();
- for (int j = 0; j < includes.getCount(); j++) {
- Object item = includes.getItem(j);
- if (item instanceof XmlSchemaExternal) {
- XmlSchemaExternal xmlSchemaExternal = (XmlSchemaExternal) item;
- XmlSchema s = xmlSchemaExternal.getSchema();
- updateSchemaLocation(s, xmlSchemaExternal);
- }
+ for (XmlSchemaExternal xmlSchemaExternal : schema.getExternals()) {
+ XmlSchema s = xmlSchemaExternal.getSchema();
+ updateSchemaLocation(s, xmlSchemaExternal);
}
}
-
+
private void updateSchemaLocation(XmlSchema s, XmlSchemaExternal xmlSchemaExternal) throws AxisFault {
if (s != null) {
String schemaLocation = xmlSchemaExternal.getSchemaLocation();
@@ -2786,15 +2786,9 @@ public class AxisService extends AxisDes
// first traversal - fill the hashtable
for (int i = 0; i < schemas.size(); i++) {
XmlSchema schema = (XmlSchema) schemas.get(i);
- XmlSchemaObjectCollection includes = schema.getIncludes();
-
- for (int j = 0; j < includes.getCount(); j++) {
- Object item = includes.getItem(j);
- XmlSchema s;
- if (item instanceof XmlSchemaExternal) {
- XmlSchemaExternal externalSchema = (XmlSchemaExternal) item;
- s = externalSchema.getSchema();
-
+ for (XmlSchemaExternal externalSchema : schema.getExternals()) {
+ if (externalSchema != null) {
+ XmlSchema s = externalSchema.getSchema();
if (s != null
&& getScheamLocationWithDot(
sourceURIToNewLocationMap, s) == null) {
@@ -2878,22 +2872,16 @@ public class AxisService extends AxisDes
* @param parentSchema
* @param nameTable
*/
- private void adjustSchemaName(XmlSchema parentSchema, Hashtable nameTable,
- Hashtable importedScheams, Hashtable sourceURIToNewLocationMap) {
- XmlSchemaObjectCollection includes = parentSchema.getIncludes();
- for (int j = 0; j < includes.getCount(); j++) {
- Object item = includes.getItem(j);
- if (item instanceof XmlSchemaExternal) {
- XmlSchemaExternal xmlSchemaExternal = (XmlSchemaExternal) item;
- XmlSchema s = xmlSchemaExternal.getSchema();
- adjustSchemaLocation(s, xmlSchemaExternal, nameTable,
- importedScheams, sourceURIToNewLocationMap);
- }
- }
+ private void adjustSchemaName(XmlSchema parentSchema, Hashtable nameTable,
+ Hashtable importedScheams, Hashtable sourceURIToNewLocationMap) {
+ for (XmlSchemaExternal xmlSchemaExternal : parentSchema.getExternals()) {
+ XmlSchema s = xmlSchemaExternal.getSchema();
+ adjustSchemaLocation(s, xmlSchemaExternal, nameTable,
+ importedScheams, sourceURIToNewLocationMap);
+ }
+ }
- }
-
- /**
+ /**
* Adjusts a given schema location
*
* @param s
@@ -3401,7 +3389,7 @@ public class AxisService extends AxisDes
/**
* returns a axisService given a input Stream of WSDL2.0 document.
*
- * @param Description
+ * @param description
* WSDL description
* @param wsdlServiceName
* @param endPoint
Modified: axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL20.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL20.java?rev=1536050&r1=1536049&r2=1536050&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL20.java (original)
+++ axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL20.java Sun Oct 27 05:48:34 2013
@@ -25,8 +25,8 @@ import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
import org.apache.axiom.om.OMNode;
-import org.apache.axiom.soap.SOAP12Constants;
import org.apache.axiom.soap.SOAP11Constants;
+import org.apache.axiom.soap.SOAP12Constants;
import org.apache.axis2.AxisFault;
import org.apache.axis2.Constants;
import org.apache.axis2.addressing.AddressingConstants;
@@ -46,9 +46,9 @@ import org.apache.neethi.PolicyReference
import org.apache.ws.commons.schema.XmlSchema;
import org.apache.ws.commons.schema.XmlSchemaComplexType;
import org.apache.ws.commons.schema.XmlSchemaElement;
-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.XmlSchemaSequenceMember;
import org.apache.ws.commons.schema.XmlSchemaSimpleType;
import org.apache.ws.commons.schema.XmlSchemaType;
@@ -398,41 +398,38 @@ public class AxisService2WSDL20 implemen
}
inMessageElementQname = schemaElement.getQName();
XmlSchemaType type = schemaElement.getSchemaType();
- if (type != null && type instanceof XmlSchemaComplexType){
+ if (type != null && type instanceof XmlSchemaComplexType) {
XmlSchemaComplexType complexType = (XmlSchemaComplexType) type;
XmlSchemaParticle particle = complexType.getParticle();
- if (particle != null && particle instanceof XmlSchemaSequence){
+ if (particle != null && particle instanceof XmlSchemaSequence) {
XmlSchemaSequence xmlSchemaSequence = (XmlSchemaSequence) particle;
- XmlSchemaObjectCollection schemaObjectCollection =
- xmlSchemaSequence.getItems();
- if (schemaObjectCollection != null) {
- Iterator iterator = schemaObjectCollection.getIterator();
- while (iterator.hasNext()) {
- Object next = iterator.next();
- if (!(next instanceof XmlSchemaElement)) {
- return new URI [0];
+ if (!xmlSchemaSequence.getItems().isEmpty()) {
+ for (XmlSchemaSequenceMember member : xmlSchemaSequence.getItems()) {
+
+ if (!(member instanceof XmlSchemaElement)) {
+ return new URI[0];
}
- XmlSchemaElement innerElement = (XmlSchemaElement) next;
- if (innerElement.getRefName() != null) {
- return new URI [0];
+ XmlSchemaElement innerElement = (XmlSchemaElement) member;
+ if (innerElement.getRef().getTargetQName() != null) {
+ return new URI[0];
}
if (innerElement.getMinOccurs() != 1 ||
- innerElement.getMaxOccurs() != 1) {
+ innerElement.getMaxOccurs() != 1) {
isMultipart = false;
}
XmlSchemaType schemaType = innerElement.getSchemaType();
QName innerElementQName = innerElement.getSchemaTypeName();
if (schemaType instanceof XmlSchemaSimpleType) {
if (Constants.XSD_QNAME.equals(innerElementQName) ||
- Constants.XSD_NOTATION.equals(innerElementQName) ||
- Constants.XSD_HEXBIN.equals(innerElementQName) ||
- Constants.XSD_BASE64.equals(innerElementQName)) {
- isIRI = false;
+ Constants.XSD_NOTATION.equals(innerElementQName) ||
+ Constants.XSD_HEXBIN.equals(innerElementQName) ||
+ Constants.XSD_BASE64.equals(innerElementQName)) {
+ isIRI = false;
}
} else {
isIRI = false;
}
- if (Constants.XSD_ANY.equals(innerElementQName) && iterator.hasNext()) {
+ if (Constants.XSD_ANY.equals(innerElementQName)) {
isRPC = false;
}
String name = innerElement.getName();
@@ -444,11 +441,11 @@ public class AxisService2WSDL20 implemen
}
}
} else {
- return new URI [0];
+ return new URI[0];
}
} else {
- return new URI [0];
- }
+ return new URI[0];
+ }
} else {
return new URI [0];
}
@@ -479,19 +476,15 @@ public class AxisService2WSDL20 implemen
XmlSchemaParticle particle = complexType.getParticle();
if (particle != null && particle instanceof XmlSchemaSequence) {
XmlSchemaSequence xmlSchemaSequence = (XmlSchemaSequence) particle;
- XmlSchemaObjectCollection schemaObjectCollection =
- xmlSchemaSequence.getItems();
- if (schemaObjectCollection != null) {
- Iterator iterator = schemaObjectCollection.getIterator();
- while (iterator.hasNext()) {
- Object next = iterator.next();
- if (!(next instanceof XmlSchemaElement)) {
+ if (!xmlSchemaSequence.getItems().isEmpty()) {
+ for (XmlSchemaSequenceMember member : xmlSchemaSequence.getItems()) {
+ if (!(member instanceof XmlSchemaElement)) {
isRPC = false;
}
- XmlSchemaElement innerElement = (XmlSchemaElement) next;
+ XmlSchemaElement innerElement = (XmlSchemaElement) member;
QName schemaTypeName = innerElement.getSchemaTypeName();
String name = innerElement.getName();
- if (innerElement.getRefName() != null) {
+ if (innerElement.getRef().getTargetQName() != null) {
isRPC = false;
}
if (outMessageElementDetails.get(name) != null) {
@@ -500,7 +493,7 @@ public class AxisService2WSDL20 implemen
QName inMessageElementType =
(QName) inMessageElementDetails.get(name);
if (inMessageElementType != null &&
- inMessageElementType != schemaTypeName) {
+ inMessageElementType != schemaTypeName) {
isRPC = false;
}
outMessageElementDetails.put(name, schemaTypeName);
Modified: axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/java2wsdl/DefaultSchemaGenerator.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/java2wsdl/DefaultSchemaGenerator.java?rev=1536050&r1=1536049&r2=1536050&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/java2wsdl/DefaultSchemaGenerator.java (original)
+++ axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/java2wsdl/DefaultSchemaGenerator.java Sun Oct 27 05:48:34 2013
@@ -75,7 +75,6 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import java.util.Hashtable;
-import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -321,7 +320,7 @@ public class DefaultSchemaGenerator impl
// since we do not support overload
- Map<String,Method> uniqueMethods = new LinkedHashMap<String,Method>();
+ Map<String, Method> uniqueMethods = new LinkedHashMap<String, Method>();
XmlSchemaComplexType methodSchemaType;
XmlSchemaSequence sequence = null;
@@ -339,7 +338,7 @@ public class DefaultSchemaGenerator impl
if (uniqueMethods.get(methodName) != null) {
log.warn("We don't support method overloading. Ignoring [" +
- methodName + "]");
+ methodName + "]");
continue;
}
if (!Modifier.isPublic(jMethod.getModifiers())) {
@@ -361,8 +360,8 @@ public class DefaultSchemaGenerator impl
addToService = true;
}
// by now axis operation should be assigned but we better recheck & add the paramether
- if(axisOperation != null){
- axisOperation.addParameter("JAXRSAnnotaion", JAXRSUtils.getMethodModel(this.classModel,jMethod));
+ if (axisOperation != null) {
+ axisOperation.addParameter("JAXRSAnnotaion", JAXRSUtils.getMethodModel(this.classModel, jMethod));
}
// Maintain a list of methods we actually work with
list.add(jMethod);
@@ -401,7 +400,7 @@ public class DefaultSchemaGenerator impl
}
service.addMessageElementQNameToOperationMapping(methodSchemaType.getQName(),
- axisOperation);
+ axisOperation);
Annotation[][] parameterAnnotation = jMethod.getParameterAnnotations();
@@ -413,36 +412,36 @@ public class DefaultSchemaGenerator impl
if (nonRpcMethods.contains(jMethod.getName())) {
generateSchemaForType(sequence, null, jMethod.getName());
break;
-
- } else if(methodParameter != null && Document.class.isAssignableFrom(methodParameter)) {
- generateSchemaTypeForDocument(sequence, parameterName);
-
- } else if(methodParameter != null && Map.class.isAssignableFrom(methodParameter)) {
- generateWrappedSchemaTypeForMap(sequence, genericParameterTypes[j], parameterName);
-
- } else if(methodParameter != null && Collection.class.isAssignableFrom(methodParameter)){
- generateWrappedSchemaTypeForCollection(sequence, genericParameterTypes[j], parameterName);
-
- }else if(methodParameter != null && Enum.class.isAssignableFrom(methodParameter)){
- generateWrappedSchemaTypeForEnum(sequence , parameterName , methodParameter , false);
- }else {
+
+ } else if (methodParameter != null && Document.class.isAssignableFrom(methodParameter)) {
+ generateSchemaTypeForDocument(sequence, parameterName);
+
+ } else if (methodParameter != null && Map.class.isAssignableFrom(methodParameter)) {
+ generateWrappedSchemaTypeForMap(sequence, genericParameterTypes[j], parameterName);
+
+ } else if (methodParameter != null && Collection.class.isAssignableFrom(methodParameter)) {
+ generateWrappedSchemaTypeForCollection(sequence, genericParameterTypes[j], parameterName);
+
+ } else if (methodParameter != null && Enum.class.isAssignableFrom(methodParameter)) {
+ generateWrappedSchemaTypeForEnum(sequence, parameterName, methodParameter, false);
+ } else {
Type genericParameterType = genericParameterTypes[j];
Type genericType = null;
- if(genericParameterType instanceof ParameterizedType){
+ if (genericParameterType instanceof ParameterizedType) {
ParameterizedType aType = (ParameterizedType) genericParameterType;
Type[] parameterArgTypes = aType.getActualTypeArguments();
genericType = parameterArgTypes[0];
generateSchemaForType(sequence, genericType, parameterName, true);
- }else{
- if(methodParameter.isArray()){
+ } else {
+ if (methodParameter.isArray()) {
Class<?> componentType = methodParameter.getComponentType();
if (Enum.class.isAssignableFrom(componentType)) {
- generateWrappedSchemaTypeForEnum(sequence, parameterName, componentType, true);
+ generateWrappedSchemaTypeForEnum(sequence, parameterName, componentType, true);
} else {
- generateSchemaForType(sequence, methodParameter, parameterName);
+ generateSchemaForType(sequence, methodParameter, parameterName);
}
- }else{
+ } else {
generateSchemaForType(sequence, methodParameter, parameterName);
}
}
@@ -455,30 +454,30 @@ public class DefaultSchemaGenerator impl
methodSchemaType =
createSchemaTypeForMethodPart(partQname);
sequence = new XmlSchemaSequence();
- methodSchemaType.setParticle(sequence);
- String returnName = "return";
+ methodSchemaType.setParticle(sequence);
+ String returnName = "return";
Type genericParameterType = jMethod.getGenericReturnType();
if (nonRpcMethods.contains(jMethod.getName())) {
generateSchemaForType(sequence, null, returnName);
-
- } else if(returnType != null && Document.class.isAssignableFrom(returnType)) {
- generateSchemaTypeForDocument(sequence, returnName);
-
- } else if (Map.class.isAssignableFrom(returnType)){
- if (genericParameterType instanceof ParameterizedType) {
- generateWrappedSchemaTypeForMap(sequence, genericParameterType, returnName);
- } else {
- generateWrappedSchemaTypeForMap(sequence, returnType, returnName);
- }
- } else if (Collection.class.isAssignableFrom(returnType)){
- if (genericParameterType instanceof ParameterizedType) {
- generateWrappedSchemaTypeForCollection(sequence, genericParameterType, returnName);
- } else {
- generateWrappedSchemaTypeForCollection(sequence, genericParameterType, returnName);
- }
- }else if(Enum.class .isAssignableFrom(returnType)){
- generateWrappedSchemaTypeForEnum(sequence , returnName , returnType , false);
- } else if(genericParameterType instanceof ParameterizedType){
+
+ } else if (returnType != null && Document.class.isAssignableFrom(returnType)) {
+ generateSchemaTypeForDocument(sequence, returnName);
+
+ } else if (Map.class.isAssignableFrom(returnType)) {
+ if (genericParameterType instanceof ParameterizedType) {
+ generateWrappedSchemaTypeForMap(sequence, genericParameterType, returnName);
+ } else {
+ generateWrappedSchemaTypeForMap(sequence, returnType, returnName);
+ }
+ } else if (Collection.class.isAssignableFrom(returnType)) {
+ if (genericParameterType instanceof ParameterizedType) {
+ generateWrappedSchemaTypeForCollection(sequence, genericParameterType, returnName);
+ } else {
+ generateWrappedSchemaTypeForCollection(sequence, genericParameterType, returnName);
+ }
+ } else if (Enum.class.isAssignableFrom(returnType)) {
+ generateWrappedSchemaTypeForEnum(sequence, returnName, returnType, false);
+ } else if (genericParameterType instanceof ParameterizedType) {
ParameterizedType aType = (ParameterizedType) genericParameterType;
Type[] parameterArgTypes = aType.getActualTypeArguments();
generateSchemaForType(sequence, parameterArgTypes[0], returnName, true);
@@ -486,7 +485,7 @@ public class DefaultSchemaGenerator impl
if (returnType.isArray()) {
Class<?> returnComponentType = returnType.getComponentType();
if (Enum.class.isAssignableFrom(returnComponentType)) {
- generateWrappedSchemaTypeForEnum(sequence, returnName, returnComponentType, true);
+ generateWrappedSchemaTypeForEnum(sequence, returnName, returnComponentType, true);
} else {
generateSchemaForType(sequence, returnType, returnName);
}
@@ -506,7 +505,7 @@ public class DefaultSchemaGenerator impl
}
service.addMessageElementQNameToOperationMapping(methodSchemaType.getQName(),
- axisOperation);
+ axisOperation);
}
if (addToService) {
service.addOperation(axisOperation);
@@ -576,10 +575,10 @@ public class DefaultSchemaGenerator impl
XmlSchemaSequence sequence = new XmlSchemaSequence();
XmlSchema xmlSchema = getXmlSchema(schemaTargetNameSpace);
QName elementName = new QName(schemaTargetNameSpace, "Exception", schema_namespace_prefix);
- XmlSchemaComplexType complexType = new XmlSchemaComplexType(xmlSchema);
+ XmlSchemaComplexType complexType = new XmlSchemaComplexType(xmlSchema, false);
complexType.setName("Exception");
xmlSchema.getItems().add(complexType);
- xmlSchema.getSchemaTypes().add(elementName, complexType);
+ xmlSchema.getSchemaTypes().put(elementName, complexType);
typeTable.addComplexSchema(Exception.class.getName(), elementName);
QName schemaTypeName = new QName(Java2WSDLConstants.URI_2001_SCHEMA_XSD, "string");
addContentToMethodSchemaType(sequence, schemaTypeName, "Message", false);
@@ -608,7 +607,7 @@ public class DefaultSchemaGenerator impl
targetNamespacePrefixMap.put(targetNameSpace, targetNamespacePrefix);
}
- XmlSchemaComplexType complexType = new XmlSchemaComplexType(xmlSchema);
+ XmlSchemaComplexType complexType = new XmlSchemaComplexType(xmlSchema, false);
XmlSchemaSequence sequence = new XmlSchemaSequence();
XmlSchemaComplexContentExtension complexExtension =
new XmlSchemaComplexContentExtension();
@@ -645,7 +644,7 @@ public class DefaultSchemaGenerator impl
//if the parent class package name is differ from the child
if (!((NamespaceMap) xmlSchema.getNamespaceContext()).values().
contains(tgtNamespace)) {
- XmlSchemaImport importElement = new XmlSchemaImport();
+ XmlSchemaImport importElement = new XmlSchemaImport(xmlSchema);
importElement.setNamespace(tgtNamespace);
xmlSchema.getItems().add(importElement);
((NamespaceMap) xmlSchema.getNamespaceContext()).
@@ -670,7 +669,7 @@ public class DefaultSchemaGenerator impl
}
xmlSchema.getItems().add(complexType);
- xmlSchema.getSchemaTypes().add(schemaTypeName, complexType);
+ xmlSchema.getSchemaTypes().put(schemaTypeName, complexType);
// adding this type to the table
typeTable.addComplexSchema(name, schemaTypeName);
@@ -774,7 +773,7 @@ public class DefaultSchemaGenerator impl
simpleTypeName += getSimpleClassName(simpleType);
if (xmlSchema.getTypeByName(simpleTypeName) == null) {
- XmlSchemaComplexType xmlSchemaComplexType = new XmlSchemaComplexType(xmlSchema);
+ XmlSchemaComplexType xmlSchemaComplexType = new XmlSchemaComplexType(xmlSchema, false);
XmlSchemaSequence xmlSchemaSequence = new XmlSchemaSequence();
xmlSchemaComplexType.setParticle(xmlSchemaSequence);
generateSchemaforFieldsandProperties(xmlSchema,
@@ -782,25 +781,25 @@ public class DefaultSchemaGenerator impl
xmlSchemaComplexType.setName(simpleTypeName);
xmlSchema.getItems().add(xmlSchemaComplexType);
- xmlSchema.getSchemaTypes().add(
+ xmlSchema.getSchemaTypes().put(
new QName(xmlSchema.getTargetNamespace(), simpleTypeName), xmlSchemaComplexType);
}
if (isGenerateWrappedArrayTypes) {
- XmlSchemaElement xmlSchemaElement = new XmlSchemaElement();
+ XmlSchemaElement xmlSchemaElement = new XmlSchemaElement(xmlSchema, false);
xmlSchemaElement.setName( name + "Wrapper");
xmlSchemaElement.setNillable(true);
sequence.getItems().add(xmlSchemaElement);
String complexTypeName = simpleTypeName + "Wrapper";
- XmlSchemaComplexType xmlSchemaComplexType = new XmlSchemaComplexType(xmlSchema);
+ XmlSchemaComplexType xmlSchemaComplexType = new XmlSchemaComplexType(xmlSchema, false);
XmlSchemaSequence xmlSchemaSequence = new XmlSchemaSequence();
xmlSchemaComplexType.setParticle(xmlSchemaSequence);
xmlSchemaComplexType.setName(complexTypeName);
xmlSchema.getItems().add(xmlSchemaComplexType);
- xmlSchema.getSchemaTypes().add(
+ xmlSchema.getSchemaTypes().put(
new QName(schemaTargetNameSpace, xmlSchemaComplexType.getName()),
xmlSchemaComplexType);
addContentToMethodSchemaType(xmlSchemaSequence,
@@ -869,7 +868,7 @@ public class DefaultSchemaGenerator impl
if (typeTable.getComplexSchemaType(propertyName) != null && !((NamespaceMap) xmlSchema.getNamespaceContext()).values().
contains(typeTable.getComplexSchemaType(propertyName).getNamespaceURI())) {
- XmlSchemaImport importElement = new XmlSchemaImport();
+ XmlSchemaImport importElement = new XmlSchemaImport(xmlSchema);
importElement.setNamespace(
typeTable.getComplexSchemaType(propertyName).getNamespaceURI());
xmlSchema.getItems().add(importElement);
@@ -901,7 +900,7 @@ public class DefaultSchemaGenerator impl
simpleTypeName += simpleType.getSimpleName();
if (xmlSchema.getTypeByName(simpleTypeName) == null) {
- XmlSchemaComplexType xmlSchemaComplexType = new XmlSchemaComplexType(xmlSchema);
+ XmlSchemaComplexType xmlSchemaComplexType = new XmlSchemaComplexType(xmlSchema, false);
XmlSchemaSequence xmlSchemaSequence = new XmlSchemaSequence();
xmlSchemaComplexType.setParticle(xmlSchemaSequence);
generateSchemaforGenericFields(xmlSchema,
@@ -909,25 +908,25 @@ public class DefaultSchemaGenerator impl
xmlSchemaComplexType.setName(simpleTypeName);
xmlSchema.getItems().add(xmlSchemaComplexType);
- xmlSchema.getSchemaTypes().add(
+ xmlSchema.getSchemaTypes().put(
new QName(xmlSchema.getTargetNamespace(), simpleTypeName), xmlSchemaComplexType);
}
if (isGenerateWrappedArrayTypes) {
- XmlSchemaElement xmlSchemaElement = new XmlSchemaElement();
+ XmlSchemaElement xmlSchemaElement = new XmlSchemaElement(xmlSchema, false);
xmlSchemaElement.setName( name + "Wrapper");
xmlSchemaElement.setNillable(true);
sequence.getItems().add(xmlSchemaElement);
String complexTypeName = simpleTypeName + "Wrapper";
- XmlSchemaComplexType xmlSchemaComplexType = new XmlSchemaComplexType(xmlSchema);
+ XmlSchemaComplexType xmlSchemaComplexType = new XmlSchemaComplexType(xmlSchema, false);
XmlSchemaSequence xmlSchemaSequence = new XmlSchemaSequence();
xmlSchemaComplexType.setParticle(xmlSchemaSequence);
xmlSchemaComplexType.setName(complexTypeName);
xmlSchema.getItems().add(xmlSchemaComplexType);
- xmlSchema.getSchemaTypes().add(
+ xmlSchema.getSchemaTypes().put(
new QName(schemaTargetNameSpace, xmlSchemaComplexType.getName()),
xmlSchemaComplexType);
addContentToMethodSchemaType(xmlSchemaSequence,
@@ -998,7 +997,7 @@ public class DefaultSchemaGenerator impl
if (typeTable.getComplexSchemaType(propertyName) != null && !((NamespaceMap) xmlSchema.getNamespaceContext()).values().
contains(typeTable.getComplexSchemaType(propertyName).getNamespaceURI())) {
- XmlSchemaImport importElement = new XmlSchemaImport();
+ XmlSchemaImport importElement = new XmlSchemaImport(xmlSchema);
importElement.setNamespace(
typeTable.getComplexSchemaType(propertyName).getNamespaceURI());
xmlSchema.getItems().add(importElement);
@@ -1018,7 +1017,7 @@ public class DefaultSchemaGenerator impl
String name,
boolean isArrayType,
String propertyName) {
- XmlSchemaElement xmlSchemaElement = new XmlSchemaElement();
+ XmlSchemaElement xmlSchemaElement = new XmlSchemaElement(xmlSchema, false);
xmlSchemaElement.setName( name + "Wrapper");
xmlSchemaElement.setNillable(true);
sequence.getItems().add(xmlSchemaElement);
@@ -1028,13 +1027,13 @@ public class DefaultSchemaGenerator impl
XmlSchemaComplexType xmlSchemaComplexType ;
if (xmlSchema.getTypeByName(complexTypeName) == null) {
- xmlSchemaComplexType = new XmlSchemaComplexType(xmlSchema);
+ xmlSchemaComplexType = new XmlSchemaComplexType(xmlSchema, false);
XmlSchemaSequence xmlSchemaSequence = new XmlSchemaSequence();
xmlSchemaComplexType.setParticle(xmlSchemaSequence);
xmlSchemaComplexType.setName(complexTypeName);
xmlSchema.getItems().add(xmlSchemaComplexType);
- xmlSchema.getSchemaTypes().add(
+ xmlSchema.getSchemaTypes().put(
new QName(schemaTargetNameSpace, xmlSchemaComplexType.getName()),
xmlSchemaComplexType);
addElementToSequence("array",
@@ -1057,7 +1056,7 @@ public class DefaultSchemaGenerator impl
boolean isBase64Binary,
boolean isArryType,
boolean isPrimitive) {
- XmlSchemaElement elt1 = new XmlSchemaElement();
+ XmlSchemaElement elt1 = new XmlSchemaElement(getXmlSchema(schemaTargetNameSpace), false);
elt1.setName(name);
elt1.setSchemaTypeName(propertyQName);
sequence.getItems().add(elt1);
@@ -1150,31 +1149,31 @@ public class DefaultSchemaGenerator impl
XmlSchema xmlSchema = getXmlSchema(schemaTargetNameSpace);
if (xmlSchema.getTypeByName(simpleTypeName) == null) {
- XmlSchemaComplexType xmlSchemaComplexType = new XmlSchemaComplexType(xmlSchema);
+ XmlSchemaComplexType xmlSchemaComplexType = new XmlSchemaComplexType(xmlSchema, false);
XmlSchemaSequence xmlSchemaSequence = new XmlSchemaSequence();
xmlSchemaComplexType.setParticle(xmlSchemaSequence);
generateSchemaForType(xmlSchemaSequence, simpleType, "array",true);
xmlSchemaComplexType.setName(simpleTypeName);
xmlSchema.getItems().add(xmlSchemaComplexType);
- xmlSchema.getSchemaTypes().add(
+ xmlSchema.getSchemaTypes().put(
new QName(xmlSchema.getTargetNamespace(), simpleTypeName), xmlSchemaComplexType);
}
if (isGenerateWrappedArrayTypes) {
- XmlSchemaElement xmlSchemaElement = new XmlSchemaElement();
+ XmlSchemaElement xmlSchemaElement = new XmlSchemaElement(xmlSchema, false);
xmlSchemaElement.setName(partName + "Wrapper");
xmlSchemaElement.setNillable(true);
sequence.getItems().add(xmlSchemaElement);
String complexTypeName = simpleTypeName + "Wrapper";
- XmlSchemaComplexType xmlSchemaComplexType = new XmlSchemaComplexType(xmlSchema);
+ XmlSchemaComplexType xmlSchemaComplexType = new XmlSchemaComplexType(xmlSchema, false);
XmlSchemaSequence xmlSchemaSequence = new XmlSchemaSequence();
xmlSchemaComplexType.setParticle(xmlSchemaSequence);
xmlSchemaComplexType.setName(complexTypeName);
xmlSchema.getItems().add(xmlSchemaComplexType);
- xmlSchema.getSchemaTypes().add(
+ xmlSchema.getSchemaTypes().put(
new QName(schemaTargetNameSpace, xmlSchemaComplexType.getName()),
xmlSchemaComplexType);
addContentToMethodSchemaType(xmlSchemaSequence,
@@ -1227,24 +1226,23 @@ public class DefaultSchemaGenerator impl
if (schemaTypeName == null) {
schemaTypeName = generateSchema(type);
if (isGenerateWrappedArrayTypes && isArrayType) {
-
- XmlSchemaElement xmlSchemaElement = new XmlSchemaElement();
+ XmlSchema xmlSchema = getXmlSchema(schemaTargetNameSpace);
+ XmlSchemaElement xmlSchemaElement = new XmlSchemaElement(xmlSchema, false);
xmlSchemaElement.setName(partName + "Wrapper");
xmlSchemaElement.setNillable(true);
sequence.getItems().add(xmlSchemaElement);
String complexTypeName = schemaTypeName.getLocalPart() + "Wrapper";
- XmlSchema xmlSchema = getXmlSchema(schemaTargetNameSpace);
XmlSchemaComplexType xmlSchemaComplexType = null;
if (xmlSchema.getTypeByName(complexTypeName) == null) {
- xmlSchemaComplexType = new XmlSchemaComplexType(xmlSchema);
+ xmlSchemaComplexType = new XmlSchemaComplexType(xmlSchema, false);
XmlSchemaSequence xmlSchemaSequence = new XmlSchemaSequence();
xmlSchemaComplexType.setParticle(xmlSchemaSequence);
xmlSchemaComplexType.setName(complexTypeName);
xmlSchema.getItems().add(xmlSchemaComplexType);
- xmlSchema.getSchemaTypes().add(
+ xmlSchema.getSchemaTypes().put(
new QName(schemaTargetNameSpace, xmlSchemaComplexType.getName()),
xmlSchemaComplexType);
addContentToMethodSchemaType(xmlSchemaSequence,
@@ -1272,24 +1270,23 @@ public class DefaultSchemaGenerator impl
} else {
if (isGenerateWrappedArrayTypes && isArrayType) {
-
- XmlSchemaElement xmlSchemaElement = new XmlSchemaElement();
+ XmlSchema xmlSchema = getXmlSchema(schemaTargetNameSpace);
+ XmlSchemaElement xmlSchemaElement = new XmlSchemaElement(xmlSchema, false);
xmlSchemaElement.setName(partName +"Wrapper");
xmlSchemaElement.setNillable(true);
sequence.getItems().add(xmlSchemaElement);
String complexTypeName = schemaTypeName.getLocalPart() + "Wrapper";
- XmlSchema xmlSchema = getXmlSchema(schemaTargetNameSpace);
XmlSchemaComplexType xmlSchemaComplexType = null;
if (xmlSchema.getTypeByName(complexTypeName) == null) {
- xmlSchemaComplexType = new XmlSchemaComplexType(xmlSchema);
+ xmlSchemaComplexType = new XmlSchemaComplexType(xmlSchema, false);
XmlSchemaSequence xmlSchemaSequence = new XmlSchemaSequence();
xmlSchemaComplexType.setParticle(xmlSchemaSequence);
xmlSchemaComplexType.setName(complexTypeName);
xmlSchema.getItems().add(xmlSchemaComplexType);
- xmlSchema.getSchemaTypes().add(
+ xmlSchema.getSchemaTypes().put(
new QName(schemaTargetNameSpace, xmlSchemaComplexType.getName()),
xmlSchemaComplexType);
addContentToMethodSchemaType(xmlSchemaSequence,
@@ -1319,31 +1316,31 @@ public class DefaultSchemaGenerator impl
private QName processParameterArrayTypes(XmlSchemaSequence sequence, Class<?> type, String partName, String simpleTypeName) throws Exception {
XmlSchema xmlSchema = getXmlSchema(schemaTargetNameSpace);
if (xmlSchema.getTypeByName(simpleTypeName) == null) {
- XmlSchemaComplexType xmlSchemaComplexType = new XmlSchemaComplexType(xmlSchema);
+ XmlSchemaComplexType xmlSchemaComplexType = new XmlSchemaComplexType(xmlSchema, false);
XmlSchemaSequence xmlSchemaSequence = new XmlSchemaSequence();
xmlSchemaComplexType.setParticle(xmlSchemaSequence);
generateSchemaForType(xmlSchemaSequence, type.getComponentType(), "array");
xmlSchemaComplexType.setName(simpleTypeName);
xmlSchema.getItems().add(xmlSchemaComplexType);
- xmlSchema.getSchemaTypes().add(
+ xmlSchema.getSchemaTypes().put(
new QName(xmlSchema.getTargetNamespace(), simpleTypeName), xmlSchemaComplexType);
}
if (isGenerateWrappedArrayTypes) {
- XmlSchemaElement xmlSchemaElement = new XmlSchemaElement();
+ XmlSchemaElement xmlSchemaElement = new XmlSchemaElement(xmlSchema, false);
xmlSchemaElement.setName(partName + "Wrapper");
xmlSchemaElement.setNillable(true);
sequence.getItems().add(xmlSchemaElement);
String complexTypeName = simpleTypeName + "Wrapper";
- XmlSchemaComplexType xmlSchemaComplexType = new XmlSchemaComplexType(xmlSchema);
+ XmlSchemaComplexType xmlSchemaComplexType = new XmlSchemaComplexType(xmlSchema, false);
XmlSchemaSequence xmlSchemaSequence = new XmlSchemaSequence();
xmlSchemaComplexType.setParticle(xmlSchemaSequence);
xmlSchemaComplexType.setName(complexTypeName);
xmlSchema.getItems().add(xmlSchemaComplexType);
- xmlSchema.getSchemaTypes().add(
+ xmlSchema.getSchemaTypes().put(
new QName(schemaTargetNameSpace, xmlSchemaComplexType.getName()),
xmlSchemaComplexType);
addContentToMethodSchemaType(xmlSchemaSequence,
@@ -1371,7 +1368,7 @@ public class DefaultSchemaGenerator impl
QName schemaTypeName,
String paraName,
boolean isArray) {
- XmlSchemaElement elt1 = new XmlSchemaElement();
+ XmlSchemaElement elt1 = new XmlSchemaElement(getXmlSchema(schemaTargetNameSpace), false);
elt1.setName(paraName);
elt1.setSchemaTypeName(schemaTypeName);
@@ -1424,11 +1421,10 @@ public class DefaultSchemaGenerator impl
XmlSchemaComplexType complexType = getComplexTypeForElement(xmlSchema, elementName);
if (complexType == null) {
- complexType = new XmlSchemaComplexType(xmlSchema);
+ complexType = new XmlSchemaComplexType(xmlSchema, false);
- XmlSchemaElement globalElement = new XmlSchemaElement();
+ XmlSchemaElement globalElement = new XmlSchemaElement(xmlSchema, false);
globalElement.setName(localPartName);
- globalElement.setQName(elementName);
boolean disallowAnonTypes = isAnonymousTypesDisallowed();
if (disallowAnonTypes) {
@@ -1437,13 +1433,13 @@ public class DefaultSchemaGenerator impl
complexType.setName(complexTypeName);
globalElement.setSchemaTypeName(complexType.getQName());
xmlSchema.getItems().add(complexType);
- xmlSchema.getSchemaTypes().add(complexType.getQName(), complexType);
+ xmlSchema.getSchemaTypes().put(complexType.getQName(), complexType);
} else {
globalElement.setSchemaType(complexType);
}
xmlSchema.getItems().add(globalElement);
- xmlSchema.getElements().add(elementName, globalElement);
+ xmlSchema.getElements().put(elementName, globalElement);
}
typeTable.addComplexSchema(localPartName, elementName);
@@ -1457,24 +1453,23 @@ public class DefaultSchemaGenerator impl
XmlSchemaComplexType complexType = getComplexTypeForElement(xmlSchema, elementName);
if (complexType == null) {
- complexType = new XmlSchemaComplexType(xmlSchema);
+ complexType = new XmlSchemaComplexType(xmlSchema, false);
- XmlSchemaElement globalElement = new XmlSchemaElement();
+ XmlSchemaElement globalElement = new XmlSchemaElement(xmlSchema, false);
globalElement.setName(localPartName);
- globalElement.setQName(elementName);
boolean disallowAnonTypes = isAnonymousTypesDisallowed();
if (disallowAnonTypes) {
complexType.setName(localPartName);
globalElement.setSchemaTypeName(complexType.getQName());
xmlSchema.getItems().add(complexType);
- xmlSchema.getSchemaTypes().add(complexType.getQName(), complexType);
+ xmlSchema.getSchemaTypes().put(complexType.getQName(), complexType);
} else {
globalElement.setSchemaType(complexType);
}
xmlSchema.getItems().add(globalElement);
- xmlSchema.getElements().add(elementName, globalElement);
+ xmlSchema.getElements().put(elementName, globalElement);
}
return complexType;
@@ -1499,13 +1494,11 @@ public class DefaultSchemaGenerator impl
}
protected XmlSchemaComplexType getComplexTypeForElement(XmlSchema xmlSchema, QName name) {
-
- Iterator<?> iterator = xmlSchema.getItems().getIterator();
- while (iterator.hasNext()) {
- XmlSchemaObject object = (XmlSchemaObject) iterator.next();
+
+ for (XmlSchemaObject object : xmlSchema.getItems()) {
if (object instanceof XmlSchemaElement && ((XmlSchemaElement) object).getQName().equals(name)) {
XmlSchemaComplexType xmlSchemaComplexType = (XmlSchemaComplexType) ((XmlSchemaElement) object).getSchemaType();
- if ((xmlSchemaComplexType == null) && (((XmlSchemaElement) object).getSchemaTypeName() != null)){
+ if ((xmlSchemaComplexType == null) && (((XmlSchemaElement) object).getSchemaTypeName() != null)) {
xmlSchemaComplexType =
(XmlSchemaComplexType) xmlSchema.getTypeByName(((XmlSchemaElement) object).getSchemaTypeName());
}
@@ -1576,9 +1569,11 @@ public class DefaultSchemaGenerator impl
}
if (map instanceof NamespaceMap && !((NamespaceMap) map).values().
contains(schemaTypeName.getNamespaceURI())) {
- XmlSchemaImport importElement = new XmlSchemaImport();
+ XmlSchemaImport importElement = new XmlSchemaImport(xmlSchema);
importElement.setNamespace(schemaTypeName.getNamespaceURI());
- xmlSchema.getItems().add(importElement);
+ if (!xmlSchema.getItems().contains(importElement)) {
+ xmlSchema.getItems().add(importElement);
+ }
((NamespaceMap) xmlSchema.getNamespaceContext()).
put(generatePrefix(), schemaTypeName.getNamespaceURI());
}
@@ -1602,17 +1597,17 @@ public class DefaultSchemaGenerator impl
protected XmlSchemaForm getAttrFormDefaultSetting() {
if (FORM_DEFAULT_UNQUALIFIED.equals(getAttrFormDefault())) {
- return new XmlSchemaForm(XmlSchemaForm.UNQUALIFIED);
+ return XmlSchemaForm.schemaValueOf(FORM_DEFAULT_UNQUALIFIED);
} else {
- return new XmlSchemaForm(XmlSchemaForm.QUALIFIED);
+ return XmlSchemaForm.schemaValueOf(FORM_DEFAULT_QUALIFIED);
}
}
protected XmlSchemaForm getElementFormDefaultSetting() {
if (FORM_DEFAULT_UNQUALIFIED.equals(getElementFormDefault())) {
- return new XmlSchemaForm(XmlSchemaForm.UNQUALIFIED);
+ return XmlSchemaForm.schemaValueOf(FORM_DEFAULT_UNQUALIFIED);
} else {
- return new XmlSchemaForm(XmlSchemaForm.QUALIFIED);
+ return XmlSchemaForm.schemaValueOf(FORM_DEFAULT_QUALIFIED);
}
}
@@ -1810,7 +1805,7 @@ public class DefaultSchemaGenerator impl
String targetNamespacePrefix = targetNamespacePrefixMap
.get(Constants.AXIS2_MAP_NAMESPACE_URI);
- XmlSchemaComplexType entryType = new XmlSchemaComplexType(xmlSchema);
+ XmlSchemaComplexType entryType = new XmlSchemaComplexType(xmlSchema, false);
QName entryTypeName = new QName(Constants.AXIS2_MAP_NAMESPACE_URI,
entryName, targetNamespacePrefix);
XmlSchemaSequence entrySequence = new XmlSchemaSequence();
@@ -1822,15 +1817,14 @@ public class DefaultSchemaGenerator impl
entryType.setName(entryName);
xmlSchema.getItems().add(entryType);
- XmlSchemaElement entryElement = new XmlSchemaElement();
+ XmlSchemaElement entryElement = new XmlSchemaElement(xmlSchema, false);
entryElement.setName(Constants.MAP_ENTRY_ELEMENT_NAME);
entryElement.setNillable(true);
entryElement.setSchemaTypeName(entryTypeName);
entryElement.setMaxOccurs(Long.MAX_VALUE);
entryElement.setMinOccurs(0);
- entryElement.setQName(entryTypeName);
- XmlSchemaComplexType mapType = new XmlSchemaComplexType(xmlSchema);
+ XmlSchemaComplexType mapType = new XmlSchemaComplexType(xmlSchema, false);
QName mapTypeName = new QName(Constants.AXIS2_MAP_NAMESPACE_URI,
mapName, targetNamespacePrefix);
XmlSchemaSequence mapSequence = new XmlSchemaSequence();
@@ -1844,8 +1838,7 @@ public class DefaultSchemaGenerator impl
addImport(getXmlSchema(schemaTargetNameSpace), schemaTypeName);
if (sequence != null) {
- XmlSchemaComplexType parameterType = new XmlSchemaComplexType(
- xmlSchema);
+ XmlSchemaComplexType parameterType = new XmlSchemaComplexType(xmlSchema, false);
QName parameterTypeName = new QName(
Constants.AXIS2_MAP_NAMESPACE_URI, mapName,
targetNamespacePrefix);
@@ -1853,7 +1846,7 @@ public class DefaultSchemaGenerator impl
parameterSequence.getItems().add(entryElement);
parameterType.setParticle(parameterSequence);
- XmlSchemaElement parameterElement = new XmlSchemaElement();
+ XmlSchemaElement parameterElement = new XmlSchemaElement(xmlSchema, false);
parameterElement.setName(parameterName);
parameterElement.setMinOccurs(0);
parameterElement.setNillable(true);
@@ -1940,7 +1933,7 @@ public class DefaultSchemaGenerator impl
.isAssignableFrom((Class<?>) innerParameterizedType
.getRawType())) {
XmlSchemaComplexType xmlSchemaComplexType = new XmlSchemaComplexType(
- xmlSchema);
+ xmlSchema, false);
XmlSchemaSequence xmlSchemaSequence = new XmlSchemaSequence();
xmlSchemaComplexType.setParticle(xmlSchemaSequence);
generateWrappedSchemaTypeForCollection(
@@ -1948,7 +1941,7 @@ public class DefaultSchemaGenerator impl
"array");
xmlSchemaComplexType.setName(simpleTypeName);
xmlSchema.getItems().add(xmlSchemaComplexType);
- xmlSchema.getSchemaTypes().add(
+ xmlSchema.getSchemaTypes().put(
new QName(xmlSchema.getTargetNamespace(),
simpleTypeName), xmlSchemaComplexType);
@@ -2069,22 +2062,21 @@ public class DefaultSchemaGenerator impl
XmlSchemaType schemaType = xmlSchema.getTypeByName(entryName);
if (schemaType == null) {
- XmlSchemaComplexType entryType = new XmlSchemaComplexType(xmlSchema);
+ XmlSchemaComplexType entryType = new XmlSchemaComplexType(xmlSchema, false);
XmlSchemaSequence entrySequence = new XmlSchemaSequence();
XmlSchemaAny any = new XmlSchemaAny();
entrySequence.getItems().add(any);
entryType.setParticle(entrySequence);
entryType.setName(entryName.getLocalPart());
xmlSchema.getItems().add(entryType);
- xmlSchema.getSchemaTypes().add(entryName, entryType);
+ xmlSchema.getSchemaTypes().put(entryName, entryType);
schemaType = entryType;
}
- XmlSchemaElement entryElement = new XmlSchemaElement();
+ XmlSchemaElement entryElement = new XmlSchemaElement(xmlSchema, false);
entryElement.setName(parameterName);
entryElement.setSchemaTypeName(schemaType.getQName());
- entryElement.setQName(schemaType.getQName());
entryElement.setMinOccurs(0);
entryElement.setNillable(true);
if (sequence != null) {
@@ -2134,7 +2126,7 @@ public class DefaultSchemaGenerator impl
enumClass, targetNamespacePrefix);
// check weather this enum class have already added to schema
if(typeTable.getSimpleTypeEnum(classType.getName())==null){
- XmlSchemaSimpleType simpleType = new XmlSchemaSimpleType(xmlSchema);
+ XmlSchemaSimpleType simpleType = new XmlSchemaSimpleType(xmlSchema, false);
simpleType.setName(enumClass);
XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction();
restriction.setBaseTypeName(Constants.XSD_STRING);
@@ -2148,17 +2140,15 @@ public class DefaultSchemaGenerator impl
}
- XmlSchemaElement entryElement = new XmlSchemaElement();
+ XmlSchemaElement entryElement = new XmlSchemaElement(xmlSchema, false);
entryElement.setName(Constants.ENUM_ELEMENT_NAME);
entryElement.setNillable(true);
entryElement.setSchemaTypeName(enumQname);
- entryElement.setQName(enumQname);
QName schemaTypeName = new QName(Constants.AXIS2_ENUM_NAMESPACE_URI,
enumClass);
addImport(getXmlSchema(schemaTargetNameSpace), schemaTypeName);
if (sequence != null) {
- XmlSchemaComplexType parameterType = new XmlSchemaComplexType(
- xmlSchema);
+ XmlSchemaComplexType parameterType = new XmlSchemaComplexType(xmlSchema, false);
QName parameterTypeName = new QName(
Constants.AXIS2_ENUM_NAMESPACE_URI, enumClass,
targetNamespacePrefix);
@@ -2166,7 +2156,7 @@ public class DefaultSchemaGenerator impl
parameterSequence.getItems().add(entryElement);
parameterType.setParticle(parameterSequence);
- XmlSchemaElement parameterElement = new XmlSchemaElement();
+ XmlSchemaElement parameterElement = new XmlSchemaElement(xmlSchema, false);
parameterElement.setName(parameterName);
if(isArrayType){
parameterElement.setMaxOccurs(Long.MAX_VALUE);
Modified: axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/java2wsdl/DocLitBareSchemaGenerator.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/java2wsdl/DocLitBareSchemaGenerator.java?rev=1536050&r1=1536049&r2=1536050&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/java2wsdl/DocLitBareSchemaGenerator.java (original)
+++ axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/java2wsdl/DocLitBareSchemaGenerator.java Sun Oct 27 05:48:34 2013
@@ -65,10 +65,10 @@ public class DocLitBareSchemaGenerator e
protected Method[] processMethods(Method[] declaredMethods) throws Exception {
ArrayList<Method> list = new ArrayList<Method>();
//short the elements in the array
- Arrays.sort(declaredMethods , new MathodComparator());
+ Arrays.sort(declaredMethods, new MathodComparator());
// since we do not support overload
- HashMap<String,Method> uniqueMethods = new LinkedHashMap<String,Method>();
+ HashMap<String, Method> uniqueMethods = new LinkedHashMap<String, Method>();
XmlSchemaComplexType methodSchemaType;
XmlSchemaSequence sequence;
@@ -85,11 +85,11 @@ public class DocLitBareSchemaGenerator e
if (uniqueMethods.get(methodName) != null) {
log.warn("We don't support method overloading. Ignoring [" +
- methodName + "]");
+ methodName + "]");
continue;
}
- if (!Modifier.isPublic(jMethod.getModifiers())) {
+ if (!Modifier.isPublic(jMethod.getModifiers())) {
// no need to generate Schema for non public methods
continue;
}
@@ -99,10 +99,10 @@ public class DocLitBareSchemaGenerator e
if (axisOperation == null) {
axisOperation = Utils.getAxisOperationForJmethod(jMethod);
if (WSDL2Constants.MEP_URI_ROBUST_IN_ONLY.equals(
- axisOperation.getMessageExchangePattern())){
+ axisOperation.getMessageExchangePattern())) {
AxisMessage outMessage = axisOperation.getMessage(
WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
- if (outMessage !=null ){
+ if (outMessage != null) {
outMessage.setName(methodName + RESULT);
}
}
@@ -111,7 +111,7 @@ public class DocLitBareSchemaGenerator e
// Maintain a list of methods we actually work with
list.add(jMethod);
- processException(jMethod,axisOperation);
+ processException(jMethod, axisOperation);
uniqueMethods.put(methodName, jMethod);
//create the schema type for the method wrapper
@@ -130,12 +130,12 @@ public class DocLitBareSchemaGenerator e
methodSchemaType.setParticle(sequence);
inMessage.setElementQName(typeTable.getQNamefortheType(methodName));
service.addMessageElementQNameToOperationMapping(methodSchemaType.getQName(),
- axisOperation);
+ axisOperation);
inMessage.setPartName(methodName);
for (int j = 0; j < paras.length; j++) {
Class<?> methodParameter = paras[j];
String parameterName = getParameterName(parameterAnnotation, j, parameterNames);
- if (generateRequestSchema(methodParameter , parameterName,jMethod, sequence, genericParameterTypes[j])) {
+ if (generateRequestSchema(methodParameter, parameterName, jMethod, sequence, genericParameterTypes[j])) {
break;
}
}
@@ -148,10 +148,10 @@ public class DocLitBareSchemaGenerator e
Class<?> methodParameter = paras[0];
inMessage.setElementQName(typeTable.getQNamefortheType(methodName));
service.addMessageElementQNameToOperationMapping(methodSchemaType.getQName(),
- axisOperation);
+ axisOperation);
inMessage.setPartName(methodName);
String parameterName = getParameterName(parameterAnnotation, 0, parameterNames);
- if (generateRequestSchema(methodParameter , parameterName,jMethod, sequence, genericParameterTypes[0])) {
+ if (generateRequestSchema(methodParameter, parameterName, jMethod, sequence, genericParameterTypes[0])) {
break;
}
} else {
@@ -160,35 +160,35 @@ public class DocLitBareSchemaGenerator e
Method processMethod = processedParameters.get(parameterName);
if (processMethod != null) {
throw new AxisFault("Inavalid Java class," +
- " there are two methods [" + processMethod.getName() + " and " +
- jMethod.getName() + " ]which have the same parameter names");
+ " there are two methods [" + processMethod.getName() + " and " +
+ jMethod.getName() + " ]which have the same parameter names");
} else {
processedParameters.put(parameterName, jMethod);
- if (methodParameter != null && Map.class.isAssignableFrom(methodParameter)){
- generateBareSchemaTypeForMap(parameterName, genericParameterTypes[0], null);
-
+ if (methodParameter != null && Map.class.isAssignableFrom(methodParameter)) {
+ generateBareSchemaTypeForMap(parameterName, genericParameterTypes[0], null);
+
} else if (methodParameter != null
- && Collection.class
- .isAssignableFrom(methodParameter)) {
-
+ && Collection.class
+ .isAssignableFrom(methodParameter)) {
+
sequence = new XmlSchemaSequence();
methodSchemaType = createSchemaTypeForMethodPart(methodName);
methodSchemaType.setParticle(sequence);
generateBareSchemaTypeForCollection(sequence,
- genericParameterTypes[0], parameterName,
- methodName);
+ genericParameterTypes[0], parameterName,
+ methodName);
parameterName = methodName;
- } else if (methodParameter != null && Document.class.isAssignableFrom(methodParameter)){
- generateBareSchemaTypeForDocument(null, parameterName);
+ } else if (methodParameter != null && Document.class.isAssignableFrom(methodParameter)) {
+ generateBareSchemaTypeForDocument(null, parameterName);
} else {
- generateSchemaForType(null, methodParameter, parameterName);
- }
+ generateSchemaForType(null, methodParameter, parameterName);
+ }
inMessage.setElementQName(typeTable.getQNamefortheType(parameterName));
inMessage.setPartName(parameterName);
inMessage.setWrapped(false);
service.addMessageElementQNameToOperationMapping(typeTable.getQNamefortheType(parameterName),
- axisOperation);
+ axisOperation);
}
}
}
@@ -213,23 +213,23 @@ public class DocLitBareSchemaGenerator e
generateSchemaForType(sequence, returnType, returnName);
}
} else {
- if(returnType != null && Document.class.isAssignableFrom(returnType)) {
- generateBareSchemaTypeForDocument(null, methodTypeName);
-
- } else if (returnType != null && Map.class.isAssignableFrom(returnType)){
- generateBareSchemaTypeForMap(methodTypeName, genericReturnType, null);
-
- } else if (returnType != null
- && Collection.class.isAssignableFrom(returnType)) {
- sequence = new XmlSchemaSequence();
- methodSchemaType = createSchemaTypeForMethodPart(methodTypeName);
- methodSchemaType.setParticle(sequence);
- generateBareSchemaTypeForCollection(sequence,
- genericReturnType, returnName, methodName);
-
- } else {
- generateSchemaForType(null, returnType, methodTypeName);
- }
+ if (returnType != null && Document.class.isAssignableFrom(returnType)) {
+ generateBareSchemaTypeForDocument(null, methodTypeName);
+
+ } else if (returnType != null && Map.class.isAssignableFrom(returnType)) {
+ generateBareSchemaTypeForMap(methodTypeName, genericReturnType, null);
+
+ } else if (returnType != null
+ && Collection.class.isAssignableFrom(returnType)) {
+ sequence = new XmlSchemaSequence();
+ methodSchemaType = createSchemaTypeForMethodPart(methodTypeName);
+ methodSchemaType.setParticle(sequence);
+ generateBareSchemaTypeForCollection(sequence,
+ genericReturnType, returnName, methodName);
+
+ } else {
+ generateSchemaForType(null, returnType, methodTypeName);
+ }
outMessage.setWrapped(false);
}
outMessage.setElementQName(typeTable.getQNamefortheType(methodTypeName));
@@ -325,15 +325,14 @@ public class DocLitBareSchemaGenerator e
protected void generateSchemaForSingleElement(QName schemaTypeName,
String paraName,
boolean isArray) throws Exception {
- XmlSchemaElement elt1 = new XmlSchemaElement();
+ XmlSchemaElement elt1 = new XmlSchemaElement(getXmlSchema(schemaTargetNameSpace), false);
elt1.setName(paraName);
elt1.setSchemaTypeName(schemaTypeName);
elt1.setNillable(true);
QName elementName =
new QName(schemaTargetNameSpace, paraName, schema_namespace_prefix);
- elt1.setQName(elementName);
XmlSchema xmlSchema = getXmlSchema(schemaTargetNameSpace);
- xmlSchema.getElements().add(elementName, elt1);
+ xmlSchema.getElements().put(elementName, elt1);
xmlSchema.getItems().add(elt1);
typeTable.addComplexSchema(paraName, elementName);
}
@@ -341,7 +340,7 @@ public class DocLitBareSchemaGenerator e
/**
* Generate schema construct for given type
*
- * @param javaType
+ * @param localPartName
*/
private XmlSchemaComplexType createSchemaTypeForMethodPart(String localPartName) {
XmlSchema xmlSchema = getXmlSchema(schemaTargetNameSpace);
@@ -350,14 +349,13 @@ public class DocLitBareSchemaGenerator e
XmlSchemaComplexType complexType = getComplexTypeForElement(xmlSchema, elementName);
if (complexType == null) {
- complexType = new XmlSchemaComplexType(xmlSchema);
+ complexType = new XmlSchemaComplexType(xmlSchema, false);
- XmlSchemaElement globalElement = new XmlSchemaElement();
+ XmlSchemaElement globalElement = new XmlSchemaElement(xmlSchema, false);
globalElement.setSchemaType(complexType);
globalElement.setName(localPartName);
- globalElement.setQName(elementName);
xmlSchema.getItems().add(globalElement);
- xmlSchema.getElements().add(elementName, globalElement);
+ xmlSchema.getElements().put(elementName, globalElement);
}
typeTable.addComplexSchema(localPartName, elementName);
@@ -412,15 +410,14 @@ public class DocLitBareSchemaGenerator e
if (sequence != null) {
return;
}
- XmlSchemaElement elt1 = new XmlSchemaElement();
+ XmlSchema xmlSchema = getXmlSchema(schemaTargetNameSpace);
+ XmlSchemaElement elt1 = new XmlSchemaElement(xmlSchema, false);
elt1.setSchemaTypeName(schemaTypeName);
elt1.setName(paraName);
elt1.setNillable(true);
QName elementName = new QName(schemaTargetNameSpace, paraName,
schema_namespace_prefix);
- elt1.setQName(elementName);
- XmlSchema xmlSchema = getXmlSchema(schemaTargetNameSpace);
- xmlSchema.getElements().add(elementName, elt1);
+ xmlSchema.getElements().put(elementName, elt1);
xmlSchema.getItems().add(elt1);
typeTable.addComplexSchema(paraName, elementName);
@@ -457,15 +454,14 @@ public class DocLitBareSchemaGenerator e
if (sequence != null) {
return;
}
- XmlSchemaElement elt1 = new XmlSchemaElement();
+ XmlSchema xmlSchema = getXmlSchema(schemaTargetNameSpace);
+ XmlSchemaElement elt1 = new XmlSchemaElement(xmlSchema, false);
elt1.setSchemaTypeName(schemaTypeName);
elt1.setName(parameterName);
elt1.setNillable(true);
QName elementName = new QName(schemaTargetNameSpace, parameterName,
schema_namespace_prefix);
- elt1.setQName(elementName);
- XmlSchema xmlSchema = getXmlSchema(schemaTargetNameSpace);
- xmlSchema.getElements().add(elementName, elt1);
+ xmlSchema.getElements().put(elementName, elt1);
xmlSchema.getItems().add(elt1);
typeTable.addComplexSchema(parameterName, elementName);
Modified: axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/util/SchemaUtil.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/util/SchemaUtil.java?rev=1536050&r1=1536049&r2=1536050&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/util/SchemaUtil.java (original)
+++ axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/util/SchemaUtil.java Sun Oct 27 05:48:34 2013
@@ -22,12 +22,11 @@ package org.apache.axis2.util;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaExternal;
import org.apache.ws.commons.schema.XmlSchemaImport;
import org.apache.ws.commons.schema.XmlSchemaInclude;
-import org.apache.ws.commons.schema.XmlSchemaObjectCollection;
import java.util.HashMap;
-import java.util.Iterator;
/**
*
@@ -49,22 +48,17 @@ public class SchemaUtil {
}
map.put(key, schema);
- XmlSchemaObjectCollection includes = schema.getIncludes();
- if (includes != null) {
- Iterator tempIterator = includes.getIterator();
- while (tempIterator.hasNext()) {
- Object o = tempIterator.next();
- if (o instanceof XmlSchemaImport) {
- XmlSchema schema1 = ((XmlSchemaImport) o).getSchema();
- if (schema1 != null) {
- traverseSchemas(schema1, map);
- }
+ for (XmlSchemaExternal external : schema.getExternals()) {
+ if (external instanceof XmlSchemaImport) {
+ XmlSchema schema1 = external.getSchema();
+ if (schema1 != null) {
+ traverseSchemas(schema1, map);
}
- if (o instanceof XmlSchemaInclude) {
- XmlSchema schema1 = ((XmlSchemaInclude) o).getSchema();
- if (schema1 != null) {
- traverseSchemas(schema1, map);
- }
+ }
+ if (external instanceof XmlSchemaInclude) {
+ XmlSchema schema1 = external.getSchema();
+ if (schema1 != null) {
+ traverseSchemas(schema1, map);
}
}
}
Modified: axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/AxisServiceTest.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/AxisServiceTest.java?rev=1536050&r1=1536049&r2=1536050&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/AxisServiceTest.java (original)
+++ axis/axis2/java/core/trunk/modules/kernel/test/org/apache/axis2/description/AxisServiceTest.java Sun Oct 27 05:48:34 2013
@@ -19,17 +19,6 @@
package org.apache.axis2.description;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.io.ObjectOutputStream;
-import java.util.ArrayList;
-
-import javax.xml.namespace.QName;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.transform.stream.StreamSource;
-
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.context.ServiceContext;
@@ -44,6 +33,16 @@ import org.apache.ws.commons.schema.XmlS
import org.w3c.dom.ls.DOMImplementationLS;
import org.w3c.dom.ls.LSSerializer;
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.stream.StreamSource;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.ObjectOutputStream;
+import java.util.ArrayList;
+
public class AxisServiceTest extends XMLSchemaTest {
public static final String PARAM_NAME = "CustomParameter";
public static final Object PARAM_VALUE = new Object();
@@ -256,7 +255,7 @@ public class AxisServiceTest extends XML
public void testPrintXSD() throws Exception {
InputStream is = new FileInputStream(SampleSchemasDirectory + "sampleSchema1.xsd");
XmlSchemaCollection schemaCol = new XmlSchemaCollection();
- XmlSchema schema = schemaCol.read(new StreamSource(is), null);
+ XmlSchema schema = schemaCol.read(new StreamSource(is));
ByteArrayOutputStream stream = new ByteArrayOutputStream();
ArrayList<XmlSchema> xmlSchemas = new ArrayList<XmlSchema>();
xmlSchemas.add(schema);