开发者

xsd dateTime loosing timezone information being passed through Websphere ESB via JAX-WS

I'm using JAX-WS (WAS 7) --> Websphere ESB 7 --> JAX-WS (WAS 7), populating a xsd:dateTime field with a timestamp.

Here's the flow:

  1. WAS - Instantiate Response object
  2. Populate XMLGregorianCalendar field in POJO [DatatypeFactory.newInstance().newXMLGregorianCalendar((GregorianCalendar)Calendar.getInstance())] "2010-11-02T15:35:42.047+13:00"
  3. Pass response back through ESB
  4. Examine response in gateway "2010-11-02T02:35:42.047Z"

As you can see the NZ timezone info is ignored. The returned XMLGregorianCalendarImpl.timezone=0, where it was XMLGregorianCalendarImpl.timezone=780 when it was instantiated.

The POJO is generated with the "JAX-WS RI IBM 2.1.1 in JDK 6" as

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "MessageControl", namespace = "http://xmlschema.customer.co.nz/generic/Response123", propOrder = {
    "messageTrackTrace",
    "messageDate",  
})
public class PojoClass {

    @XmlElement(name = "MessageTrackTrace")
    protected String messageTrackTrace;
    @XmlElement(name = "MessageDate", required = true)
    pro开发者_JS百科tected XMLGregorianCalendar messageDate;

Is this a bug in ESB? Perhaps there is a configuration I can change? Cheers


Thanks for the thought Ryan, I solved it by populating a new XMLGregorianCalendar from a Date.

DatatypeFactory df = DatatypeFactory.newInstance();
GregorianCalendar cal = (GregorianCalendar) Calendar.getInstance();

Date messageDate = pojoClass.getMessageDate().toGregorianCalendar().getTime();
cal.setTime(messageDate);
XMLGregorianCalendar xCal = df.newXMLGregorianCalendar(cal);
pojoClass.setMessageDate(xCal);

This maintains the format I want i.e. 'Pacific/Auckland' timezone.

Cheers

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜