I’m having a problem sending dates from a client in one timezone to a web service residing on a server in a different timezone. Both ends use XFire 1.1.2.

 

The request object that is sent to the web service contains a String, an int and a Date. i.e.

 

public class Request

{

   private String code;

   private int number;

   private Date date;

 

   getters and setters …

}

 

The WSDL that XFire generates for this class looks like this:

 

<xsd:complexType name="Request">

   <xsd:sequence>

      <xsd:element name="code" type="xsd:string" minOccurs="0" nillable="true"/>

      <xsd:element name="number" type="xsd:int" minOccurs="0"/>

      <xsd:element name="date" type="xsd:dateTime" minOccurs="0"/>

   </xsd:sequence>

</xsd:complexType>

 

Notice how the date field has been mapped to a xsd:dateTime. We generate client code based on the WSDL using wsgen. When we run the client in Sydney, Australia the date field is transmitted as follows:

 

<date>2006-10-18T00:00:00.000Z</date>

 

The server running the web service is based in the US. What’s happening is that the date is converted to CST timezone when XFire unmarshals this field and it ends up being the day before the date that was sent from the client. It subtracts five hours since CST is GMT-5.

 

Reading the newsgroups it appears that the most common solution is to use a String field rather than a date. Are there any other solutions to this problem, e.g. can I force the Date field to be an xsd:date field in the WSDL that has no timezone info?

 

Thanks for your help,

Stuart

Reply via email to