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 am...@apache.org on 2007/06/26 06:53:48 UTC
svn commit: r550685 - in /webservices/axis2/trunk/java/modules:
adb-codegen/src/org/apache/axis2/schema/ExtensionUtility.java
codegen/src/org/apache/axis2/wsdl/codegen/extension/SchemaUnwrapperExtension.java
Author: amilas
Date: Mon Jun 25 21:53:47 2007
New Revision: 550685
URL: http://svn.apache.org/viewvc?view=rev&rev=550685
Log:
fixed issues with the document bare unwrap
Modified:
webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/ExtensionUtility.java
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/SchemaUnwrapperExtension.java
Modified: webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/ExtensionUtility.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/ExtensionUtility.java?view=diff&rev=550685&r1=550684&r2=550685
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/ExtensionUtility.java (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/ExtensionUtility.java Mon Jun 25 21:53:47 2007
@@ -11,6 +11,8 @@
import org.apache.axis2.wsdl.util.Constants;
import org.apache.axis2.util.URLProcessor;
import org.apache.axis2.AxisFault;
+import org.apache.axis2.schema.typemap.TypeMap;
+import org.apache.axis2.schema.typemap.JavaTypeMap;
import org.apache.ws.commons.schema.*;
import javax.xml.namespace.QName;
@@ -198,7 +200,29 @@
private static void setComplexTypeName(AxisMessage axisMessage) throws AxisFault {
if (axisMessage.getSchemaElement() != null){
- XmlSchemaType schemaType = axisMessage.getSchemaElement().getSchemaType();
+
+ XmlSchemaElement schemaElement = axisMessage.getSchemaElement();
+ XmlSchemaType schemaType = schemaElement.getSchemaType();
+ QName schemaTypeQname = schemaElement.getSchemaTypeName();
+
+ if (schemaType == null) {
+ if (schemaTypeQname != null) {
+ // find the schema type from all the schemas
+ // now we need to get the schema of the extension type from the parent schema. For that let's first retrieve
+ // the parent schema
+ AxisService axisService = (AxisService) axisMessage.getParent().getParent();
+ ArrayList schemasList = axisService.getSchema();
+ XmlSchema schema = null;
+ for (Iterator iter = schemasList.iterator(); iter.hasNext();) {
+ schema = (XmlSchema) iter.next();
+ schemaType = getSchemaType(schema, schemaTypeQname);
+ if (schemaType != null) {
+ break;
+ }
+ }
+ }
+ }
+
if (schemaType instanceof XmlSchemaComplexType){
XmlSchemaComplexType complexType = (XmlSchemaComplexType) schemaType;
if ((complexType.getName() != null) && (complexType.getQName() != null)) {
@@ -241,10 +265,39 @@
String qnameSuffix) {
if (message.getParameter(Constants.UNWRAPPED_KEY) != null) {
- XmlSchemaType schemaType = message.getSchemaElement().getSchemaType();
+
+ XmlSchemaElement schemaElement = message.getSchemaElement();
+ XmlSchemaType schemaType = schemaElement.getSchemaType();
+ QName schemaTypeQname = schemaElement.getSchemaTypeName();
+
+ if (schemaType == null) {
+ if (schemaTypeQname != null) {
+ // find the schema type from all the schemas
+ // now we need to get the schema of the extension type from the parent schema. For that let's first retrieve
+ // the parent schema
+ AxisService axisService = (AxisService) message.getParent().getParent();
+ ArrayList schemasList = axisService.getSchema();
+
+ XmlSchema schema = null;
+ for (Iterator iter = schemasList.iterator(); iter.hasNext();) {
+ schema = (XmlSchema) iter.next();
+ schemaType = getSchemaType(schema, schemaTypeQname);
+ if (schemaType != null) {
+ break;
+ }
+ }
+ }
+ }
+
//create a type mapper
+ TypeMap basicTypeMap = new JavaTypeMap();
if (schemaType instanceof XmlSchemaComplexType) {
processXMLSchemaComplexType(schemaType, mapper, opName, schemaMap, qnameSuffix);
+ } else if ((schemaTypeQname != null) && basicTypeMap.getTypeMap().containsKey(schemaTypeQname)){
+ QName partQName = WSDLUtil.getPartQName(opName,
+ qnameSuffix,
+ message.getElementQName().getLocalPart());
+ mapper.addTypeMappingName(partQName, (String)basicTypeMap.getTypeMap().get(schemaTypeQname));
} else if (schemaType instanceof XmlSchemaSimpleType) {
XmlSchemaSimpleType xmlSchemaSimpleType = (XmlSchemaSimpleType) schemaType;
populateClassName(xmlSchemaSimpleType.getMetaInfoMap(),
@@ -253,6 +306,7 @@
false,
message.getElementQName().getLocalPart(),
qnameSuffix);
+ // handle xsd:anyType
}
}
Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/SchemaUnwrapperExtension.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/SchemaUnwrapperExtension.java?view=diff&rev=550685&r1=550684&r2=550685
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/SchemaUnwrapperExtension.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/SchemaUnwrapperExtension.java Mon Jun 25 21:53:47 2007
@@ -57,7 +57,7 @@
*/
public void engage(CodeGenConfiguration configuration) throws CodeGenerationException {
this.codeGenConfiguration = configuration;
-
+
if (!configuration.isParametersWrapped()) {
// A check to avoid nasty surprises - Since unwrapping is not
@@ -75,21 +75,21 @@
AxisService axisService;
for (Iterator servicesIter = services.iterator(); servicesIter.hasNext();) {
- axisService = (AxisService)servicesIter.next();
+ axisService = (AxisService) servicesIter.next();
for (Iterator operations = axisService.getOperations();
operations.hasNext();) {
- AxisOperation op = (AxisOperation)operations.next();
+ AxisOperation op = (AxisOperation) operations.next();
if (WSDLUtil.isInputPresentForMEP(op.getMessageExchangePattern())) {
walkSchema(op.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE),
- WSDLConstants.INPUT_PART_QNAME_SUFFIX);
+ WSDLConstants.INPUT_PART_QNAME_SUFFIX);
}
// get the out put parameter details as well to unwrap the responses
//TODO: support xmlbeans
if (configuration.getDatabindingType().equals("adb")) {
if (WSDLUtil.isOutputPresentForMEP(op.getMessageExchangePattern())) {
walkSchema(op.getMessage(WSDLConstants.MESSAGE_LABEL_OUT_VALUE),
- WSDLConstants.OUTPUT_PART_QNAME_SUFFIX);
+ WSDLConstants.OUTPUT_PART_QNAME_SUFFIX);
}
}
}
@@ -116,27 +116,48 @@
XmlSchemaElement schemaElement = message.getSchemaElement();
XmlSchemaType schemaType = schemaElement.getSchemaType();
+ QName schemaTypeQname = schemaElement.getSchemaTypeName();
+ if (schemaType == null) {
+ if (schemaTypeQname != null) {
+ // find the schema type from all the schemas
+ // now we need to get the schema of the extension type from the parent schema. For that let's first retrieve
+ // the parent schema
+ AxisService axisService = (AxisService) message.getParent().getParent();
+ ArrayList schemasList = axisService.getSchema();
+
+ XmlSchema schema = null;
+ for (Iterator iter = schemasList.iterator(); iter.hasNext();) {
+ schema = (XmlSchema) iter.next();
+ schemaType = getSchemaType(schema, schemaTypeQname);
+ if (schemaType != null) {
+ break;
+ }
+ }
+ }
+ }
- if (schemaType instanceof XmlSchemaComplexType){
- handleAllCasesOfComplexTypes(schemaType,
- message,
- partNameList,
- qnameSuffix);
- } else if (schemaType instanceof XmlSchemaSimpleType){
- XmlSchemaSimpleType xmlSchemaSimpleType = (XmlSchemaSimpleType) schemaType;
- QName opName = ((AxisOperation)message.getParent()).getName();
+ if (schemaType instanceof XmlSchemaComplexType) {
+ handleAllCasesOfComplexTypes(schemaType,
+ message,
+ partNameList,
+ qnameSuffix);
+ } else if ((schemaType instanceof XmlSchemaSimpleType) ||
+ ((schemaTypeQname != null) && (schemaTypeQname.equals(new QName("http://www.w3.org/2001/XMLSchema", "anyType")))) ) {
+ QName opName = ((AxisOperation) message.getParent()).getName();
partNameList.add(WSDLUtil.getPartQName(opName.getLocalPart(),
- qnameSuffix,
- schemaElement.getQName().getLocalPart()));
+ qnameSuffix,
+ schemaElement.getQName().getLocalPart()));
+ } else if (schemaType == null) {
+ throw new CodeGenerationException("Can not determine the schema type for the "
+ + schemaElement.getName());
} else {
//we've no idea how to unwrap a non complexType!!!!!!
throw new CodeGenerationException(
CodegenMessages.getMessage("extension.unsupportedSchemaFormat",
- "unknown", "complexType"));
+ schemaType.getName(), "complexType"));
}
-
try {
//set in the axis message that the unwrapping was success
message.addParameter(getParameter(
@@ -146,13 +167,13 @@
// attach the opName and the parts name list into the
// axis message by using the holder
MessagePartInformationHolder infoHolder = new MessagePartInformationHolder();
- infoHolder.setOperationName(((AxisOperation)message.getParent()).getName());
+ infoHolder.setOperationName(((AxisOperation) message.getParent()).getName());
infoHolder.setPartsList(partNameList);
//attach it to the parameters
message.addParameter(
getParameter(Constants.UNWRAPPED_DETAILS,
- infoHolder));
+ infoHolder));
} catch (AxisFault axisFault) {
throw new CodeGenerationException(axisFault);
@@ -168,11 +189,11 @@
// if a complex type name exits for a element then
// we keep that complex type to support unwrapping
if (schemaType instanceof XmlSchemaComplexType) {
- XmlSchemaComplexType cmplxType = (XmlSchemaComplexType)schemaType;
+ XmlSchemaComplexType cmplxType = (XmlSchemaComplexType) schemaType;
if (cmplxType.getContentModel() == null) {
if (cmplxType.getParticle() != null) {
processXMLSchemaSequence(cmplxType.getParticle(), message, partNameList,
- qnameSuffix);
+ qnameSuffix);
}
} else {
// now lets handle case with extensions
@@ -188,19 +209,19 @@
AxisMessage message,
List partNameList,
String qnameSuffix) {
- QName opName = ((AxisOperation)message.getParent()).getName();
+ QName opName = ((AxisOperation) message.getParent()).getName();
XmlSchemaObjectCollection xmlObjectCollection = complexType.getAttributes();
XmlSchemaObject item;
XmlSchemaAttribute xmlSchemaAttribute;
for (Iterator iter = xmlObjectCollection.getIterator(); iter.hasNext();) {
- item = (XmlSchemaObject)iter.next();
+ item = (XmlSchemaObject) iter.next();
if (item instanceof XmlSchemaAttribute) {
- xmlSchemaAttribute = (XmlSchemaAttribute)item;
+ xmlSchemaAttribute = (XmlSchemaAttribute) item;
String partName = xmlSchemaAttribute.getName();
partNameList.add(
WSDLUtil.getPartQName(opName.getLocalPart(),
- qnameSuffix,
- partName));
+ qnameSuffix,
+ partName));
}
}
@@ -212,30 +233,30 @@
String qnameSuffix) throws CodeGenerationException {
XmlSchemaContentModel contentModel = cmplxType.getContentModel();
if (contentModel instanceof XmlSchemaComplexContent) {
- XmlSchemaComplexContent xmlSchemaComplexContent = (XmlSchemaComplexContent)contentModel;
+ XmlSchemaComplexContent xmlSchemaComplexContent = (XmlSchemaComplexContent) contentModel;
XmlSchemaContent content = xmlSchemaComplexContent.getContent();
if (content instanceof XmlSchemaComplexContentExtension) {
- XmlSchemaComplexContentExtension schemaExtension = (XmlSchemaComplexContentExtension)content;
+ XmlSchemaComplexContentExtension schemaExtension = (XmlSchemaComplexContentExtension) content;
// process particles inside this extension, if any
if (schemaExtension.getParticle() != null) {
processXMLSchemaSequence(schemaExtension.getParticle(), message, partNameList,
- qnameSuffix);
+ qnameSuffix);
}
// now we need to get the schema of the extension type from the parent schema. For that let's first retrieve
// the parent schema
- AxisService axisService = (AxisService)message.getParent().getParent();
+ AxisService axisService = (AxisService) message.getParent().getParent();
ArrayList schemasList = axisService.getSchema();
XmlSchema parentSchema = null;
XmlSchema schema = null;
XmlSchemaType extensionSchemaType = null;
- for (Iterator iter = schemasList.iterator();iter.hasNext();){
+ for (Iterator iter = schemasList.iterator(); iter.hasNext();) {
schema = (XmlSchema) iter.next();
extensionSchemaType = getSchemaType(schema, schemaExtension.getBaseTypeName());
- if (extensionSchemaType != null){
+ if (extensionSchemaType != null) {
break;
}
}
@@ -243,7 +264,7 @@
// ok now we got the parent schema. Now let's get the extension's schema type
handleAllCasesOfComplexTypes(extensionSchemaType, message, partNameList,
- qnameSuffix);
+ qnameSuffix);
}
}
}
@@ -262,13 +283,13 @@
object = includesIter.next();
if (object instanceof XmlSchemaImport) {
XmlSchema schema1 = ((XmlSchemaImport) object).getSchema();
- xmlSchemaType = getSchemaType(schema1,typeName);
+ xmlSchemaType = getSchemaType(schema1, typeName);
}
if (object instanceof XmlSchemaInclude) {
XmlSchema schema1 = ((XmlSchemaInclude) object).getSchema();
- xmlSchemaType = getSchemaType(schema1,typeName);
+ xmlSchemaType = getSchemaType(schema1, typeName);
}
- if (xmlSchemaType != null){
+ if (xmlSchemaType != null) {
break;
}
}
@@ -286,9 +307,9 @@
// get the name of the operation name and namespace,
// part name and hang them somewhere ? The ideal place
// would be the property bag in the codegen config!
- QName opName = ((AxisOperation)message.getParent()).getName();
+ QName opName = ((AxisOperation) message.getParent()).getName();
- XmlSchemaSequence sequence = (XmlSchemaSequence)schemaParticle;
+ XmlSchemaSequence sequence = (XmlSchemaSequence) schemaParticle;
XmlSchemaObjectCollection items = sequence.getItems();
// if this is an empty sequence, return
@@ -324,8 +345,8 @@
partNameList.add(
WSDLUtil.getPartQName(opName.getLocalPart(),
- qnameSuffix,
- partName));
+ qnameSuffix,
+ partName));
// if the particle contains anything other than
// a XMLSchemaElement then we are not in a position
@@ -336,16 +357,16 @@
// for it for now
//we have to handle both maxoccurs 1 and maxoccurs > 1 situation
- XmlSchemaAny xmlSchemaAny = (XmlSchemaAny)item;
+ XmlSchemaAny xmlSchemaAny = (XmlSchemaAny) item;
partNameList.add(
WSDLUtil.getPartQName(opName.getLocalPart(),
- qnameSuffix,
- Constants.ANY_ELEMENT_FIELD_NAME));
+ qnameSuffix,
+ Constants.ANY_ELEMENT_FIELD_NAME));
} else {
throw new CodeGenerationException(
CodegenMessages.getMessage("extension.unsupportedSchemaFormat",
- "unknown type", "Element"));
+ "unknown type", "Element"));
}
}
@@ -356,16 +377,16 @@
} else if (schemaParticle instanceof XmlSchemaChoice) {
throw new CodeGenerationException(
CodegenMessages.getMessage("extension.unsupportedSchemaFormat",
- "choice", "sequence"));
+ "choice", "sequence"));
} else if (schemaParticle instanceof XmlSchemaAll) {
throw new CodeGenerationException(
CodegenMessages.getMessage("extension.unsupportedSchemaFormat",
- "all", "sequence"));
+ "all", "sequence"));
} else {
throw new CodeGenerationException(
CodegenMessages.getMessage("extension.unsupportedSchemaFormat",
- "unknown", "sequence"));
+ "unknown", "sequence"));
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org