Search code examples
javaweb-serviceswsdlwsdl2java

org.apache.axis.wsdl.toJava.DuplicateFileException: Duplicate file name:


I am trying to create client project from WSDL file using Axis 1.4 (I don't have other choices, even cannot use Axis 2) and getting following error. Can any one suggest me how can I resolve it? The WSDL file is provided by vendor.

org.apache.axis.wsdl.toJava.DuplicateFileException: Duplicate file name: C:\Documents and Settings\My Documents\CalculateTax\com\NewProj\CompanyCodeType.java.  
Hint: you may have mapped two namespaces with elements of the same name to the same package name.
    at org.apache.axis.wsdl.toJava.JavaWriter.generate(JavaWriter.java:110)
    at org.apache.axis.wsdl.toJava.JavaBeanWriter.generate(JavaBeanWriter.java:1405)
    at org.apache.axis.wsdl.toJava.JavaTypeWriter.generate(JavaTypeWriter.java:113)
    at org.apache.axis.wsdl.toJava.JavaGeneratorFactory$Writers.generate(JavaGeneratorFactory.java:421)
    at org.apache.axis.wsdl.gen.Parser.generateTypes(Parser.java:547)
    at org.apache.axis.wsdl.gen.Parser.generate(Parser.java:432)
    at org.apache.axis.wsdl.gen.Parser.access$000(Parser.java:45)
    at org.apache.axis.wsdl.gen.Parser$WSDLRunnable.run(Parser.java:362)
    at java.lang.Thread.run(Unknown Source)

Solution

  • you don't have to use Axis 2.

    For example, if you have a part of wsdl like this:

      ...
      <xs:complexType name="Address">
        <xs:sequence>
          <xs:element name="Country" type="xs:string"/>
          <xs:element name="City" type="xs:string"/>
          <xs:element name="Town" type="xs:string"/>
        </xs:sequence>
      </xs:complexType>
      <xs:complexType name="address">
        <xs:sequence>
          <xs:element name="leftSideOfAt" type="xs:string"/>
          <xs:element name="domain" type="xs:string"/>
        </xs:sequence>
      </xs:complexType>
      <xs:element name="OwnerAddress" type="tns:Address" />
      <xs:element name="EmailAddress" type="tns:address" />
      <xs:element name="CompanyEmailAddress" type="tns:address" />
      ...
    

    This is a legal WSDL definition but Axis is failed. You can fix this problem with renaming complexTypes. For above example:

      ...
      <xs:complexType name="Address">
        <xs:sequence>
          <xs:element name="Country" type="xs:string"/>
          <xs:element name="City" type="xs:string"/>
          <xs:element name="Town" type="xs:string"/>
        </xs:sequence>
      </xs:complexType>
      <xs:complexType name="Email">
        <xs:sequence>
          <xs:element name="leftSideOfAt" type="xs:string"/>
          <xs:element name="domain" type="xs:string"/>
        </xs:sequence>
      </xs:complexType>
      <xs:element name="OwnerAddress" type="tns:Address" />
      <xs:element name="EmailAddress" type="tns:Email" />
      <xs:element name="CompanyEmailAddress" type="tns:Email" />
      ...
    

    The point is when you write a name of complexType as "PascalCase", it conflicts with another one!