【问题标题】:cxf-codegen-plugin and "Two declarations cause a collision in the ObjectFactory class."cxf-codegen-plugin 和“两个声明导致 ObjectFactory 类发生冲突。”
【发布时间】:2016-01-06 06:16:47
【问题描述】:

我们正在尝试生成一个 Java SOAP 客户端以与外部服务集成。由于这是一家外部公司,因此无法更改 WSDL。

尝试使用 cxf-codegen-plugin Maven 插件生成客户端时,我们收到以下错误:

Two declarations cause a collision in the ObjectFactory class.

问题与 WSDL 中的以下声明有关:

<s:element name="CallSomeMethod">
    <s:complexType>
      <s:sequence>
        <s:element minOccurs="1" maxOccurs="1" name="GetSomeDataResult" type="tns:InterfaceReturnCode" />
        <s:element minOccurs="0" maxOccurs="1" name="getSomeDataResult" type="tns:GetSomeDataResult" />
      </s:sequence>
    </s:complexType>
  </s:element>

很明显可以看出问题出在哪里。我的问题是,WSDL 似乎可以通过在线通用 SOAP 客户端很好地导入,所以它至少必须是有效的。我还读到生成没有-p 选项的Java 代码将导致生成器创建单独的包,这应该可以解决问题。但是,如何使用 cxf-codegen-plugin Maven 插件来做到这一点?

【问题讨论】:

    标签: java soap cxf-codegen-plugin


    【解决方案1】:

    不确定您是否找到了解决方案,但可能会对其他人有所帮助。 我尝试了以下方法,它对我有用。 我使用 cxf-codegen-plugin Maven 插件并得到上述错误。 所以首先我在我的 pom.xml 中使用了 -autoNameResolution。这解决了一些重复,但仍然很少。 所以在我的 pom.xml 中,我使用“-p”参数将冲突的命名空间放在单独的目录中,并且它起作用了。

    示例(来自我的 pom.xml 的 sn-p):

    <wsdlOption>
    
    <wsdl>${basedir}/src/main/resources/wsdl/<wsdl_file>.wsdl</wsdl>
    
    <wsdlLocation>http://host.does.not.exist/src/main/resources/wsdl/<wsdl_file>.wsdl</wsdlLocation>
                                        <extraargs>
                                            <extaarg>-client</extaarg>
                                            <extaarg>-verbose</extaarg>
                                            <extraarg>-autoNameResolution</extraarg>
    
                                            <extraarg>-p</extraarg>
                                            <extraarg><conflicting_namespace>=<package_where_the_namepsace_should_get_created></extraarg>
                                            <extraarg>-p</extraarg>
                                            <extraarg><conflicting_namespace>=<package_where_the_namepsace_should_get_created></extraarg>
                                        </extraargs>
                                        <packagenames>
                                            <packagename><path_to_package></packagename>
                                        </packagenames>
                                  </wsdlOption>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-11-05
      • 2011-11-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-23
      • 2012-04-27
      • 1970-01-01
      相关资源
      最近更新 更多