简体   繁体   English

JDAX1.5的JAXWS代码生成和实现

[英]JAXWS code generation and implementation along side Spring for JDK1.5

We're trying to generate source code stubs from a series of WSDLs (each with their own XSDs). 我们正在尝试从一系列WSDL(每个都有自己的XSD)生成源代码存根。 We can do this fine and works perfectly under JDK1.6, however we need it to work under JDK1.5. 我们可以做得很好并在JDK1.6下完美运行,但我们需要它在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). 我们使用jaxws-maven-plugin来生成源代码,但是它依赖于可用的wsimport二进制文件(这在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. 最后一个问题出现在我们尝试使用Spring编译的存根代码(2.5.6)时,我们使用JaxWsPortProxyFactoryBean来连接生成的客户端代码。 We get a java.lang.NoClassDefFoundError: javax/xml/ws/soap/Addressing. 我们得到一个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. 我调查了为什么会这样,并发现javax.xml.ws/javax-api/2.1依赖项不包含此类。 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: 我将版本号升级到2.1-1,现在当我们构建项目(生成源代码)时,我们收到以下错误:

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? 任何人都可以为此提供解决方案,以便我们可以生成JAXWS客户端存根代码并使其与JaxWsPortProxyFactoryBean一起使用吗?

Thanks in advance 提前致谢

Jonathan 乔纳森

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 删除M2_REPO / javax / xml / ws / jaxws-api / 2.1 /目录
  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> 

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: 我设法解决了这个问题,经过几个小时的研究依赖关系并查看每个内部的内容后,我发现需要依赖javax.xml.ws:jaxws-api:2.1-1,但我们不得不复制一份这种依赖关系并取出:

<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: 然后我必须在我的应用程序的pom.xml中包含以下依赖项:

<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. 这远非理想,我们必须在我们的maven存储库中维护一个单独的专有依赖关系并记住包含这种依赖关系。 The annoying thing is Maven doesn't allow me to exclude by version number (only by groupId and artifactId). 令人烦恼的是Maven不允许我按版本号排除(仅限于groupId和artifactId)。 If anyone has a suggestion to make this solution better please let me know. 如果有人建议更好地解决这个问题,请告诉我。

Thanks for your help. 谢谢你的帮助。

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). 我们使用jaxws-maven-plugin来生成源代码,但是它依赖于可用的wsimport二进制文件(这在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. 实际上, wsimport ,这是JAX-WS的一部分,不包括在Java 5的(不像Java 6中,其中包括JAX-WS 2.x的,爪哇6u14包括JAX-WS 2.1.6),但它可用于Java 5只要正如你提供的那样。 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". 奇怪的是,jaxws-maven-plugin声明了这些依赖项(例如参见jaxws-maven-plugin-1.12.pom ),某处必须存在类加载问题,因此“解决”问题。

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. 最后一个问题出现在我们尝试使用Spring编译的存根代码(2.5.6)时,我们使用JaxWsPortProxyFactoryBean来连接生成的客户端代码。 We get a java.lang.NoClassDefFoundError: javax/xml/ws/soap/Addressing. 我们得到一个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 : 我建议使用版本1.12和相同版本的jax-ws,如pom.xml中的插件:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM