英文:
cxf-codegen-plugin 4.0.0 ignores bindingFile
问题
我根据cxf-codegen-plugin基于wsdl创建代码。我使用额外的绑定来:
- 更改包
- 使用
Date而不是XmlGregorianCalender
这在版本3.5.5中正常工作。
当我切换到4.0.0时,不再起作用(使用默认包和XmlGregorianCalender)。我在迁移指南中找不到相关信息。
这是我的配置
pom.xml
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>4.0.0</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<wsdlOptions>
<wsdlOption>
<wsdl>https:url?wsdl</wsdl>
<bindingFiles>
<bindingFile>${basedir}/src/main/resources/bindings.xml</bindingFile>
</bindingFiles>
<extraargs>
<extraarg>-verbose</extraarg>
<extraarg>-p</extraarg>
<extraarg>http://url/service=com.some.package</extraarg>
<extraarg>-xjc-Xts:style:org.apache.commons.lang3.builder.ToStringStyle.DEFAULT_STYLE</extraarg>
</extraargs>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.cxf.xjcplugins</groupId>
<artifactId>cxf-xjc-ts</artifactId>
<version>4.0.0</version>
</dependency>
</dependencies>
</plugin>
绑定
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<jaxb:bindings xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:jaxws="http://cxf.apache.org/jaxws"
version="2.1">
<jaxb:bindings schemaLocation="https://url.file.xsd"
node="/xsd:schema">
<jaxb:schemaBindings>
<jaxb:package name="com.some.package.dto" />
</jaxb:schemaBindings>
<jaxb:globalBindings>
<jaxb:javaType name="java.util.Date"
xmlType="xsd:dateTime"
parseMethod="org.apache.cxf.xjc.runtime.DataTypeAdapter.parseDateTime"
printMethod="org.apache.cxf.xjc.runtime.DataTypeAdapter.printDateTime" />
<jaxb:javaType name="java.util.Date"
xmlType="xsd:date"
parseMethod="org.apache.cxf.xjc.runtime.DataTypeAdapter.parseDate"
printMethod="org.apache.cxf.xjc.runtime.DataTypeAdapter.printDate"/>
<jaxb:javaType name="java.util.Date"
xmlType="xsd:time"
parseMethod="org.apache.cxf.xjc.runtime.DataTypeAdapter.parseTime"
printMethod="org.apache.cxf.xjc.runtime.DataTypeAdapter.printTime"/>
</jaxb:globalBindings>
</jaxb:bindings>
</jaxb:bindings>
英文:
I create code from a wsdl based on the cxf-codegen-plugin. I use additional bindings to
- change the package
- use
Dateinstead ofXmlGregorianCalender
this works fine with version 3.5.5
When I switch to 4.0.0 this does not work anymore (default package and XmlGregorianCalender is used). I could not find anything related in a migration guide.
Here is my configuration
pom.xml
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>4.0.0</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<wsdlOptions>
<wsdlOption>
<wsdl>https:url?wsdl</wsdl>
<bindingFiles>
<bindingFile>${basedir}/src/main/resources/bindings.xml</bindingFile>
</bindingFiles>
<extraargs>
<extraarg>-verbose</extraarg>
<extraarg>-p</extraarg>
<extraarg>http://url/service=com.some.package</extraarg>
<extraarg>-xjc-Xts:style:org.apache.commons.lang3.builder.ToStringStyle.DEFAULT_STYLE</extraarg>
</extraargs>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.cxf.xjcplugins</groupId>
<artifactId>cxf-xjc-ts</artifactId>
<version>4.0.0</version>
</dependency>
</dependencies>
</plugin>
Bindings
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<jaxb:bindings xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:jaxws="http://cxf.apache.org/jaxws"
version="2.1">
<jaxb:bindings schemaLocation="https://url.file.xsd"
node="/xsd:schema">
<jaxb:schemaBindings>
<jaxb:package name="com.some.package.dto" />
</jaxb:schemaBindings>
<jaxb:globalBindings>
<jaxb:javaType name="java.util.Date"
xmlType="xsd:dateTime"
parseMethod="org.apache.cxf.xjc.runtime.DataTypeAdapter.parseDateTime"
printMethod="org.apache.cxf.xjc.runtime.DataTypeAdapter.printDateTime" />
<jaxb:javaType name="java.util.Date"
xmlType="xsd:date"
parseMethod="org.apache.cxf.xjc.runtime.DataTypeAdapter.parseDate"
printMethod="org.apache.cxf.xjc.runtime.DataTypeAdapter.printDate"/>
<jaxb:javaType name="java.util.Date"
xmlType="xsd:time"
parseMethod="org.apache.cxf.xjc.runtime.DataTypeAdapter.parseTime"
printMethod="org.apache.cxf.xjc.runtime.DataTypeAdapter.printTime"/>
</jaxb:globalBindings>
</jaxb:bindings>
</jaxb:bindings>
答案1
得分: 9
我也在版本4.0.0中遇到了相同的问题。似乎所有的 javax.* 规范都被替换成了 jakarta.* 规范。
因此,我意识到我必须将绑定文件中的 xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" 和 xmlns:jaxws="http://cxf.apache.org/jaxws" 替换为 jakarta 的版本:
<jaxb:bindings xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:jaxb="https://jakarta.ee/xml/ns/jaxb"
xmlns:jaxws="https://jakarta.ee/xml/ns/jaxws"
version="3.0">
....
</jaxb:bindings>
正如我所看到的,官方的Apache CXF文档没有明确提到这一点。但你可以在这里检查Jakarta XML Web Services WSDL自定义描述符的XML模式。
英文:
I've also faced with the same issue at version 4.0.0. It seems like all of the javax.* specs are replaced with jakarta.* specs.
So I've realized that I have to replace the xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" and xmlns:jaxws="http://cxf.apache.org/jaxws" in the bindings file to the jakarta ones:
<jaxb:bindings xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:jaxb="https://jakarta.ee/xml/ns/jaxb"
xmlns:jaxws="https://jakarta.ee/xml/ns/jaxws"
version="3.0">
....
</jaxb:bindings>
As I see the official apache cxf docs not mention this explicitly. But you can check the XML Schema for the Jakarta XML Web Services WSDL customization descriptor here.
答案2
得分: 0
抱歉,看起来 4.0.0 插件存在问题。我遇到了相同的问题 - 绑定文件被忽略。
我已经使用单一设置进行了测试:
<jaxb:globalBindings typesafeEnumMaxMembers="2000"/>
但始终获得相同的结果:
[WARNING] 警告:file:/C:/skr/src/main/resources/Service/language.xsd [3,3]:由于 EnumMemberSizeCap 限制,简单类型 "LanguageCodeEnum" 未映射到枚举。Facets 计数:501,当前限制:256。您可以使用自定义属性 "typesafeEnumMaxMembers" 来扩展限制。
因此,此源被忽略,未生成工件。
相同的绑定文件在先前版本(3.5.5)的插件中可以正常工作。
英文:
Unfortunately, it looks like 4.0.0 plugin is buggy. I've got the same problem - binding file is ignored.
I've tested it with single settings:
<jaxb:globalBindings typesafeEnumMaxMembers="2000"/>
and always get the same result:
[WARNING] WARNING: file:/C:/skr/src/main/resources/Service/language.xsd [3,3]: Simple type "LanguageCodeEnum" was not mapped to Enum due to EnumMemberSizeCap limit. Facets count: 501, current limit: 256. You can use customization attribute "typesafeEnumMaxMembers" to extend the limit.
So this source is ignored and artifact is not generated.
The same binding file works in the previous (3.5.5) version of plugin.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论