Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6925957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:51:24+00:00 2026-05-27T10:51:24+00:00

Using Java 1.6 wsimport I generated source from a WSDL for a web service.

  • 0

Using Java 1.6 wsimport I generated source from a WSDL for a web service. One of the fields in the request structure has type xs:dateTime in the XML schema included by the WSDL and type javax.xml.datatype.XMLGregorianCalendar in the generated code.

Through manual testing with soapUI I have determined that the following serialized values are accepted by the web service: 2011-12-08, 2011-12-08Z. The following are not accepted and the response in this case is an empty reply (not an explicit error): 2011-12-08T20:00:00, 2011-12-08T20:00:00-05:00. The service itself is .NET powered if that matters.

My thought is that the server should accept the full date/time and reject the date only, but the other way around is what is happening. But I am under no assumption that maintainers of the server will be open to change. So I have attempted to convince the client to send a date only.

I can’t convince my client code to serialize an XMLGregorianCalendar object into a date only. Well actually I can, except when the generated code does it. When the generated client code (produced by wsimport) does it, the serialized value is the empty string, and the server correctly returns an error. I verified this using a packet sniffer.

Here is how I’m creating and populating the date field in the request:

import java.util.Calendar;
import java.util.GregorianCalendar;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeConstants;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;
import java.util.TimeZone;
// also import GeneratedRequest from generated packages

private makeRequest() {
   GeneratedRequest request;
   // ...
   request.setDateField(xmlDayNow(TimeZone.getTimeZone("America/New_York"),
       6));  // broadcast day starts at 6 am EST
   // ...
}

@XmlSchemaType(name="date")
private static XMLGregorianCalendar xmlDayNow(TimeZone tz, int localHourStart)
throws MyException {
    GregorianCalendar cal = gregorianBroadcastDayNow(tz, localHourStart);
    XMLGregorianCalendar result;
    try {
        result = DatatypeFactory.newInstance().newXMLGregorianCalendarDate(
            cal.get(Calendar.YEAR), cal.get(Calendar.MONTH) + 1,
            cal.get(Calendar.DAY_OF_MONTH), DatatypeConstants.FIELD_UNDEFINED)
            .normalize();
    } catch (DatatypeConfigurationException e) {
        throw new MyException("XMLGregorianCalendar issue", e);
    }
    return result;
}

protected static GregorianCalendar gregorianBroadcastDayNow(TimeZone tz,
        int localHourStart) {
    GregorianCalendar now = new GregorianCalendar(tz);
    if (now.get(GregorianCalendar.HOUR_OF_DAY) < localHourStart) {
        now.add(GregorianCalendar.DAY_OF_MONTH, -1);
    }
    return now;
}

The implementation class for XMLGregorianCalendar in my case is com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl. In the debugger, or if I add log output, calling the date object’s toXMLFormat() method returns a date only, such as 2011-12-09. Using a debugger to inspect the date object itself, I see that its year, day and month fields are populated, and all the others are either null or -2147483648 which is the value of DatatypeConstants.FIELD_UNDEFINED. According to all documentation and Internet search results I have found, my date object is correctly formed.

Am I crazy? Is the server really in error? Is the refusal of the generated client code to send a date only correct? Is this a justifiable “undefined behavior” case? Is the wrong implementation class being used (could that possibly matter anyway)? Is there some known issue with wsimport that’s affecting me?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T10:51:24+00:00Added an answer on May 27, 2026 at 10:51 am

    I was seeing an unintuitive implementation detail of .NET web services that I did not recognize. In my analysis I observed that providing a complete date/time serialized string resulted in an empty response from the server, but not an explicit error.

    This was because on the server, they were in fact using date/time objects, but were forcing all of the times to midnight Eastern Standard Time. So the responses were only populated with results if I forced the time in the request to midnight EST, which I was not doing. (In the event that no time zone was given, the server assumed EST; and if no time was given at all, midnight EST was assumed.)

    So in my case, the solution was to modify the client code to force the time zone to Olson America/New_York and force the local time to 00:00:00 when creating the request.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a wsdl and I'd like to generate jax-ws type Java source from
I am attempting to consume a WCF web service from a Java client using
I have a WCF web service using wsHttpBinding that I am consuming from a
I have a strange problem. Using wsimport I generated als JAX-WS Code from a
Using Java, how can I extract all the links from a given web page?
I am using jax-ws's wsimport to generate java classes from WSDLs. I am using
Using code that was generated with wsimport , can the service endpoint be overridden
Using Java (1.6) I want to split an input string that has components of
I have hard times using maven to generate my web service client. So please
I'm using wsimport in Java 1.6 (i.e. build 1.6.0-b105) on Windows XP 5.1 and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.