Binding WSDL外部XSD的JAXB绑定
我们正在从第三方WSDL使用wsdl2java生成java(这意味着我们不能修改他)。WSDL包含:Binding WSDL外部XSD的JAXB绑定,binding,jaxb,xsd,wsdl,wsdl2java,Binding,Jaxb,Xsd,Wsdl,Wsdl2java,我们正在从第三方WSDL使用wsdl2java生成java(这意味着我们不能修改他)。WSDL包含: <wsdl:import namespace="http://somenamespace" location="xsdschema.xsd" /> 在这个xsdschema中,元素具有nillable=“true”,生成器报告ObjectFactory中的冲突(重复)。我们尝试使用绑定generateElementProperty=“false”。但在为WSDL定义的绑定定义
<wsdl:import namespace="http://somenamespace" location="xsdschema.xsd" />
在这个xsdschema中,元素具有nillable=“true”,生成器报告ObjectFactory中的冲突(重复)。我们尝试使用绑定generateElementProperty=“false”。但在为WSDL定义的绑定定义中,generator忽略了它,并且在为xsd定义绑定时,WSDL2Java说xsd不是编译的一部分。如何解决
WSDL的XJB(generateElementProperty被忽略-ObjectFactory中仍然存在重复错误):
XJB for XSD(错误:XSD不是编译的一部分):
马文:
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf.version}</version>
<executions>
<execution>
<goals>
<goal>wsdl2java</goal>
</goals>
<configuration>
<wsdlRoot>src/main/resources/wsdl</wsdlRoot>
<defaultOptions>
<bindingFiles>bindingFile>bindingFile.xjb</bindingFile>
</bindingFiles>
</defaultOptions>
</configuration>
</execution>
</executions>
</plugin>
org.apache.cxf
cxf-codegen插件
${cxf.version}
wsdl2java
src/main/resources/wsdl
bindingFile>bindingFile.xjb
我建议您采用这种策略
使用此配置生成API并排除XSD类
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf.version}</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/pathOfYourWSDL.wsdl</wsdl>
<extraargs>
<extraarg>-nexclude</extraarg>
<extraarg>http://somenamespace</extraarg>
</extraargs>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
org.apache.cxf
cxf-codegen插件
${cxf.version}
生成源
生成源
${basedir}/pathOfYourWSDL.wsdl
-下一步包括
http://somenamespace
wsdl2java
使用此插件生成具有绑定配置的XSD类
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.8.1</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<args>
<arg>-Xannotate</arg>
<arg>-nv</arg>
</args>
<extension>true</extension>
<forceRegenerate>true</forceRegenerate>
<bindingDirectory>${basedir}/pathOfYourXJB</bindingDirectory>
<bindingIncludes>
<include>yourXJB.xjb</include>
</bindingIncludes>
<schemas>
<schema>
<fileset>
<directory>${basedir}/pathOfYourXSD</directory>
<includes>
<include>yourXSD.xsd</include>
</includes>
</fileset>
</schema>
</schemas>
<debug>true</debug>
<verbose>true</verbose>
<plugins>
<plugin>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics</artifactId>
<version>0.6.2</version>
</plugin>
<plugin>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics-annotate</artifactId>
<version>0.6.2</version>
</plugin>
</plugins>
</configuration>
</plugin>
org.jvnet.jaxb2.maven2
maven-jaxb2-plugin
0.8.1
生成源
生成
-山奈特
-内华达州
真的
真的
${basedir}/pathOfYourXJB
yourXJB.xjb
${basedir}/pathOfYourXSD
yourXSD.xsd
真的
真的
org.jvnet.jaxb2_commons
jaxb2基础知识
0.6.2
org.jvnet.jaxb2_commons
jaxb2基础注释
0.6.2
使用此插件添加资源
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>target/generated-sources/xjc</source>
<source>target/generated-sources/cxf</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
org.codehaus.mojo
构建助手maven插件
1.1
添加源
生成源
添加源
目标/生成源/xjc
目标/生成源/cxf
我使用此策略将数据模型与API分开您解决了这个问题吗?如果是,您是如何解决的?
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.8.1</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<args>
<arg>-Xannotate</arg>
<arg>-nv</arg>
</args>
<extension>true</extension>
<forceRegenerate>true</forceRegenerate>
<bindingDirectory>${basedir}/pathOfYourXJB</bindingDirectory>
<bindingIncludes>
<include>yourXJB.xjb</include>
</bindingIncludes>
<schemas>
<schema>
<fileset>
<directory>${basedir}/pathOfYourXSD</directory>
<includes>
<include>yourXSD.xsd</include>
</includes>
</fileset>
</schema>
</schemas>
<debug>true</debug>
<verbose>true</verbose>
<plugins>
<plugin>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics</artifactId>
<version>0.6.2</version>
</plugin>
<plugin>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics-annotate</artifactId>
<version>0.6.2</version>
</plugin>
</plugins>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>target/generated-sources/xjc</source>
<source>target/generated-sources/cxf</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>