简体   繁体   English

生成客户端肥皂时将wsdl日期类型转换为XMLGregorianCalendar

[英]wsdl date type transformed to XMLGregorianCalendar when generate client soap

I can't understand why my field dateTransaction 我不明白为什么我的字段dateTransaction

changed from date type to XMLGregorianCalendar after generating the soap client ( with wsimpot or cxf maven plugin) 在生成soap客户端后(使用wsimpot或cxf maven插件)将date类型更改为XMLGregorianCalendar

<xs:schema targetNamespace="http://www.xxxxxx.xxr/xx/wsdl/service/objets/v1" elementFormDefault="qualified" attributeFormDefault="unqualified" xmlns="http://www.xxxxxx.xxr/xx/wsdl/service/objets/v1" xmlns:xs="http://www.w3.org/2001/XMLSchema">

    <xs:element name="RequeteService" type="RequeteService"/>

            <xs:element name="dateTransaction" type="xs:date" minOccurs="1" maxOccurs="1"/>

    </xs:complexType>
</xs:schema>

here is my generated class : 这是我生成的类:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "RequeteService", propOrder = {

    "dateTransaction",
    ....
})
    public class RequeteService{

      .....
        @XmlSchemaType(name = "date")
        protected XMLGregorianCalendar dateTransaction;

here is my plugin 这是我的插件

<plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>jaxws-maven-plugin</artifactId>
                <version>2.5</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>wsimport</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <useJdkToolchainExecutable>false</useJdkToolchainExecutable>
                    <wsdlDirectory>${project.basedir}/src/main/resources/wsdl</wsdlDirectory>
                    <packageName>xxxx.xxxx.ws.api</packageName>
                    <keep>true</keep>
                    <sourceDestDir>${project.basedir}/target/generated/src/main/java</sourceDestDir>
                </configuration>
            </plugin>

This is part of the JDK's (and XSD) standard handling for Xml 'date' types. 这是XDK“日期”类型的JDK(和XSD)标准处理的一部分。 XMLGregorianCalendar handles all the XML and timezone specifics. XMLGregorianCalendar处理所有XML和时区细节。 If you want to map the xml date (or dateTime) attributes to a different Java date(time) object, you can do that using a binding file to map the file to something else using an Adapter. 如果要将xml日期(或dateTime)属性映射到其他Java date(时间)对象,则可以使用绑定文件通过Adapter将该文件映射到其他对象。

Here is a DZone article about it: Customizing XML date(time) field generation w/ XJB 这是有关DZone的文章:使用XJB定制XML日期(时间)字段生成

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM