JAXWS 代码生成和与 Spring for JDK1.5 一起实现

发布于 2024-08-09 22:20:13 字数 761 浏览 12 评论 0原文

我们正在尝试从一系列 WSDL(每个都有自己的 XSD)生成源代码存根。我们可以很好地做到这一点并且在 JDK1.6 下完美工作,但是我们需要它在 JDK1.5 下工作。

我们使用 jaxws-maven-plugin 来生成源代码,但这取决于可用的 wsimport 二进制文件(这在 JDK1.5 中不可用)。我们找到了一个解决方法,我们现在可以生成源代码代码。

当我们尝试将编译的存根代码与 Spring (2.5.6) 一起使用时,最后一个问题就出现了,我们使用 JaxWsPortProxyFactoryBean 与生成的客户端代码进行交互。我们得到一个 java.lang.NoClassDefFoundError:javax/xml/ws/soap/Addressing。我调查了原因,发现 javax.xml.ws/javax-api/2.1 依赖项不包含此类。我将版本号升级到 2.1-1,现在当我们构建项目(生成源代码)时,我们收到以下错误:

cannot find symbol
symbol : method partName()
location : @interface javax.jws.WebParam

任何人都可以提供解决方案,以便我们可以生成 JAXWS 客户端存根代码并使其与JaxWsPortProxyFactoryBean?

预先感谢

乔纳森

We're trying to generate source code stubs from a series of WSDLs (each with their own XSDs). We can do this fine and works perfectly under JDK1.6, however we need it to work under JDK1.5.

We're using jaxws-maven-plugin to generate the source code, however it depends on the wsimport binary being available (this is not available in JDK1.5). We found a work around for this, we can now generate the source code.

The final problem comes when we try and use the compiled stub code with Spring (2.5.6) we're using a JaxWsPortProxyFactoryBean to interface with the generated client code. We get a java.lang.NoClassDefFoundError: javax/xml/ws/soap/Addressing. I investigated why this was and found that the javax.xml.ws/javax-api/2.1 dependency did not contain this class. I upgraded the version number to 2.1-1 and now when we build the project (to generate the source code) we get the following error:

cannot find symbol
symbol : method partName()
location : @interface javax.jws.WebParam

Can anyone provide a solution to this so we can generate our JAXWS client stub code and make it work with the JaxWsPortProxyFactoryBean?

Thanks in advance

Jonathan

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

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

发布评论

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

评论(3

静水深流 2024-08-16 22:20:13

看来他们弄乱了这个罐子,请参阅 此链接

解决方法如下:

  1. 删除 M2_REPO/javax/xml/ws/jaxws-api/2.1/ 目录
  2. 使用此依赖项

    <依赖>;
     javax.xml.ws
     jaxws-api;
     <版本>2.1
    
    
  3. 将这些存储库放在列表的顶部:

    <预><代码><存储库>;
    javanet
    http://download.java.net/maven/2/

    <存储库>
    javanet 遗留
    http://download.java.net/maven/1/
    <布局>旧版

It seems that they mess with this jar, see this link.

The workaround is the following :

  1. delete M2_REPO/javax/xml/ws/jaxws-api/2.1/ directory
  2. use this dependency

    <dependency>
     <groupId>javax.xml.ws</groupId>
     <artifactId>jaxws-api</artifactId>
     <version>2.1</version>
    </dependency>
    
  3. put these repositories at the top of your list :

    <repository>
     <id>javanet</id>
     <url>http://download.java.net/maven/2/</url>
    </repository>
    <repository>
     <id>javanet legacy</id>
     <url>http://download.java.net/maven/1/</url>
     <layout>legacy</layout>
    </repository>
    
知足的幸福 2024-08-16 22:20:13

我设法解决了这个问题,经过几个小时的研究依赖项并查看每个依赖项的内部内容,我发现依赖项 javax.xml.ws:jaxws-api:2.1-1 是必需的,但我们必须获取一份副本 这

<dependency>
    <groupId>javax.jws</groupId>
    <artifactId>jsr181</artifactId>
    <version>1.0</version>
</dependency>

然后我必须在应用程序的 pom.xml 中包含以下依赖项:

<dependency>
    <groupId>javax.jws</groupId>
    <artifactId>jsr181-api</artifactId>
    <version>1.0-MR1</version>
</dependency>

远非理想,我们必须在 Maven 存储库中维护一个单独的专有依赖项,并记住包含此依赖项。烦人的是 Maven 不允许我按版本号排除(只能按 groupId 和 artifactId)。如果有人有改进此解决方案的建议,请告诉我。

感谢您的帮助。

I managed to solve this one, after hours of studying the dependencies and looking at what each of them had inside I discovered that the dependency javax.xml.ws:jaxws-api:2.1-1 was required, but we had to take a copy of this dependency and take out:

<dependency>
    <groupId>javax.jws</groupId>
    <artifactId>jsr181</artifactId>
    <version>1.0</version>
</dependency>

Then I had to include the following dependency in the pom.xml of my application:

<dependency>
    <groupId>javax.jws</groupId>
    <artifactId>jsr181-api</artifactId>
    <version>1.0-MR1</version>
</dependency>

This is far from ideal, we have to maintain a separate proprietary dependency in our maven repository and remember to include this dependency. The annoying thing is Maven doesn't allow me to exclude by version number (only by groupId and artifactId). If anyone has a suggestion to make this solution better please let me know.

Thanks for your help.

奢欲 2024-08-16 22:20:13

我们使用 jaxws-maven-plugin 来生成源代码,但这取决于可用的 wsimport 二进制文件(这在 JDK1.5 中不可用)。我们找到了一个解决方法,我们现在可以生成源代码代码。

实际上,作为 JAX-WS 一部分的 wsimport 并不包含在 Java 5 中(与包含 JAX-WS 2.x 的 Java 6 不同,Java 6u14 包含 JAX-WS 2.1.6),但它只要您提供,就可以用于 Java 5。奇怪的部分是 jaxws-maven-plugin 声明了这些依赖项(例如参见 jaxws-maven-plugin-1.12.pom),某处一定存在类加载问题,因此需要“解决方法”。

当我们尝试在 Spring (2.5.6) 中使用编译的存根代码时,最后一个问题出现了,我们使用 JaxWsPortProxyFactoryBean 与生成的客户端代码进行交互。我们得到一个 java.lang.NoClassDefFoundError:javax/xml/ws/soap/Addressing。 [...]

您使用的插件版本到底是什么?我建议使用 1.12 版本以及与 pom.xml 插件中相同版本的 jax-ws:

<dependency>
  <groupId>com.sun.xml.ws</groupId>
  <artifactId>jaxws-tools</artifactId>
  <version>2.1.7</version>
</dependency>

We're using jaxws-maven-plugin to generate the source code, however it depends on the wsimport binary being available (this is not available in JDK1.5). We found a work around for this, we can now generate the source code.

Actually, wsimport, which is part of JAX-WS, is not included in Java 5 (unlike Java 6 which includes JAX-WS 2.x, Java 6u14 includes JAX-WS 2.1.6) but it is available for Java 5 as long as you provide it. The odd part is that the jaxws-maven-plugin declare these dependencies (see for example jaxws-maven-plugin-1.12.pom), there must be a classloading issue somewhere, hence the "work around".

The final problem comes when we try and use the compiled stub code with Spring (2.5.6) we're using a JaxWsPortProxyFactoryBean to interface with the generated client code. We get a java.lang.NoClassDefFoundError: javax/xml/ws/soap/Addressing. [...]

What version of the plugin are you using exactly? I'd suggest to use the version 1.12 and the same version of jax-ws as in the plugin in your pom.xml:

<dependency>
  <groupId>com.sun.xml.ws</groupId>
  <artifactId>jaxws-tools</artifactId>
  <version>2.1.7</version>
</dependency>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文