cxf-codegen-plugin 4.0.0 忽略了 bindingFile。

huangapple go评论136阅读模式
英文:

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 Date instead of XmlGregorianCalender

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

&lt;plugin&gt;
                &lt;groupId&gt;org.apache.cxf&lt;/groupId&gt;
                &lt;artifactId&gt;cxf-codegen-plugin&lt;/artifactId&gt;
                &lt;version&gt;4.0.0&lt;/version&gt;
                &lt;executions&gt;
                    &lt;execution&gt;
                        &lt;id&gt;generate-sources&lt;/id&gt;
                        &lt;phase&gt;generate-sources&lt;/phase&gt;
                        &lt;configuration&gt;
                            &lt;wsdlOptions&gt;
                                &lt;wsdlOption&gt;
                                    &lt;wsdl&gt;https:url?wsdl&lt;/wsdl&gt;
                                    &lt;bindingFiles&gt;
                                        &lt;bindingFile&gt;${basedir}/src/main/resources/bindings.xml&lt;/bindingFile&gt;
                                    &lt;/bindingFiles&gt;
                                    &lt;extraargs&gt;
                                        &lt;extraarg&gt;-verbose&lt;/extraarg&gt;
                                        &lt;extraarg&gt;-p&lt;/extraarg&gt;
                                        &lt;extraarg&gt;http://url/service=com.some.package&lt;/extraarg&gt;
                                        &lt;extraarg&gt;-xjc-Xts:style:org.apache.commons.lang3.builder.ToStringStyle.DEFAULT_STYLE&lt;/extraarg&gt;
                                    &lt;/extraargs&gt;
                                &lt;/wsdlOption&gt;
                            &lt;/wsdlOptions&gt;
                        &lt;/configuration&gt;
                        &lt;goals&gt;
                            &lt;goal&gt;wsdl2java&lt;/goal&gt;
                        &lt;/goals&gt;
                    &lt;/execution&gt;
                &lt;/executions&gt;
                &lt;dependencies&gt;
                    &lt;dependency&gt;
                        &lt;groupId&gt;org.apache.cxf.xjcplugins&lt;/groupId&gt;
                        &lt;artifactId&gt;cxf-xjc-ts&lt;/artifactId&gt;
                        &lt;version&gt;4.0.0&lt;/version&gt;
                    &lt;/dependency&gt;
                &lt;/dependencies&gt;
            &lt;/plugin&gt;

Bindings

&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;yes&quot;?&gt;

&lt;jaxb:bindings xmlns:wsdl=&quot;http://schemas.xmlsoap.org/wsdl/&quot;
               xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot;
               xmlns:jaxb=&quot;http://java.sun.com/xml/ns/jaxb&quot;
               xmlns:jaxws=&quot;http://cxf.apache.org/jaxws&quot;
               version=&quot;2.1&quot;&gt;

    &lt;jaxb:bindings schemaLocation=&quot;https://url.file.xsd&quot;
                   node=&quot;/xsd:schema&quot;&gt;
        &lt;jaxb:schemaBindings&gt;
            &lt;jaxb:package name=&quot;com.some.package.dto&quot; /&gt;
        &lt;/jaxb:schemaBindings&gt;
        &lt;jaxb:globalBindings&gt;
            &lt;jaxb:javaType name=&quot;java.util.Date&quot;
                           xmlType=&quot;xsd:dateTime&quot;
                           parseMethod=&quot;org.apache.cxf.xjc.runtime.DataTypeAdapter.parseDateTime&quot;
                           printMethod=&quot;org.apache.cxf.xjc.runtime.DataTypeAdapter.printDateTime&quot; /&gt;
            &lt;jaxb:javaType name=&quot;java.util.Date&quot;
                           xmlType=&quot;xsd:date&quot;
                           parseMethod=&quot;org.apache.cxf.xjc.runtime.DataTypeAdapter.parseDate&quot;
                           printMethod=&quot;org.apache.cxf.xjc.runtime.DataTypeAdapter.printDate&quot;/&gt;
            &lt;jaxb:javaType name=&quot;java.util.Date&quot;
                           xmlType=&quot;xsd:time&quot;
                           parseMethod=&quot;org.apache.cxf.xjc.runtime.DataTypeAdapter.parseTime&quot;
                           printMethod=&quot;org.apache.cxf.xjc.runtime.DataTypeAdapter.printTime&quot;/&gt;
        &lt;/jaxb:globalBindings&gt;
    &lt;/jaxb:bindings&gt;

&lt;/jaxb:bindings&gt;

答案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=&quot;http://java.sun.com/xml/ns/jaxb&quot; and xmlns:jaxws=&quot;http://cxf.apache.org/jaxws&quot; in the bindings file to the jakarta ones:

&lt;jaxb:bindings xmlns:wsdl=&quot;http://schemas.xmlsoap.org/wsdl/&quot;
               xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot;
               xmlns:jaxb=&quot;https://jakarta.ee/xml/ns/jaxb&quot;
               xmlns:jaxws=&quot;https://jakarta.ee/xml/ns/jaxws&quot;
               version=&quot;3.0&quot;&gt;

....

&lt;/jaxb:bindings&gt;

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.

huangapple
  • 本文由 发表于 2023年2月23日 19:43:02
  • 转载请务必保留本文链接:https://go.coder-hub.com/75544349.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定