org.apache.axis.wsdl.toJava.DuplicateFileException

2019-07-13 02:39发布

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)

3条回答
Evening l夕情丶
2楼-- · 2019-07-13 03:09

The issue happens when you try to generate java client using a wsdl with same element names. Please change the element names and try. Otherwise you can use the eclipse tool for generating java client. It will automatically detect the same element names and create separate packages for the same. To generate java client using Eclipse : Right click on wsdl file > Web Services > Generate Client. This should help you.

查看更多
爷的心禁止访问
3楼-- · 2019-07-13 03:14

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!

查看更多
Anthone
4楼-- · 2019-07-13 03:34

The Axis 1.4 bug description is (https://issues.apache.org/jira/browse/AXIS-2606)

Hint: you may have mapped two namespaces with elements of the same name to the same package name.

Thus you can solve this by leaving out the optional parameter

-p, --package <argument>
    override all namespace to package mappings, use this package
     name instead

... and it will generate your WSDL classes without errors. You can refactor them later if necessary.

查看更多
登录 后发表回答