Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cxf-codegen-plugin 4.0.0 ignores bindingFile

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>
like image 967
user1451252 Avatar asked May 17 '26 12:05

user1451252


1 Answers

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.

like image 82
Spiresix Avatar answered May 21 '26 16:05

Spiresix



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!