Search code examples
dateapache-axiswsdl2java

WSDL2Java code generation and date/dateTime fields


Given the following xsd fragment:

<simpleType name="ConsentDateType">
    <restriction base="date">
        <minInclusive value="2000-01-01Z" />
    </restriction>
</simpleType>

I find that WSDL2Java (1.6.2) is producing XMLGregorianCalendar instances to hold the dates. By itself this is not a problem, but when the fields are serialized to XML the time is included as well. And this is indeed a problem, since the XML is used in a SOAP request, which is rejected because a field containing both a date and a time does not follow the formal xsd:date requirements (only a date and a timezone offset is allowed).

What can I do to get around this problem?

-Michael


Solution

  • I found the answer here:

    Java parsing XML date - exclude time

    Solution is to create XMLGregorianCalendarDate objects. They will be serialized correctly.

    -Michael