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 ch...@apache.org on 2006/09/04 13:15:09 UTC
svn commit: r440030 - in /webservices/axis2/trunk/java/modules/codegen:
src/org/apache/axis2/wsdl/codegen/extension/SchemaUnwrapperExtension.java
test/org/apache/axis2/wsdl/codegen/extension/SchemaUnwrapperExtensionTest.java
Author: chinthaka
Date: Mon Sep 4 04:15:08 2006
New Revision: 440030
URL: http://svn.apache.org/viewvc?view=rev&rev=440030
Log:
Unwrapping should be working by now. I wrote some test cases which can test the bevaiour without actually generating the code. But I need to codegen a complex wsdl and see.
Modified:
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/SchemaUnwrapperExtension.java
webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/wsdl/codegen/extension/SchemaUnwrapperExtensionTest.java
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=440030&r1=440029&r2=440030
==============================================================================
--- 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 Sep 4 04:15:08 2006
@@ -16,6 +16,7 @@
import org.apache.ws.commons.schema.*;
import javax.xml.namespace.QName;
+import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@@ -117,21 +118,7 @@
// this type should be a complex type or it should have a name which refer to another type definition
// first let's handle this being a complex type
- if (schemaType instanceof XmlSchemaComplexType) {
- XmlSchemaComplexType cmplxType = (XmlSchemaComplexType) schemaType;
- if (cmplxType.getContentModel() == null) {
- processComplexType(cmplxType.getParticle(), message, partNameList);
- } else {
- // now lets handle case with extensions
- processComplexContentModel(cmplxType, message, partNameList);
- }
-
-
- } else {
- //we've no idea how to unwrap a non complexType!!!!!!
- throw new CodeGenerationException(CodegenMessages.getMessage("extension.unsupportedSchemaFormat",
- "unknown", "complexType"));
- }
+ handleAllCasesOfComplexTypes(schemaType, message, partNameList);
try {
//set in the axis message that the unwrapping was success
@@ -156,6 +143,24 @@
}
+ private void handleAllCasesOfComplexTypes(XmlSchemaType schemaType, AxisMessage message, List partNameList) throws CodeGenerationException {
+ if (schemaType instanceof XmlSchemaComplexType) {
+ XmlSchemaComplexType cmplxType = (XmlSchemaComplexType) schemaType;
+ if (cmplxType.getContentModel() == null) {
+ processComplexType(cmplxType.getParticle(), message, partNameList);
+ } else {
+ // now lets handle case with extensions
+ processComplexContentModel(cmplxType, message, partNameList);
+ }
+
+
+ } else {
+ //we've no idea how to unwrap a non complexType!!!!!!
+ throw new CodeGenerationException(CodegenMessages.getMessage("extension.unsupportedSchemaFormat",
+ "unknown", "complexType"));
+ }
+ }
+
private void processComplexContentModel(XmlSchemaComplexType cmplxType, AxisMessage message, List partNameList) throws CodeGenerationException {
XmlSchemaContentModel contentModel = cmplxType.getContentModel();
if (contentModel instanceof XmlSchemaComplexContent) {
@@ -167,21 +172,25 @@
// process particles inside this extension, if any
processComplexType(schemaExtension.getParticle(), message, partNameList);
-// AxisService axisService = (AxisService) message.getParent().getParent();
-// XmlSchemaElement schemaElement = axisService.getSchemaElement(schemaExtension.getBaseTypeName());
-// if (schemaElement != null) {
-// XmlSchemaType schemaType = schemaElement.getSchemaType();
-//
-// if (schemaType instanceof XmlSchemaComplexType) {
-// XmlSchemaComplexType xmlSchemaComplexType = (XmlSchemaComplexType) schemaType;
-// processComplexType(xmlSchemaComplexType, message, partNameList);
-//
-// } else {
-// //we've no idea how to unwrap a non complexType!!!!!!
-// throw new CodeGenerationException(CodegenMessages.getMessage("extension.unsupportedSchemaFormat",
-// "unknown", "complexType"));
-// }
-// }
+ // 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 parentSchema = null;
+
+ for (int i = 0; i < schemasList.size() || parentSchema == null; i++) {
+ XmlSchema schema = (XmlSchema) schemasList.get(i);
+ if (schema.getTargetNamespace().equals(schemaExtension.getBaseTypeName().getNamespaceURI())) {
+ parentSchema = schema;
+ }
+ }
+
+ // ok now we got the parent schema. Now let's get the extension's schema type
+
+ XmlSchemaType extensionSchemaType = parentSchema.getTypeByName(schemaExtension.getBaseTypeName());
+
+ handleAllCasesOfComplexTypes(extensionSchemaType, message, partNameList);
}
}
}
Modified: webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/wsdl/codegen/extension/SchemaUnwrapperExtensionTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/wsdl/codegen/extension/SchemaUnwrapperExtensionTest.java?view=diff&rev=440030&r1=440029&r2=440030
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/wsdl/codegen/extension/SchemaUnwrapperExtensionTest.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/wsdl/codegen/extension/SchemaUnwrapperExtensionTest.java Mon Sep 4 04:15:08 2006
@@ -9,7 +9,6 @@
import org.apache.axis2.wsdl.util.MessagePartInformationHolder;
import org.apache.ws.commons.schema.XmlSchema;
import org.apache.ws.commons.schema.XmlSchemaCollection;
-import org.apache.ws.commons.schema.XmlSchemaElement;
import javax.xml.namespace.QName;
import javax.xml.transform.stream.StreamSource;
@@ -98,57 +97,55 @@
assertTrue(partsList.size() == 2);
}
-// /**
-// * 1. AddRequest is of AddRequestType
-// * 2. AddRequestType extends from AbstractParameterType
-// * 3. AbstractParameterType has primitive types only
-// */
-// public void testScenarioThree() {
-// String schemaLocation = "test-resources/schemas/schema-3.xsd";
-//
-// createAndWalkSchema(schemaLocation);
-//
-// assertTrue(axisMessage.getParameter(Constants.UNWRAPPED_KEY).getValue() == Boolean.TRUE);
-//
-// Parameter parameter = axisMessage.getParameter(Constants.UNWRAPPED_DETAILS);
-// MessagePartInformationHolder messagePartInformationHolder = (MessagePartInformationHolder) parameter.getValue();
-// List partsList = messagePartInformationHolder.getPartsList();
-//
-// assertTrue(partsList.contains(WSDLUtil.getPartQName(ADD_OPERATION, WSDLConstants.INPUT_PART_QNAME_SUFFIX, PARAMETER_ONE)));
-// assertTrue(partsList.contains(WSDLUtil.getPartQName(ADD_OPERATION, WSDLConstants.INPUT_PART_QNAME_SUFFIX, PARAMETER_TWO)));
-// assertTrue(partsList.size() == 2);
-// }
-//
-// /**
-// * 1. AddRequest is of AddRequestType
-// * 2. AddRequestType extends from AbstractParameterType and it AddRequestType has more stuff defined in a sequence, in
-// * addition to the extension.
-// * 3. AbstractParameterType has primitive types only
-// */
-// public void testScenarioFour() {
-// String schemaLocation = "test-resources/schemas/schema-4.xsd";
-//
-// createAndWalkSchema(schemaLocation);
-//
-// assertTrue(axisMessage.getParameter(Constants.UNWRAPPED_KEY).getValue() == Boolean.TRUE);
-//
-// Parameter parameter = axisMessage.getParameter(Constants.UNWRAPPED_DETAILS);
-// MessagePartInformationHolder messagePartInformationHolder = (MessagePartInformationHolder) parameter.getValue();
-// List partsList = messagePartInformationHolder.getPartsList();
-//
-// assertTrue(partsList.contains(WSDLUtil.getPartQName(ADD_OPERATION, WSDLConstants.INPUT_PART_QNAME_SUFFIX, PARAMETER_ONE)));
-// assertTrue(partsList.contains(WSDLUtil.getPartQName(ADD_OPERATION, WSDLConstants.INPUT_PART_QNAME_SUFFIX, PARAMETER_TWO)));
-// assertTrue(partsList.contains(WSDLUtil.getPartQName(ADD_OPERATION, WSDLConstants.INPUT_PART_QNAME_SUFFIX, PARAMETER_THREE)));
-// assertTrue(partsList.contains(WSDLUtil.getPartQName(ADD_OPERATION, WSDLConstants.INPUT_PART_QNAME_SUFFIX, PARAMETER_FOUR)));
-// assertTrue(partsList.size() == 4);
-// }
+ /**
+ * 1. AddRequest is of AddRequestType
+ * 2. AddRequestType extends from AbstractParameterType
+ * 3. AbstractParameterType has primitive types only
+ */
+ public void testScenarioThree() {
+ String schemaLocation = "test-resources/schemas/schema-3.xsd";
+
+ createAndWalkSchema(schemaLocation);
+
+ assertTrue(axisMessage.getParameter(Constants.UNWRAPPED_KEY).getValue() == Boolean.TRUE);
+
+ Parameter parameter = axisMessage.getParameter(Constants.UNWRAPPED_DETAILS);
+ MessagePartInformationHolder messagePartInformationHolder = (MessagePartInformationHolder) parameter.getValue();
+ List partsList = messagePartInformationHolder.getPartsList();
+
+ assertTrue(partsList.contains(WSDLUtil.getPartQName(ADD_OPERATION, WSDLConstants.INPUT_PART_QNAME_SUFFIX, PARAMETER_ONE)));
+ assertTrue(partsList.contains(WSDLUtil.getPartQName(ADD_OPERATION, WSDLConstants.INPUT_PART_QNAME_SUFFIX, PARAMETER_TWO)));
+ assertTrue(partsList.size() == 2);
+ }
+
+ /**
+ * 1. AddRequest is of AddRequestType
+ * 2. AddRequestType extends from AbstractParameterType and it AddRequestType has more stuff defined in a sequence, in
+ * addition to the extension.
+ * 3. AbstractParameterType has primitive types only
+ */
+ public void testScenarioFour() {
+ String schemaLocation = "test-resources/schemas/schema-4.xsd";
+
+ createAndWalkSchema(schemaLocation);
+
+ assertTrue(axisMessage.getParameter(Constants.UNWRAPPED_KEY).getValue() == Boolean.TRUE);
+
+ Parameter parameter = axisMessage.getParameter(Constants.UNWRAPPED_DETAILS);
+ MessagePartInformationHolder messagePartInformationHolder = (MessagePartInformationHolder) parameter.getValue();
+ List partsList = messagePartInformationHolder.getPartsList();
+
+ assertTrue(partsList.contains(WSDLUtil.getPartQName(ADD_OPERATION, WSDLConstants.INPUT_PART_QNAME_SUFFIX, PARAMETER_ONE)));
+ assertTrue(partsList.contains(WSDLUtil.getPartQName(ADD_OPERATION, WSDLConstants.INPUT_PART_QNAME_SUFFIX, PARAMETER_TWO)));
+ assertTrue(partsList.contains(WSDLUtil.getPartQName(ADD_OPERATION, WSDLConstants.INPUT_PART_QNAME_SUFFIX, PARAMETER_THREE)));
+ assertTrue(partsList.contains(WSDLUtil.getPartQName(ADD_OPERATION, WSDLConstants.INPUT_PART_QNAME_SUFFIX, PARAMETER_FOUR)));
+ assertTrue(partsList.size() == 4);
+ }
private void createAndWalkSchema(String schemaLocation) {
try {
XmlSchema xmlSchema = loadSchema(schemaLocation);
axisService.addSchema(xmlSchema);
- XmlSchemaElement schemaElement = axisMessage.getSchemaElement();
-
SchemaUnwrapperExtension extension = new SchemaUnwrapperExtension();
extension.walkSchema(axisMessage);
} catch (FileNotFoundException e) {
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org