use*_*704 5 wsimport maven-jaxb2-plugin jax-ws-customization jaxb-xew-plugin
我正在使用maven-jaxws-plugin从我的wsdl,schema中生成java类.它不会在生成的类中生成@XmlElementWrapper注释.从这篇文章我明白我需要使用jaxb-xew-plugin但是我无法使用maven-jaxws-plugin.任何帮助,将不胜感激.这是我试过的配置
<plugin>
<groupId>org.jvnet.jax-ws-commons</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<goals>
<goal>wsimport</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<xjcArgs>
<xjcArg>-no-header</xjcArg>
<xjcArg>-Xxew</xjcArg>
<xjcArg>-Xxew:instantiate lazy</xjcArg>
<xjcArg>-Xxew:delete</xjcArg>
</xjcArgs>
<extension>true</extension>
<wsdlDirectory>${basedir}/src/main/resources</wsdlDirectory>
<wsdlFiles>
<wsdlFile>attribute-service.wsdl</wsdlFile>
</wsdlFiles>
<sourceDestDir>${project.build.directory}/generated</sourceDestDir>
<verbose>true</verbose>
<keep>true</keep>
<plugins>
<plugin>
<groupId>com.github.jaxb-xew-plugin</groupId>
<artifactId>jaxb-xew-plugin</artifactId>
<version>1.0</version>
</plugin>
</plugins>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
如果它只能与maven-jaxb2-plugin集成,你可以帮我搞网络服务吗?基本上如何指定wsdl以及如何生成Service类?(使用@WebService注释)
谢谢,
Bhagya
小智 3
虽然这篇文章在我写这篇文章时已经有 10 个月了,但我还是回答它以防有人需要它。
使用 jaxws-maven-plugin 并在 jaxb-xew-plugin 的帮助下,您可以为列表/数组对象生成 @XmlElementWrapper 注释
假设您的 wsdl 具有如下架构:
<xs:element name="books" minOccurs="0" >
<xs:complexType>
<xs:sequence>
<xs:element name="book" type="Book" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
</xs:element>
Run Code Online (Sandbox Code Playgroud)
它生成java为:
@XmlElementWrapper(name = "books")
@XmlElement(name = "book")
protected List<Book> books;
Run Code Online (Sandbox Code Playgroud)
这是构建/插件
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>1.12</version>
<configuration>
<wsdlDirectory>${project.basedir}/src/main/webapp/WEB-INF/wsdl/</wsdlDirectory>
<xjcArgs>
<xjcArg>-no-header</xjcArg>
<xjcArg>-Xxew</xjcArg>
<xjcArg>-Xxew:instantiate lazy</xjcArg>
<xjcArg>-Xxew:delete</xjcArg>
</xjcArgs>
</configuration>
<executions>
<execution>
<id>wsdl_import</id>
<goals>
<goal>wsimport</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.github.jaxb-xew-plugin</groupId>
<artifactId>jaxb-xew-plugin</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-xjc</artifactId>
<version>2.2.4-1</version>
</dependency>
</dependencies>
</plugin>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9263 次 |
| 最近记录: |