diff --git a/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java b/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java
index 7554452f06..68456cb54f 100644
--- a/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java
+++ b/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java
@@ -1766,6 +1766,11 @@ private Map createSchemaForPorttype(String namespaceURI,
namespacePrefixMap,
boEntry);
+ // No wrapped element needs to be created
+ if (!boEntry.isWrappedInput()) {
+ continue;
+ }
+
elementDeclaration.appendChild(newComplexType);
String namespaceToUse = namespaceURI;
@@ -1855,6 +1860,12 @@ private Map createSchemaForPorttype(String namespaceURI,
namespaceImportsMap,
namespacePrefixMap,
boEntry);
+
+ // No wrapped element needs to be created
+ if (!boEntry.isWrappedInput()) {
+ continue;
+ }
+
elementDeclaration.appendChild(newComplexType);
String namespaceToUse = namespaceURI;
@@ -2259,7 +2270,11 @@ private void addPartToElement(Part part,
"and use the type attribute.");
} else {
// The presense of an element means that a wrapper xsd element is not needed.
- boe.setWrappedOutput(false);
+ if (isOutMessage){
+ boe.setWrappedOutput(false);
+ } else {
+ boe.setWrappedInput(false);
+ }
if (log.isDebugEnabled()) {
log.debug("The binding operation " + bindingOperationName +
" references message part " +
diff --git a/modules/kernel/test-resources/wsdl/nonduplicatedElements.wsdl b/modules/kernel/test-resources/wsdl/nonduplicatedElements.wsdl
new file mode 100644
index 0000000000..93d9b452d5
--- /dev/null
+++ b/modules/kernel/test-resources/wsdl/nonduplicatedElements.wsdl
@@ -0,0 +1,55 @@
+
+
+
+
+
+
+
+
+
+
+
+ Message part referencing a global element declaration
+
+
+
+
+
+ Message part referencing a type definition
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/modules/kernel/test/org/apache/axis2/description/WSDL11ToAxisServiceBuilderTest.java b/modules/kernel/test/org/apache/axis2/description/WSDL11ToAxisServiceBuilderTest.java
index cdf1c9b31a..f8bb920f2e 100644
--- a/modules/kernel/test/org/apache/axis2/description/WSDL11ToAxisServiceBuilderTest.java
+++ b/modules/kernel/test/org/apache/axis2/description/WSDL11ToAxisServiceBuilderTest.java
@@ -24,14 +24,19 @@
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import javax.wsdl.xml.WSDLLocator;
import javax.xml.namespace.QName;
import org.apache.axis2.engine.AxisConfiguration;
import org.apache.axis2.wsdl.WSDLConstants;
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.ws.commons.schema.XmlSchemaObject;
import org.xml.sax.InputSource;
import junit.framework.TestCase;
@@ -65,6 +70,43 @@ public void testMultipleFaultsWithSameMessage() throws Exception {
}
}
+ public void testNonDuplicatedElementsHttpBinding() throws Exception {
+ final String wsdlPath = "test-resources/wsdl/nonduplicatedElements.wsdl";
+ InputStream in = new FileInputStream(wsdlPath);
+ final String targetNamespace = "http://www.example.org";
+ final QName serviceName = new QName(targetNamespace, "FooService");
+ final String portName = "FooHttpGetPort";
+
+ AxisService service = new WSDL11ToAxisServiceBuilder(in, serviceName, portName).populateService();
+ List schemaDocuments = service.getSchema();
+ List duplicatedGlobalElements = findDuplicatedGlobalElements(schemaDocuments);
+ // NO duplicated element should exists
+ assertTrue("Duplicated global element declarations found in '" + wsdlPath,
+ duplicatedGlobalElements.isEmpty());
+ }
+
+ protected List findDuplicatedGlobalElements(List schemaDocuments) {
+ List duplicatedGlobalElementDeclarations = new ArrayList();
+ Set globalElementDeclarations = new HashSet();
+ // Iterate over all schema documents
+ for (XmlSchema schemaDocument : schemaDocuments) {
+ for (XmlSchemaObject xmlSchemaObject : schemaDocument.getItems()) {
+ // Check only XML schema elements
+ if (xmlSchemaObject instanceof XmlSchemaElement) {
+ QName elementName = ((XmlSchemaElement)xmlSchemaObject).getQName();
+ /* Was another element with the same name found in this or
+ other XML schema document? */
+ if (globalElementDeclarations.contains(elementName)) {
+ duplicatedGlobalElementDeclarations.add(elementName);
+ } else {
+ globalElementDeclarations.add(elementName);
+ }
+ }
+ }
+ }
+ return duplicatedGlobalElementDeclarations;
+ }
+
private AxisService populateAxisService(AxisConfiguration axisConf, File wsdlFile) throws IOException {
InputStream in = null;
try {