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 am...@apache.org on 2007/03/27 07:22:59 UTC
svn commit: r522756 - in /webservices/axis2/trunk/java/modules:
adb-codegen/src/org/apache/axis2/schema/
codegen/src/org/apache/axis2/wsdl/codegen/extension/
integration/test-resources/wsdl/
Author: amilas
Date: Mon Mar 26 22:22:58 2007
New Revision: 522756
URL: http://svn.apache.org/viewvc?view=rev&rev=522756
Log:
Added the attribute support for unwrapping.
Modified:
webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/ExtensionUtility.java
webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/SchemaUnwrapperExtension.java
webservices/axis2/trunk/java/modules/integration/test-resources/wsdl/DocumentUnwrappingTest.wsdl
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=522756&r1=522755&r2=522756
==============================================================================
--- 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 Mar 26 22:22:58 2007
@@ -145,14 +145,18 @@
WSDLConstants.INPUT_PART_QNAME_SUFFIX);
}
- if (WSDLUtil.isOutputPresentForMEP(op.getMessageExchangePattern())) {
- walkSchema(op.getMessage(
- WSDLConstants.MESSAGE_LABEL_OUT_VALUE),
- mapper,
- schemaMap,
- op.getName().getLocalPart(),
- WSDLConstants.OUTPUT_PART_QNAME_SUFFIX);
+ // TODO: support for xml beans
+ if (configuration.getDatabindingType().equals("adb")) {
+ if (WSDLUtil.isOutputPresentForMEP(op.getMessageExchangePattern())) {
+ walkSchema(op.getMessage(
+ WSDLConstants.MESSAGE_LABEL_OUT_VALUE),
+ mapper,
+ schemaMap,
+ op.getName().getLocalPart(),
+ WSDLConstants.OUTPUT_PART_QNAME_SUFFIX);
+ }
}
+
}
}
@@ -237,6 +241,7 @@
XmlSchemaType schemaType = message.getSchemaElement().getSchemaType();
//create a type mapper
processXMLSchemaComplexType(schemaType, mapper, opName, schemaMap, qnameSuffix);
+
}
}
@@ -252,9 +257,34 @@
} else {
processComplexContentModel(cmplxType, mapper, opName, schemaMap, qnameSuffix);
}
+ processAttributes(cmplxType, opName, qnameSuffix, mapper);
}
}
+ private static void processAttributes(XmlSchemaComplexType complexType,
+ String opName,
+ String qnameSuffix,
+ TypeMapper typeMap) {
+ XmlSchemaObjectCollection xmlObjectCollection = complexType.getAttributes();
+ XmlSchemaObject item;
+ for (Iterator iter = xmlObjectCollection.getIterator(); iter.hasNext();) {
+ item = (XmlSchemaObject) iter.next();
+ XmlSchemaAttribute xmlSchemaAttribute;
+ if (item instanceof XmlSchemaAttribute) {
+ xmlSchemaAttribute = (XmlSchemaAttribute) item;
+ populateClassName(xmlSchemaAttribute.getMetaInfoMap(),
+ typeMap,
+ opName,
+ false,
+ xmlSchemaAttribute.getName(),
+ qnameSuffix);
+ }
+
+ }
+
+ }
+
+
private static void processComplexContentModel(XmlSchemaComplexType cmplxType,
TypeMapper mapper,
String opName,
@@ -289,8 +319,7 @@
Map schemaMap,
String qnameSuffix) {
if (particle instanceof XmlSchemaSequence) {
- XmlSchemaObjectCollection items =
- ((XmlSchemaSequence) particle).getItems();
+ XmlSchemaObjectCollection items = ((XmlSchemaSequence) particle).getItems();
for (Iterator i = items.getIterator(); i.hasNext();) {
Object item = i.next();
// get each and every element in the sequence and
@@ -299,52 +328,68 @@
//populate the map with the partname - class name
//attached to the schema element
XmlSchemaElement xmlSchemaElement = (XmlSchemaElement) item;
- XmlSchemaType eltSchemaType = xmlSchemaElement.getSchemaType();
- if (eltSchemaType != null) {
- //there is a schema type object.We can utilize that
- populateClassName(eltSchemaType, mapper, opName, xmlSchemaElement, qnameSuffix);
- } else if (xmlSchemaElement.getSchemaTypeName() != null) {
- //there is no schema type object but there is a
- //schema type QName. Use that Qname to look up the
- //schematype in other schema objects
- eltSchemaType = findSchemaType(schemaMap,
- xmlSchemaElement.getSchemaTypeName());
- if (eltSchemaType != null) {
- populateClassName(eltSchemaType, mapper, opName, xmlSchemaElement, qnameSuffix);
- } else if (xmlSchemaElement.getSchemaTypeName().equals(SchemaConstants.XSD_ANYTYPE)) {
- QName partQName = WSDLUtil.getPartQName(opName,
- qnameSuffix,
- xmlSchemaElement.getName());
-
- if (xmlSchemaElement.getMaxOccurs() > 1) {
- mapper.addTypeMappingName(partQName, "org.apache.axiom.om.OMElement[]");
- } else {
- mapper.addTypeMappingName(partQName, "org.apache.axiom.om.OMElement");
- }
- }
- }
+ boolean isArray = (xmlSchemaElement.getMaxOccurs() - xmlSchemaElement.getMinOccurs()) > 1;
+
+// XmlSchemaType eltSchemaType = xmlSchemaElement.getSchemaType();
+// if (eltSchemaType != null) {
+// //there is a schema type object.We can utilize that
+// populateClassName(eltSchemaType.getMetaInfoMap(),
+// mapper,
+// opName,
+// isArray,
+// xmlSchemaElement.getName(),
+// qnameSuffix);
+// } else if (xmlSchemaElement.getSchemaTypeName() != null) {
+// //there is no schema type object but there is a
+// //schema type QName. Use that Qname to look up the
+// //schematype in other schema objects
+// eltSchemaType = findSchemaType(schemaMap,
+// xmlSchemaElement.getSchemaTypeName());
+// if (eltSchemaType != null) {
+// populateClassName(eltSchemaType.getMetaInfoMap(),
+// mapper,
+// opName,
+// isArray,
+// xmlSchemaElement.getName(),
+// qnameSuffix);
+// } else if (xmlSchemaElement.getSchemaTypeName().equals(SchemaConstants.XSD_ANYTYPE)) {
+// QName partQName = WSDLUtil.getPartQName(opName,
+// qnameSuffix,
+// xmlSchemaElement.getName());
+//
+// if (xmlSchemaElement.getMaxOccurs() > 1) {
+// mapper.addTypeMappingName(partQName, "org.apache.axiom.om.OMElement[]");
+// } else {
+// mapper.addTypeMappingName(partQName, "org.apache.axiom.om.OMElement");
+// }
+// }
+// }
+ // get the element class name from the element and populate the mapper
+ populateClassName(xmlSchemaElement.getMetaInfoMap(),
+ mapper,
+ opName,
+ isArray,
+ xmlSchemaElement.getName(),
+ qnameSuffix);
} else if (item instanceof XmlSchemaAny) {
// if this is an instance of xs:any, then there is no part name for it. Using ANY_ELEMENT_FIELD_NAME
// for it for now
- //we have to handle both maxoccurs 1 and maxoccurs > 1 situation
XmlSchemaAny xmlSchemaAny = (XmlSchemaAny) item;
+ boolean isArray = xmlSchemaAny.getMaxOccurs() - xmlSchemaAny.getMinOccurs() > 1;
QName partQName = WSDLUtil.getPartQName(opName,
qnameSuffix,
Constants.ANY_ELEMENT_FIELD_NAME);
- if (((XmlSchemaAny) item).getMaxOccurs() > 1) {
+ if (isArray) {
mapper.addTypeMappingName(partQName, "org.apache.axiom.om.OMElement[]");
} else {
mapper.addTypeMappingName(partQName, "org.apache.axiom.om.OMElement");
}
-
}
-
}
-
}
}
@@ -353,17 +398,15 @@
/**
* Util method to populate the class name into the typeMap
*
- * @param eltSchemaType
*/
- private static void populateClassName(XmlSchemaType eltSchemaType,
+ private static void populateClassName(Map metaInfoMap,
TypeMapper typeMap,
String opName,
- XmlSchemaElement xmlSchemaElement,
+ boolean isArray,
+ String partName,
String qnameSuffix) {
- boolean isArray = xmlSchemaElement.getMaxOccurs() > 1;
- Map metaInfoMap = eltSchemaType.getMetaInfoMap();
if (metaInfoMap != null) {
String className = (String) metaInfoMap.
@@ -382,7 +425,7 @@
QName partQName = WSDLUtil.getPartQName(opName,
qnameSuffix,
- xmlSchemaElement.getName());
+ partName);
typeMap.addTypeMappingName(partQName, className);
if (Boolean.TRUE.equals(
metaInfoMap.get(SchemaConstants.
Modified: webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java?view=diff&rev=522756&r1=522755&r2=522756
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java Mon Mar 26 22:22:58 2007
@@ -434,8 +434,7 @@
String writtenClassName = writer.write(xsElt, processedTypemap, metainf);
//register the class name
- xsElt.addMetaInfo(SchemaConstants.SchemaCompilerInfoHolder.CLASSNAME_KEY,
- writtenClassName);
+ xsElt.addMetaInfo(SchemaConstants.SchemaCompilerInfoHolder.CLASSNAME_KEY, writtenClassName);
processedElementMap.put(xsElt.getQName(), writtenClassName);
}
@@ -503,10 +502,10 @@
innerElementMap.put(xsElt.getQName(), className);
- //store in the schema map
- schemaType.addMetaInfo(
- SchemaConstants.SchemaCompilerInfoHolder.CLASSNAME_KEY,
- className);
+ // always store the class name in the element meta Info itself
+ // this details only needed by the unwrappig to set the complex type
+ schemaType.addMetaInfo(SchemaConstants.SchemaCompilerInfoHolder.CLASSNAME_KEY, className);
+ xsElt.addMetaInfo(SchemaConstants.SchemaCompilerInfoHolder.CLASSNAME_KEY, className);
if (baseSchemaTypeMap.containsValue(className)) {
schemaType.addMetaInfo(
@@ -541,7 +540,7 @@
xsElt.getQName(),
className);
- //store in the schema map
+ //store in the schema map to retrive in the unwrapping
xsElt.addMetaInfo(
SchemaConstants.SchemaCompilerInfoHolder.CLASSNAME_KEY,
className);
@@ -604,6 +603,9 @@
this.processedElementRefMap.put(referenceEltQName, javaClassName);
referencedElement.addMetaInfo(SchemaConstants.SchemaCompilerInfoHolder.CLASSNAME_KEY,
javaClassName);
+ // set the element class name to be used in unwrapping
+ xsElt.addMetaInfo(SchemaConstants.SchemaCompilerInfoHolder.CLASSNAME_KEY,
+ javaClassName);
} else {
//this referenced element has an anon type and that anon type has been already
//processed. But in this case we need it to be a seperate class since this
@@ -633,6 +635,9 @@
processedTypemap.put(generatedTypeName, javaclassName);
this.processedElementRefMap.put(referenceEltQName, javaclassName);
+ // set the class name to be used in unwrapping
+ xsElt.addMetaInfo(SchemaConstants.SchemaCompilerInfoHolder.CLASSNAME_KEY,
+ javaclassName);
}
}
@@ -652,6 +657,9 @@
String className = findClassName(schemaTypeName, isArray(xsElt));
//since this is a inner element we should add it to the inner element map
innerElementMap.put(xsElt.getQName(), className);
+ // set the class name to be used in unwrapping
+ xsElt.addMetaInfo(SchemaConstants.SchemaCompilerInfoHolder.CLASSNAME_KEY,
+ className);
} else {
this.processedElementList.add(xsElt.getQName());
}
@@ -660,6 +668,9 @@
if (!isOuter) {
String className = findClassName(schemaTypeName, isArray(xsElt));
innerElementMap.put(xsElt.getQName(), className);
+ // set the class name to be used in unwrapping
+ xsElt.addMetaInfo(SchemaConstants.SchemaCompilerInfoHolder.CLASSNAME_KEY,
+ className);
} else {
this.processedElementList.add(xsElt.getQName());
}
@@ -1499,6 +1510,12 @@
if (use.indexOf("optional") != -1) {
metainf.addtStatus(att.getQName(), SchemaConstants.OPTIONAL_TYPE);
}
+
+ String className = findClassName(schemaTypeName, false);
+
+ att.addMetaInfo(
+ SchemaConstants.SchemaCompilerInfoHolder.CLASSNAME_KEY,
+ className);
// after
} else {
XmlSchemaType type = getType(parentSchema, schemaTypeName);
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=522756&r1=522755&r2=522756
==============================================================================
--- 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 Mar 26 22:22:58 2007
@@ -59,11 +59,13 @@
*/
public class SchemaUnwrapperExtension extends AbstractCodeGenerationExtension {
+ private CodeGenConfiguration codeGenConfiguration;
/**
* @param configuration
* @throws CodeGenerationException
*/
public void engage(CodeGenConfiguration configuration) throws CodeGenerationException {
+ this.codeGenConfiguration = configuration;
if (!configuration.isParametersWrapped()) {
// A check to avoid nasty surprises - Since unwrapping is not
@@ -91,11 +93,13 @@
WSDLConstants.INPUT_PART_QNAME_SUFFIX);
}
// get the out put parameter details as well to unwrap the responses
- if (WSDLUtil.isOutputPresentForMEP(op.getMessageExchangePattern())) {
- walkSchema(op.getMessage(WSDLConstants.MESSAGE_LABEL_OUT_VALUE),
- WSDLConstants.OUTPUT_PART_QNAME_SUFFIX);
+ //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);
+ }
}
-
}
}
}
@@ -128,7 +132,12 @@
XmlSchemaElement schemaElement = message.getSchemaElement();
XmlSchemaType schemaType = schemaElement.getSchemaType();
- handleAllCasesOfComplexTypes(schemaType, message, partNameList, qnameSuffix);
+
+ handleAllCasesOfComplexTypes(schemaType,
+ message,
+ partNameList,
+ qnameSuffix);
+
try {
//set in the axis message that the unwrapping was success
@@ -160,24 +169,46 @@
// if a complex type name exits for a element then
// we keep that complex type to support unwrapping
- String complexType = "";
if (schemaType instanceof XmlSchemaComplexType) {
XmlSchemaComplexType cmplxType = (XmlSchemaComplexType) schemaType;
if (cmplxType.getContentModel() == null) {
- if (cmplxType.getParticle() != null){
+ if (cmplxType.getParticle() != null) {
processXMLSchemaSequence(cmplxType.getParticle(), message, partNameList, qnameSuffix);
}
} else {
// now lets handle case with extensions
processComplexContentModel(cmplxType, message, partNameList, qnameSuffix);
}
+ // handle attributes here
+ processAttributes(cmplxType, message, partNameList, qnameSuffix);
-
- } else {
+ } else {
//we've no idea how to unwrap a non complexType!!!!!!
throw new CodeGenerationException(CodegenMessages.getMessage("extension.unsupportedSchemaFormat",
"unknown", "complexType"));
}
+ }
+
+ private void processAttributes(XmlSchemaComplexType complexType,
+ AxisMessage message,
+ List partNameList,
+ String qnameSuffix){
+ 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();
+ if (item instanceof XmlSchemaAttribute){
+ xmlSchemaAttribute = (XmlSchemaAttribute) item;
+ String partName = xmlSchemaAttribute.getName();
+ partNameList.add(
+ WSDLUtil.getPartQName(opName.getLocalPart(),
+ qnameSuffix,
+ partName));
+ }
+ }
+
}
private void processComplexContentModel(XmlSchemaComplexType cmplxType,
Modified: webservices/axis2/trunk/java/modules/integration/test-resources/wsdl/DocumentUnwrappingTest.wsdl
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/test-resources/wsdl/DocumentUnwrappingTest.wsdl?view=diff&rev=522756&r1=522755&r2=522756
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test-resources/wsdl/DocumentUnwrappingTest.wsdl (original)
+++ webservices/axis2/trunk/java/modules/integration/test-resources/wsdl/DocumentUnwrappingTest.wsdl Mon Mar 26 22:22:58 2007
@@ -92,6 +92,37 @@
<xsd:element name="Request6" type="tns:ChildComplexType"/>
<xsd:element name="Response6" type="tns:ChildComplexType"/>
+ <xsd:element name="Request7" >
+ <xsd:complexType>
+ <xsd:attribute name="attrib1" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="Response7" >
+ <xsd:complexType>
+ <xsd:attribute name="attrib1" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="Request8">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="param1" type="xsd:string"/>
+ <xsd:element name="param2" type="xsd:string"/>
+ </xsd:sequence>
+ <xsd:attribute name="attrib1" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="Response8">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="param1" type="xsd:string"/>
+ <xsd:element name="param2" type="xsd:string"/>
+ </xsd:sequence>
+ <xsd:attribute name="attrib1" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+
<xsd:complexType name="AbstractComplexType">
<xsd:sequence>
<xsd:element name="param1" type="xsd:anyType"/>
@@ -153,6 +184,20 @@
<wsdl:part element="tns:Response6" name="parameters"/>
</wsdl:message>
+ <wsdl:message name="OperationRequestMessage7">
+ <wsdl:part element="tns:Request7" name="parameters"/>
+ </wsdl:message>
+ <wsdl:message name="OperationResponseMessage7">
+ <wsdl:part element="tns:Response7" name="parameters"/>
+ </wsdl:message>
+
+ <wsdl:message name="OperationRequestMessage8">
+ <wsdl:part element="tns:Request8" name="parameters"/>
+ </wsdl:message>
+ <wsdl:message name="OperationResponseMessage8">
+ <wsdl:part element="tns:Response8" name="parameters"/>
+ </wsdl:message>
+
<wsdl:message name="FaultMessage">
<wsdl:part element="tns:Request1" name="parameters"/>
</wsdl:message>
@@ -183,6 +228,16 @@
<wsdl:output message="tns:OperationResponseMessage6"/>
</wsdl:operation>
+ <wsdl:operation name="Operation9">
+ <wsdl:input message="tns:OperationRequestMessage7"/>
+ <wsdl:output message="tns:OperationResponseMessage7"/>
+ </wsdl:operation>
+
+ <wsdl:operation name="Operation10">
+ <wsdl:input message="tns:OperationRequestMessage8"/>
+ <wsdl:output message="tns:OperationResponseMessage8"/>
+ </wsdl:operation>
+
<wsdl:operation name="Operation7">
<wsdl:input message="tns:OperationRequestMessage1"/>
</wsdl:operation>
@@ -249,19 +304,37 @@
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="Operation7">
- <soap:operation soapAction="http://www.example.org/wsdltest/Operation6"/>
+ <soap:operation soapAction="http://www.example.org/wsdltest/Operation7"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
</wsdl:operation>
<wsdl:operation name="Operation8">
- <soap:operation soapAction="http://www.example.org/wsdltest/Operation6"/>
+ <soap:operation soapAction="http://www.example.org/wsdltest/Operation8"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:fault name="TestFault">
<soap:body use="literal" name="TestFault"/>
</wsdl:fault>
+ </wsdl:operation>
+ <wsdl:operation name="Operation9">
+ <soap:operation soapAction="http://www.example.org/wsdltest/Operation9"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="Operation10">
+ <soap:operation soapAction="http://www.example.org/wsdltest/Operation10"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="DocumentUnwrappingTestService">
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org