pat*_*s91 5 java soap wsdl xjc maven-jaxb2-plugin
我有问题maven-jaxb2-plugin.我想要实现的是从x个不同的wsdl生成源到不同的包.
我想避免使用多个方法,<execution>所以当我添加另一个wsdl时,我可以保持pom.xml不变.
我配置了像这样的maven插件:
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.12.1</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<schemaLanguage>WSDL</schemaLanguage>
<schemaDirectory>src/main/resources/webservice/wsdl</schemaDirectory>
<schemaIncludes>
<include>orig/*.wsdl</include>
</schemaIncludes>
<bindingDirectory>src/main/resources/webservice/xjb</bindingDirectory>
<bindingIncludes>
<include>orig/*.xjb</include>
</bindingIncludes>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
在我的理解中,这种方式我指定了.wsdl位置以及绑定文件位置.
现在在一个示例绑定文件中(所有这些都以相同的方式构造)我得到以下代码:
<?xml version="1.0" encoding="UTF-8"?>
<jaxb:bindings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xsi:schemaLocation="http://java.sun.com/xml/ns/jaxb http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
jaxb:version="2.1">
<jaxb:bindings schemaLocation="../../wsdl/orig/soap1.wsdl"
node="*/xs:schema">
<jaxb:schemaBindings>
<jaxb:package name="my.package.com.soap1" />
</jaxb:schemaBindings>
</jaxb:bindings>
</jaxb:bindings>
Run Code Online (Sandbox Code Playgroud)
另一项服务是soap2,soap3等,它们都有类似的绑定文件.如果我理解这是正确的,多亏了这个connfig我应该能够在单独的包中为我的肥皂生成域对象.
但是当我运行时,maven clean compile我得到以下输出:
[ERROR] Error while parsing schema(s).Location [ file:/C:/Users/me/workspace/orig-project/src/main/resources/webservice/wsdl/orig/soap1.wsdl{202,39}].
org.xml.sax.SAXParseException; systemId: file:/C:/Users/me/workspace/orig-project/src/main/resources/webservice/wsdl/orig/soap1.wsdl; lineNumber: 202; columnNumber: 39; 'Line' **is already defined**
Run Code Online (Sandbox Code Playgroud)
更重要的是,出于测试目的,我尝试配置插件来单独处理每个wsdl <execution>(我想在最终代码中避免这种情况),我观察到的是在第一个ex之后.处理了soap1.wsdl,正确创建了包,但根本没有创建其他soap.wsdl的包.(只有第一次处理).
有什么问题,如果有可能实现我的目标?
更新: 为了澄清我想要实现的目标,我将发布适用于我的解决方案,但它强制我每次添加新的webservice时编辑POM:
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.12.1</version>
<executions>
<execution>
<id>soap1</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<schemaDirectory>src/main/resources/webservice/wsdl</schemaDirectory>
<schemaIncludes>
<include>Soap1.wsdl</include>
</schemaIncludes>
<generatePackage>my.package.com.soap1</generatePackage>
</configuration>
</execution>
<execution>
<id>soap2</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<schemaDirectory>src/main/resources/webservice/wsdl</schemaDirectory>
<schemaIncludes>
<include>Soap2.wsdl</include>
</schemaIncludes>
<generatePackage>my.package.com.soap2</generatePackage>
</configuration>
</execution>
<execution>
<id>soap3</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<schemaDirectory>src/main/resources/webservice/wsdl</schemaDirectory>
<schemaIncludes>
<include>Soap3.wsdl</include>
</schemaIncludes>
<bindingDirectory>src/main/resources/webservice/xjb</bindingDirectory>
<bindingIncludes>
<include>soap3.xjb</include>
</bindingIncludes>
<generatePackage>my.package.com.soap3</generatePackage>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
看起来(也许?)有一些问题:
<jaxb:schemaBindings>
<jaxb:package name="my.package.com.soap1" />
</jaxb:schemaBindings>
Run Code Online (Sandbox Code Playgroud)
在我的第一个(和通缉)解决方案.有任何想法吗?
| 归档时间: |
|
| 查看次数: |
1922 次 |
| 最近记录: |