You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by ul...@apache.org on 2011/02/10 02:07:17 UTC
svn commit: r1069188 - in /cxf/branches/2.3.x-fixes/tools/corba/src:
main/java/org/apache/cxf/tools/corba/processors/idl/
test/java/org/apache/cxf/tools/corba/ test/resources/idl/
Author: ulhasbhole
Date: Thu Feb 10 01:07:17 2011
New Revision: 1069188
URL: http://svn.apache.org/viewvc?rev=1069188&view=rev
Log:
[CXF-3319] idl2wsdl defines XSD types multiple times in wsdl.
Added:
cxf/branches/2.3.x-fixes/tools/corba/src/test/resources/idl/duplicateAttribute.idl
cxf/branches/2.3.x-fixes/tools/corba/src/test/resources/idl/expected_duplicateAttribute.wsdl (with props)
Modified:
cxf/branches/2.3.x-fixes/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/AttributeVisitor.java
cxf/branches/2.3.x-fixes/tools/corba/src/test/java/org/apache/cxf/tools/corba/IDLToWSDLTest.java
Modified: cxf/branches/2.3.x-fixes/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/AttributeVisitor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/AttributeVisitor.java?rev=1069188&r1=1069187&r2=1069188&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/AttributeVisitor.java (original)
+++ cxf/branches/2.3.x-fixes/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/AttributeVisitor.java Thu Feb 10 01:07:17 2011
@@ -19,6 +19,8 @@
package org.apache.cxf.tools.corba.processors.idl;
+import java.util.HashMap;
+import java.util.Map;
import javax.wsdl.Binding;
import javax.wsdl.BindingInput;
import javax.wsdl.BindingOperation;
@@ -49,8 +51,12 @@ import org.apache.ws.commons.schema.XmlS
import org.apache.ws.commons.schema.XmlSchemaSequence;
import org.apache.ws.commons.schema.XmlSchemaType;
+
+
+
public class AttributeVisitor extends VisitorBase {
+ private static Map<String, String> duplicateTypeTrackerMap = new HashMap<String, String>();
private static final String GETTER_PREFIX = "_get_";
private static final String SETTER_PREFIX = "_set_";
private static final String RESULT_POSTFIX = "Result";
@@ -58,10 +64,13 @@ public class AttributeVisitor extends Vi
private static final String PART_NAME = "parameters";
private static final String PARAM_NAME = "_arg";
private static final String RETURN_PARAM_NAME = "return";
+
private ExtensionRegistry extReg;
private PortType portType;
private Binding binding;
+
+
public AttributeVisitor(Scope scope,
Definition defn,
@@ -239,14 +248,22 @@ public class AttributeVisitor extends Vi
XmlSchemaComplexType complex = new XmlSchemaComplexType(schema);
complex.setParticle(sequence);
-
+
+ QName qName = new QName(definition.getTargetNamespace(), name);
+
XmlSchemaElement result = new XmlSchemaElement();
- result.setName(name);
- result.setQName(new QName(definition.getTargetNamespace(), name));
result.setSchemaType(complex);
-
+ if (duplicateTypeTrackerMap.containsKey(qName.toString())) {
+ result.setName(getScope().toString() + "." + name);
+ result.setQName(new QName(definition.getTargetNamespace(), getScope().toString() + "." + name));
+ } else {
+ result.setName(name);
+ result.setQName(qName);
+ }
+
schema.getItems().add(result);
+ duplicateTypeTrackerMap.put(result.getQName().toString(), name);
return result;
}
@@ -255,9 +272,16 @@ public class AttributeVisitor extends Vi
Part part = definition.createPart();
part.setName(PART_NAME);
part.setElementName(element.getQName());
-
+
Message result = definition.createMessage();
- result.setQName(new QName(definition.getTargetNamespace(), name));
+
+ QName qName = new QName(definition.getTargetNamespace(), name);
+ if (definition.getMessage(qName) != null) {
+ String newName = getScope().toString() + "." + name;
+ qName = new QName(definition.getTargetNamespace(), newName);
+ }
+
+ result.setQName(qName);
result.addPart(part);
result.setUndefined(false);
Modified: cxf/branches/2.3.x-fixes/tools/corba/src/test/java/org/apache/cxf/tools/corba/IDLToWSDLTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/tools/corba/src/test/java/org/apache/cxf/tools/corba/IDLToWSDLTest.java?rev=1069188&r1=1069187&r2=1069188&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/tools/corba/src/test/java/org/apache/cxf/tools/corba/IDLToWSDLTest.java (original)
+++ cxf/branches/2.3.x-fixes/tools/corba/src/test/java/org/apache/cxf/tools/corba/IDLToWSDLTest.java Thu Feb 10 01:07:17 2011
@@ -135,7 +135,7 @@ public class IDLToWSDLTest extends ToolT
strBuf.append(usageBuf.toString());
checkStrings(strBuf.toString().getBytes(), bout.toByteArray());
}
-
+
public void testDetailOutput() throws Exception {
String[] args = new String[] {"-?"};
int exc = execute(args);
@@ -360,5 +360,25 @@ public class IDLToWSDLTest extends ToolT
assertEquals("IDLToWSDL Failed", noError, exc);
doTestGeneratedWsdl(expected, actual);
}
+
+
+
+ public void testDuplicateTypeGeneration() throws Exception {
+ File input = new File(getClass().getResource("/idl/duplicateAttribute.idl").toURI());
+ File expected =
+ new File(getClass().getResource("/idl/expected_duplicateAttribute.wsdl").toURI());
+
+ String[] args = new String[] {"-ow", "duplicateAttribute.wsdl",
+ "-o", output.toString(),
+ "-verbose",
+ input.toString()
+ };
+ int exc = execute(args);
+ File actual = new File(output, "duplicateAttribute.wsdl");
+
+ assertEquals("IDLToWSDL Failed", noError, exc);
+ doTestGeneratedWsdl(expected, actual);
+ }
+
}
Added: cxf/branches/2.3.x-fixes/tools/corba/src/test/resources/idl/duplicateAttribute.idl
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/tools/corba/src/test/resources/idl/duplicateAttribute.idl?rev=1069188&view=auto
==============================================================================
--- cxf/branches/2.3.x-fixes/tools/corba/src/test/resources/idl/duplicateAttribute.idl (added)
+++ cxf/branches/2.3.x-fixes/tools/corba/src/test/resources/idl/duplicateAttribute.idl Thu Feb 10 01:07:17 2011
@@ -0,0 +1,17 @@
+
+module testDuplicateAttribute {
+
+ interface Filter {
+ readonly attribute string filter_string;
+
+ void store_filter(in string myfilter);
+ string retrieve_filter(in long id);
+ };
+
+ interface MapFilter {
+ readonly attribute string filter_string;
+
+ void store_map_filter(in string myfilter);
+ string retrieve_map_filter(in long id);
+ };
+};
Added: cxf/branches/2.3.x-fixes/tools/corba/src/test/resources/idl/expected_duplicateAttribute.wsdl
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/tools/corba/src/test/resources/idl/expected_duplicateAttribute.wsdl?rev=1069188&view=auto
==============================================================================
--- cxf/branches/2.3.x-fixes/tools/corba/src/test/resources/idl/expected_duplicateAttribute.wsdl (added)
+++ cxf/branches/2.3.x-fixes/tools/corba/src/test/resources/idl/expected_duplicateAttribute.wsdl Thu Feb 10 01:07:17 2011
@@ -0,0 +1,256 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<wsdl:definitions targetNamespace="http://cxf.apache.org/bindings/corba/idl/duplicateAttribute" xmlns:corba="http://cxf.apache.org/bindings/corba" xmlns:tns="http://cxf.apache.org/bindings/corba/idl/duplicateAttribute" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
+ <corba:typeMapping targetNamespace="http://cxf.apache.org/bindings/corba/idl/duplicateAttribute/typemap"/>
+ <wsdl:types>
+ <xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://cxf.apache.org/bindings/corba/idl/duplicateAttribute" xmlns="http://cxf.apache.org/bindings/corba/idl/duplicateAttribute" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:element name="_get_filter_string">
+ <xs:complexType>
+ <xs:sequence>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="_get_filter_stringResult">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="return" type="xs:string">
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="store_filter">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="myfilter" type="xs:string">
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="store_filterResponse">
+ <xs:complexType>
+ <xs:sequence>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="retrieve_filter">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="id" type="xs:int">
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="retrieve_filterResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="return" type="xs:string">
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="testDuplicateAttribute.MapFilter._get_filter_string">
+ <xs:complexType>
+ <xs:sequence>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="testDuplicateAttribute.MapFilter._get_filter_stringResult">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="return" type="xs:string">
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="store_map_filter">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="myfilter" type="xs:string">
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="store_map_filterResponse">
+ <xs:complexType>
+ <xs:sequence>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="retrieve_map_filter">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="id" type="xs:int">
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="retrieve_map_filterResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="return" type="xs:string">
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:schema>
+ </wsdl:types>
+ <wsdl:message name="store_map_filterResponse">
+ <wsdl:part name="outparameter" element="tns:store_map_filterResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="testDuplicateAttribute.MapFilter._get_filter_stringResponse">
+ <wsdl:part name="parameters" element="tns:testDuplicateAttribute.MapFilter._get_filter_stringResult">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="store_filter">
+ <wsdl:part name="inparameter" element="tns:store_filter">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="_get_filter_string">
+ <wsdl:part name="parameters" element="tns:_get_filter_string">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="testDuplicateAttribute.MapFilter._get_filter_string">
+ <wsdl:part name="parameters" element="tns:testDuplicateAttribute.MapFilter._get_filter_string">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="retrieve_map_filter">
+ <wsdl:part name="inparameter" element="tns:retrieve_map_filter">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="retrieve_filter">
+ <wsdl:part name="inparameter" element="tns:retrieve_filter">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="_get_filter_stringResponse">
+ <wsdl:part name="parameters" element="tns:_get_filter_stringResult">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="store_map_filter">
+ <wsdl:part name="inparameter" element="tns:store_map_filter">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="retrieve_map_filterResponse">
+ <wsdl:part name="outparameter" element="tns:retrieve_map_filterResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="retrieve_filterResponse">
+ <wsdl:part name="outparameter" element="tns:retrieve_filterResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="store_filterResponse">
+ <wsdl:part name="outparameter" element="tns:store_filterResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:portType name="testDuplicateAttribute.Filter">
+ <wsdl:operation name="_get_filter_string">
+ <wsdl:input name="_get_filter_string" message="tns:_get_filter_string">
+ </wsdl:input>
+ <wsdl:output name="_get_filter_stringResponse" message="tns:_get_filter_stringResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="store_filter">
+ <wsdl:input name="store_filterRequest" message="tns:store_filter">
+ </wsdl:input>
+ <wsdl:output name="store_filterResponse" message="tns:store_filterResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="retrieve_filter">
+ <wsdl:input name="retrieve_filterRequest" message="tns:retrieve_filter">
+ </wsdl:input>
+ <wsdl:output name="retrieve_filterResponse" message="tns:retrieve_filterResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:portType name="testDuplicateAttribute.MapFilter">
+ <wsdl:operation name="_get_filter_string">
+ <wsdl:input name="testDuplicateAttribute.MapFilter._get_filter_string" message="tns:testDuplicateAttribute.MapFilter._get_filter_string">
+ </wsdl:input>
+ <wsdl:output name="testDuplicateAttribute.MapFilter._get_filter_stringResponse" message="tns:testDuplicateAttribute.MapFilter._get_filter_stringResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="store_map_filter">
+ <wsdl:input name="store_map_filterRequest" message="tns:store_map_filter">
+ </wsdl:input>
+ <wsdl:output name="store_map_filterResponse" message="tns:store_map_filterResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="retrieve_map_filter">
+ <wsdl:input name="retrieve_map_filterRequest" message="tns:retrieve_map_filter">
+ </wsdl:input>
+ <wsdl:output name="retrieve_map_filterResponse" message="tns:retrieve_map_filterResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="testDuplicateAttribute.MapFilterCORBABinding" type="tns:testDuplicateAttribute.MapFilter">
+ <corba:binding repositoryID="IDL:testDuplicateAttribute/MapFilter:1.0"/>
+ <wsdl:operation name="_get_filter_string">
+ <corba:operation name="_get_filter_string">
+ <corba:return name="return" idltype="corba:string"/>
+ </corba:operation>
+ <wsdl:input name="testDuplicateAttribute.MapFilter._get_filter_string">
+ </wsdl:input>
+ <wsdl:output name="testDuplicateAttribute.MapFilter._get_filter_stringResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="store_map_filter">
+ <corba:operation name="store_map_filter">
+ <corba:param mode="in" name="myfilter" idltype="corba:string"/>
+ </corba:operation>
+ <wsdl:input name="store_map_filterRequest">
+ </wsdl:input>
+ <wsdl:output name="store_map_filterResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="retrieve_map_filter">
+ <corba:operation name="retrieve_map_filter">
+ <corba:param mode="in" name="id" idltype="corba:long"/>
+ <corba:return name="return" idltype="corba:string"/>
+ </corba:operation>
+ <wsdl:input name="retrieve_map_filterRequest">
+ </wsdl:input>
+ <wsdl:output name="retrieve_map_filterResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:binding name="testDuplicateAttribute.FilterCORBABinding" type="tns:testDuplicateAttribute.Filter">
+ <corba:binding repositoryID="IDL:testDuplicateAttribute/Filter:1.0"/>
+ <wsdl:operation name="_get_filter_string">
+ <corba:operation name="_get_filter_string">
+ <corba:return name="return" idltype="corba:string"/>
+ </corba:operation>
+ <wsdl:input name="_get_filter_string">
+ </wsdl:input>
+ <wsdl:output name="_get_filter_stringResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="store_filter">
+ <corba:operation name="store_filter">
+ <corba:param mode="in" name="myfilter" idltype="corba:string"/>
+ </corba:operation>
+ <wsdl:input name="store_filterRequest">
+ </wsdl:input>
+ <wsdl:output name="store_filterResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="retrieve_filter">
+ <corba:operation name="retrieve_filter">
+ <corba:param mode="in" name="id" idltype="corba:long"/>
+ <corba:return name="return" idltype="corba:string"/>
+ </corba:operation>
+ <wsdl:input name="retrieve_filterRequest">
+ </wsdl:input>
+ <wsdl:output name="retrieve_filterResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="testDuplicateAttribute.MapFilterCORBAService">
+ <wsdl:port name="testDuplicateAttribute.MapFilterCORBAPort" binding="tns:testDuplicateAttribute.MapFilterCORBABinding">
+ <corba:address location="IOR:"/>
+ </wsdl:port>
+ </wsdl:service>
+ <wsdl:service name="testDuplicateAttribute.FilterCORBAService">
+ <wsdl:port name="testDuplicateAttribute.FilterCORBAPort" binding="tns:testDuplicateAttribute.FilterCORBABinding">
+ <corba:address location="IOR:"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
Propchange: cxf/branches/2.3.x-fixes/tools/corba/src/test/resources/idl/expected_duplicateAttribute.wsdl
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/branches/2.3.x-fixes/tools/corba/src/test/resources/idl/expected_duplicateAttribute.wsdl
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: cxf/branches/2.3.x-fixes/tools/corba/src/test/resources/idl/expected_duplicateAttribute.wsdl
------------------------------------------------------------------------------
svn:mime-type = text/xml