You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by de...@apache.org on 2007/06/29 19:07:28 UTC
svn commit: r551961 - in
/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description:
AxisOperation.java java2wsdl/DefaultSchemaGenerator.java
java2wsdl/DocLitBareSchemaGenerator.java java2wsdl/TypeTable.java
Author: deepal
Date: Fri Jun 29 10:07:28 2007
New Revision: 551961
URL: http://svn.apache.org/viewvc?view=rev&rev=551961
Log:
seems like I have done a mistake in previous change.
- when a method throws two or more my changed failed to handle
Modified:
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisOperation.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/java2wsdl/DefaultSchemaGenerator.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/java2wsdl/DocLitBareSchemaGenerator.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/java2wsdl/TypeTable.java
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=551961&r1=551960&r2=551961
==============================================================================
--- 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 Fri Jun 29 10:07:28 2007
@@ -509,7 +509,10 @@
public void setFaultMessages(AxisMessage faultMessage) {
faultMessages.add(faultMessage);
- addFaultAction(faultMessage.getName(),"urn:" + faultMessage.getName());
+ if(getFaultAction(faultMessage.getName())==null){
+ addFaultAction(faultMessage.getName(),"urn:" + name.getLocalPart()
+ + faultMessage.getName());
+ }
}
public void setSoapAction(String soapAction) {
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/java2wsdl/DefaultSchemaGenerator.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/java2wsdl/DefaultSchemaGenerator.java?view=diff&rev=551961&r1=551960&r2=551961
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/java2wsdl/DefaultSchemaGenerator.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/java2wsdl/DefaultSchemaGenerator.java Fri Jun 29 10:07:28 2007
@@ -231,48 +231,7 @@
// Maintain a list of methods we actually work with
list.add(jMethod);
- if (jMethod.getExceptionTypes().length > 0) {
- JClass[] extypes = jMethod.getExceptionTypes();
- for (int j = 0; j < extypes.length; j++) {
- JClass extype = extypes[j];
- if (AxisFault.class.getName().equals(extype.getQualifiedName())) {
- continue;
- }
- if (!generateBaseException) {
- methodSchemaType = createSchemaTypeForMethodPart("Exception");
- sequence = new XmlSchemaSequence();
- QName schemaTypeName = typeTable.getSimpleSchemaTypeName(Exception.class.getName());
- addContentToMethodSchemaType(sequence,
- schemaTypeName,
- "Exception",
- false);
- methodSchemaType.setParticle(sequence);
- generateBaseException = true;
- }
- String partQname = extype.getSimpleName();
- methodSchemaType = createSchemaTypeForMethodPart(partQname);
- sequence = new XmlSchemaSequence();
- if (Exception.class.getName().equals(extype.getQualifiedName())) {
- addContentToMethodSchemaType(sequence,
- typeTable.getComplexSchemaType("Exception"),
- partQname,
- false);
- methodSchemaType.setParticle(sequence);
- typeTable.addComplexSchema(Exception.class.getPackage().getName(),
- methodSchemaType.getQName());
- } else {
- generateSchemaForType(sequence, extype, extype.getSimpleName());
- methodSchemaType.setParticle(sequence);
- }
- if (AxisFault.class.getName().equals(extype.getQualifiedName())) {
- continue;
- }
- AxisMessage faultMessage = new AxisMessage();
- faultMessage.setName(extype.getSimpleName());
- faultMessage.setElementQName(typeTable.getQNamefortheType(partQname));
- axisOperation.setFaultMessages(faultMessage);
- }
- }
+ processException(jMethod,axisOperation);
uniqueMethods.put(methodName, jMethod);
JParameter[] paras = jMethod.getParameters();
String parameterNames[] = null;
@@ -350,6 +309,72 @@
}
/**
+ * This method will generate Schema element for all the excetion types in a given JMethod
+ * - No matter what it will generate Schema element for java.lang.Exception so that for other
+ * exception which extend java.lang.Excetion can use as the base class type
+ */
+ protected void processException(JMethod jMethod,
+ AxisOperation axisOperation) throws Exception {
+ XmlSchemaComplexType methodSchemaType;
+ XmlSchemaSequence sequence;
+ if (jMethod.getExceptionTypes().length > 0) {
+ if (!generateBaseException) {
+ sequence = new XmlSchemaSequence();
+ XmlSchema xmlSchema = getXmlSchema(schemaTargetNameSpace);
+ QName elementName = new QName(schemaTargetNameSpace,
+ "Exception",
+ schema_namespace_prefix);
+ XmlSchemaComplexType complexType = new XmlSchemaComplexType(xmlSchema);
+ complexType.setName("Exception");
+ xmlSchema.getItems().add(complexType);
+ xmlSchema.getElements().add(elementName, complexType);
+ typeTable.addComplexSchema(Exception.class.getName(), elementName);
+ QName schemaTypeName = TypeTable.ANY_TYPE;
+ addContentToMethodSchemaType(sequence,
+ schemaTypeName,
+ "Exception",
+ false);
+ complexType.setParticle(sequence);
+ generateBaseException = true;
+ }
+ JClass[] extypes = jMethod.getExceptionTypes();
+ for (int j = 0; j < extypes.length; j++) {
+ JClass extype = extypes[j];
+ if (AxisFault.class.getName().equals(extype.getQualifiedName())) {
+ continue;
+ }
+ String partQname = extype.getSimpleName();
+ methodSchemaType = createSchemaTypeForFault(partQname);
+ QName elementName =
+ new QName(this.schemaTargetNameSpace, partQname, this.schema_namespace_prefix);
+ sequence = new XmlSchemaSequence();
+ if (Exception.class.getName().equals(extype.getQualifiedName())) {
+ addContentToMethodSchemaType(sequence,
+ typeTable.getComplexSchemaType(Exception.class.getName()),
+ partQname,
+ false);
+ methodSchemaType.setParticle(sequence);
+ typeTable.addComplexSchema(Exception.class.getPackage().getName(),
+ methodSchemaType.getQName());
+ } else {
+ generateSchemaForType(sequence, extype, extype.getSimpleName());
+ methodSchemaType.setParticle(sequence);
+ }
+
+ typeTable.addComplexSchema(partQname,elementName);
+
+ if (AxisFault.class.getName().equals(extype.getQualifiedName())) {
+ continue;
+ }
+ AxisMessage faultMessage = new AxisMessage();
+ faultMessage.setName(extype.getSimpleName());
+ faultMessage.setElementQName(typeTable.getQNamefortheType(partQname));
+ axisOperation.setFaultMessages(faultMessage);
+ }
+ }
+ }
+
+ /**
* JAM convert first name of an attribute into UpperCase as an example if there is a instance
* variable called foo in a bean , then Jam give that as Foo so this method is to correct that
* error
@@ -413,7 +438,11 @@
tgtNamespace =
resolveSchemaNamespace(sup.getContainingPackage().getQualifiedName());
tgtNamespacepfx = (String) targetNamespacePrefixMap.get(tgtNamespace);
- generateSchema(sup);
+ QName superClassQname = generateSchema(sup);
+ if(superClassQname!=null){
+ tgtNamespacepfx = superClassQname.getPrefix();
+ tgtNamespace = superClassQname.getNamespaceURI();
+ }
}
if (tgtNamespacepfx == null) {
@@ -465,7 +494,6 @@
Arrays.sort(properties);
for (int i = 0; i < properties.length; i++) {
JProperty property = properties[i];
- String propertyName = getQualifiedName(property.getType());
boolean isArryType = property.getType().isArrayType();
String propname = getCorrectName(property.getSimpleName());
@@ -671,6 +699,25 @@
}
typeTable.addComplexSchema(localPartName, elementName);
+ return complexType;
+ }
+
+ private XmlSchemaComplexType createSchemaTypeForFault(String localPartName) {
+ XmlSchema xmlSchema = getXmlSchema(schemaTargetNameSpace);
+ QName elementName =
+ new QName(this.schemaTargetNameSpace, localPartName, this.schema_namespace_prefix);
+
+ XmlSchemaComplexType complexType = getComplexTypeForElement(xmlSchema, elementName);
+ if (complexType == null) {
+ complexType = new XmlSchemaComplexType(xmlSchema);
+
+ XmlSchemaElement globalElement = new XmlSchemaElement();
+ globalElement.setSchemaType(complexType);
+ globalElement.setName(localPartName);
+ globalElement.setQName(elementName);
+ xmlSchema.getItems().add(globalElement);
+ xmlSchema.getElements().add(elementName, globalElement);
+ }
return complexType;
}
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/java2wsdl/DocLitBareSchemaGenerator.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/java2wsdl/DocLitBareSchemaGenerator.java?view=diff&rev=551961&r1=551960&r2=551961
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/java2wsdl/DocLitBareSchemaGenerator.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/java2wsdl/DocLitBareSchemaGenerator.java Fri Jun 29 10:07:28 2007
@@ -91,49 +91,7 @@
// Maintain a list of methods we actually work with
list.add(jMethod);
-
- if (jMethod.getExceptionTypes().length > 0) {
- JClass[] extypes = jMethod.getExceptionTypes();
- for (int j = 0; j < extypes.length; j++) {
- JClass extype = extypes[j];
- if (AxisFault.class.getName().equals(extype.getQualifiedName())) {
- continue;
- }
- if (!generateBaseException) {
- methodSchemaType = createSchemaTypeForMethodPart("Exception");
- sequence = new XmlSchemaSequence();
- QName schemaTypeName = typeTable.getSimpleSchemaTypeName(Exception.class.getName());
- addContentToMethodSchemaType(sequence,
- schemaTypeName,
- "Exception",
- false);
- methodSchemaType.setParticle(sequence);
- generateBaseException = true;
- }
- String partQname = extype.getSimpleName();
- methodSchemaType = createSchemaTypeForMethodPart(partQname);
- sequence = new XmlSchemaSequence();
- if (Exception.class.getName().equals(extype.getQualifiedName())) {
- addContentToMethodSchemaType(sequence,
- typeTable.getComplexSchemaType("Exception"),
- partQname,
- false);
- methodSchemaType.setParticle(sequence);
- typeTable.addComplexSchema(Exception.class.getPackage().getName(),
- methodSchemaType.getQName());
- } else {
- generateSchemaForType(sequence, extype, extype.getSimpleName());
- methodSchemaType.setParticle(sequence);
- }
- if (AxisFault.class.getName().equals(extype.getQualifiedName())) {
- continue;
- }
- AxisMessage faultMessage = new AxisMessage();
- faultMessage.setName(extype.getSimpleName());
- faultMessage.setElementQName(typeTable.getQNamefortheType(partQname));
- axisOperation.setFaultMessages(faultMessage);
- }
- }
+ processException(jMethod,axisOperation);
uniqueMethods.put(getSimpleName(jMethod), jMethod);
//create the schema type for the method wrapper
@@ -388,7 +346,11 @@
tgtNamespace =
resolveSchemaNamespace(sup.getContainingPackage().getQualifiedName());
tgtNamespacepfx = (String) targetNamespacePrefixMap.get(tgtNamespace);
- generateSchema(sup);
+ QName superClassQname = generateSchema(sup);
+ if(superClassQname!=null){
+ tgtNamespacepfx = superClassQname.getPrefix();
+ tgtNamespace = superClassQname.getNamespaceURI();
+ }
}
if (tgtNamespacepfx == null) {
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/java2wsdl/TypeTable.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/java2wsdl/TypeTable.java?view=diff&rev=551961&r1=551960&r2=551961
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/java2wsdl/TypeTable.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/java2wsdl/TypeTable.java Fri Jun 29 10:07:28 2007
@@ -25,7 +25,7 @@
public class TypeTable {
private static HashMap simpleTypetoxsd;
- private static final QName ANY_TYPE = new QName(Java2WSDLConstants.URI_2001_SCHEMA_XSD, "anyType", "xs");
+ public static final QName ANY_TYPE = new QName(Java2WSDLConstants.URI_2001_SCHEMA_XSD, "anyType", "xs");
private HashMap complexTypeMap;
@@ -134,7 +134,8 @@
public QName getSimpleSchemaTypeName(String typeName) {
QName qName = (QName) simpleTypetoxsd.get(typeName);
if(qName == null){
- if(typeName.startsWith("java.lang")||typeName.startsWith("javax.")){
+ if((typeName.startsWith("java.lang")||typeName.startsWith("javax.")) &&
+ !Exception.class.getName().equals(typeName)){
return ANY_TYPE;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org