4

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

<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>
Marius
  • 365
  • 4
  • 18
  • Would you be interested to write this same issue in their jira? https://issues.apache.org/jira/projects/CXF/issues I think this pretty clearly describes the issue and there doesn't seem to be much activity outside the CXF jira. – LeadingMoominExpert Mar 10 '23 at 08:12

2 Answers2

5

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.

Spiresix
  • 61
  • 5
0

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.

jarp90
  • 1