WSDL2Code (Maven) 自动生成损坏的类(包)

发布于 2024-07-09 02:20:38 字数 1892 浏览 16 评论 0原文

我目前正在用 Axis2 替换 IBM WebService 框架。 从 WSDL 文件生成代码时,我使用 Maven 插件 WSDL2Code。 然而,创建的代码总是错误的。 或者更确切地说,包名总是错误的,这反过来又使得每个被调用的方法都无法调用(产生更多的错误,在 eclipse 中多达 10.000+ 错误)。

下面是实际发生的情况的示例(这只是我专门为获取建议而制作的示例):

      <plugin>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-wsdl2code-maven-plugin</artifactId>
            <version>1.4.1</version>
            <executions>
                <execution>
                    <id>Test</id>
                    <goals>
                        <goal>wsdl2code</goal>
                    </goals>
                    <configuration>
                        <packageName>test.testpackage</packageName>
                        <databindingName>xmlbeans</databindingName>
                        <wsdlFile>${basedir}/wsdl/service.wsdl</wsdlFile>
                        <outputDirectory>${basedir}/testdirectory</outputDirectory>
                    </configuration>
                </execution>
            </executions>
        </plugin>

理论上,这应该在目录 testdirectory/test/testpackage 中生成包名称为“test.testpackage”的代码。 但是,它会在目录 testdirectory.src.test.testpackage 中创建以下包:Src.test.testpackage。 它总是在包名称和目录中添加“src” - 如果我将包名称更改为 src.test.testpackage,它将生成以下包:src.src.test.testpackage。

当然,这会导致一个巨大的问题,因为每个生成的文件都有以下错误: “声明的包“src.test.testpackage”与预期的包不匹配 “src.src.test.testpackage”

我在这里完全不知所措。 我根本找不到任何理由为什么它应该在任何地方添加“src”。 我注意到一个自动生成的 build.xml 文件包含一个名为 sourcedirectory = x/src (或类似的值)的值,但我无能为力来影响这个值(尝试更改它然后保存文件没有什么区别) ,显然,因为它只是在我下次运行 Maven 时再次生成)。

哦,我通常使用命令“mvn clean install”和 WSDL2Code 版本 1.4.1,所以它不是旧的 wsdl2code:wsdl2code bug 之一。

如果有人知道这里到底出了什么问题,我将不胜感激。

提前致谢。

I am currently in the process of replacing the IBM WebService framework with Axis2. When generating the code from the WSDL file, I use the Maven plugin WSDL2Code. However, the code created is always wrong. Or rather, the packagenames are always wrong, which in turn makes every method called uncallable (creating even more errors, up to 10.000+ errors in eclipse).

Here's an example of what is actually going on (this is just an example I made specifically to get advice):

      <plugin>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-wsdl2code-maven-plugin</artifactId>
            <version>1.4.1</version>
            <executions>
                <execution>
                    <id>Test</id>
                    <goals>
                        <goal>wsdl2code</goal>
                    </goals>
                    <configuration>
                        <packageName>test.testpackage</packageName>
                        <databindingName>xmlbeans</databindingName>
                        <wsdlFile>${basedir}/wsdl/service.wsdl</wsdlFile>
                        <outputDirectory>${basedir}/testdirectory</outputDirectory>
                    </configuration>
                </execution>
            </executions>
        </plugin>

In theory, this should generate code with the package name "test.testpackage" in the directory testdirectory/test/testpackage. However, instead it creates the following package: Src.test.testpackage in the directory testdirectory.src.test.testpackage. It always adds a "src" to both package name and directory - if I change the package name to src.test.testpackage, it will generate the following package: src.src.test.testpackage.

This, of course, leads to a huge problem, because every generated file has the following error:
"The declared package "src.test.testpackage" does not match the expected package
"src.src.test.testpackage"

I'm at a complete loss here. I simply can't find any reason at all why it should add "src" everywhere. I've noticed an auto-generated build.xml file containing a value called sourcedirectory = x/src (or something similar), but there's nothing I can do to affect this value (trying to change it and then save the file makes no difference, obviously, since it's just generated again the next time I run maven).

Oh, and I generally use the command "mvn clean install" and version 1.4.1 of WSDL2Code, so it's not one of the old wsdl2code:wsdl2code bugs.

If anyone has any idea of what is actually wrong here, I'd greatly appreciate it.

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

清风不识月 2024-07-16 02:20:38

版本 1.4.1 还有一些未真正记录的配置选项(查看 org.apache.axis2.maven2.wsdl2code.WSDL2CodeMojo 的源代码)...

只需使用true即可 - 这应该可以解决你的问题:-)

Version 1.4.1 has a few more configuration options that are not really documented (have a look at the the source of org.apache.axis2.maven2.wsdl2code.WSDL2CodeMojo)...

Just use <flattenFiles>true</flattenFiles> - that should solve your problem :-)

灯下孤影 2024-07-16 02:20:38

这个问题很老了,所以我不知道你是否仍然遇到问题......

我建议使用 Axistools Maven 插件,它在我们的案例中效果很好。

This question is quite old, so I don't know if you're still having the problem...

I would recommend using Axistools Maven Plugin instead, it worked great in our case.

陌路黄昏 2024-07-16 02:20:38

也许 'src' 是 ${basedir} 的一部分?

Maybe 'src' is part of ${basedir} ?

夏末 2024-07-16 02:20:38

恐怕不是。 即使是这样,也不应该出现奇怪的问题 - 路径将是正确的 testdirectory/src/test/testpackage,因此不会导致包名称出现问题。 现在出现问题是因为它被放置在包不期望的目录中 - 它期望 ${basedir}/testdirectory/insert.package.here.divided.by./,但它得到 ${basedir}/testdirectory/src /insert.package.here.divided.by./。

src 不应出现在路径的该部分中。

I'm afraid not. Even if it was, the strange problem shouldn't occur then - the path would then be correct being testdirectory/src/test/testpackage, thus causing no problem with the package name. The problem now arises because it is placed in a directory the package does not expect - it expects ${basedir}/testdirectory/insert.package.here.divided.by./, but instead it gets ${basedir}/testdirectory/src/insert.package.here.divided.by./.

The src should not be present in that part of the path.

鸵鸟症 2024-07-16 02:20:38

这与 maven/axis2 的那些“天才”(或用户)有关,他们实际上为你做出了决定......请看这个:
[Axis2 邮件列表条目][1]

[1]: http ://markmail.org/search/?q=[Axis2]+indrit#query:[Axis2 邮件列表条目]%20indrit+page:1+mid:a34wbp7l3pljagsz+state:results

This is connected with those "genius" of(or user of) maven/axis2 that practically takes decisions for you ... see this:
[Axis2 mailing list entry][1]

[1]: http://markmail.org/search/?q=[Axis2]+indrit#query:[Axis2 Mailing List entry]%20indrit+page:1+mid:a34wbp7l3pljagsz+state:results

断念 2024-07-16 02:20:38

我最近遇到了同样的问题,并通过修改 targetSourceFolderLocation 解决了它,如下所示。 默认情况下,它指向 src 目录。 因此它在您的情况下生成了名为 testdirectory.src.test.testpackage 的包结构。 请使用下面的配置,它应该按预期工作。

<outputDirectory>${basedir}</outputDirectory>
<packageName>test.testpackage</packageName>
<targetSourceFolderLocation>testdirectory</targetSourceFolderLocation>

I have recently faced the same issue and solved it by modifying the targetSourceFolderLocation as below. By default, it points to the src directory. so it generated package structure as testdirectory.src.test.testpackage in your case. please use below config and it should work as expected.

<outputDirectory>${basedir}</outputDirectory>
<packageName>test.testpackage</packageName>
<targetSourceFolderLocation>testdirectory</targetSourceFolderLocation>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文