Can't deserialize xsd:date attributes using Axis WSDL2Java classes

Discussion in 'Java' started by john, Sep 29, 2004.

  1. john

    john Guest

    I am generating client classes from a WSDL with the Axis WSDL2Java
    tool.
    Many of the attributes of the complexType objects described in the
    wsdl
    are xsd:date attributes. I can call some of the methods successfully,
    but
    when I call a method that returns an object that has an attribute
    which maps
    to an xsd:date attribute from the wsdl, the client fails with a
    deserialization
    error. Here is a snippet from the wsdl:

    <xsd:element name="base_currency_select_response">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="currency" minOccurs="0" maxOccurs="1">
    <xsd:complexType>
    <xsd:attribute name="currency" type="xsd:string"
    use="required"/>
    <xsd:attribute name="user_code" type="xsd:string"
    use="required"/>
    <xsd:attribute name="description" type="xsd:string"/>
    <xsd:attribute name="exchange_rate" type="s0:ZZMoney"
    use="required"/>
    <xsd:attribute name="n_decimal_places" type="xsd:int"
    use="required"/>
    <xsd:attribute name="change_date" type="xsd:date"
    use="required"/>
    <xsd:attribute name="currency_symbol" type="xsd:string"/>
    <xsd:attribute name="html_symbol" type="xsd:string"/>
    </xsd:complexType>
    </xsd:element>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>

    I look at the xml being sent back to the client from the server, and
    it looks
    like:

    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
    soap:encodingStyle="" >
    <soap:Body xmlns="http://Sandlot/XmlWebServices/" >
    <base_currency_select_response table_specification="currency" >
    <currency currency="USD" user_code="ZZS" description="US Dollar"
    exchange_rate="1.000000" n_decimal_places="2" change_date="1998-01-01"
    currency_symbol="$" />
    </base_currency_select_response>
    </soap:Body>
    </soap:Envelope>

    Note the part: change_date="1998-01-01"

    In the Axis-WSDL2Java-generated data file representing this object,
    this change_date is represented as a java.util.Date:
    private java.util.Date change_date; // attribute

    This is what happens in the console when I call the web service
    method:
    There was 1 error:
    1) test8SandlotSoapBaseCurrencySelect(Sandlot.XmlWebServices.SandlotWSTestCase)A
    xisFault
    faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
    faultSubcode:
    faultString: java.lang.NumberFormatException: Invalid date/time
    faultActor:
    faultNode:
    faultDetail:
    {http://xml.apache.org/axis/}stackTrace:java.lang.NumberFormatException:
    Invalid date/time
    at org.apache.axis.encoding.ser.BeanDeserializer.onStartElement(BeanDese
    rializer.java:417)
    at org.apache.axis.encoding.DeserializerImpl.startElement(DeserializerIm
    pl.java:435)
    at org.apache.axis.encoding.ser.BeanDeserializer.startElement(BeanDeseri
    alizer.java:165)
    at org.apache.axis.encoding.DeserializationContextImpl.startElement(Dese
    rializationContextImpl.java:1053)
    at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.ja
    va:198)

    I am using java 1.4.2_03. I have tried generating and calling the
    service with
    Axis 1.1 and 1.2 beta - same problem both times.

    Anybody know what I am doing wrong? Or is this just and Axis bug? Or
    is this a bug in the web service server (I doubt that - the xml looks
    good - but maybe..)? Any ideas or suggestions would be greatly
    appreciated.

    Thanks.
    -John

    Any ideas for fixing this would be greatly appreciated.
     
    john, Sep 29, 2004
    #1
    1. Advertising

  2. Based on the error (Invalid date/time), it could be that you're sending bad
    date strings. I.e. the format of the xml you're sending is not what the
    deserializer is expecting. What's interesting is that the AXIS
    CalendarDeserializer was not in the stack trace.

    You can see the CalendarDeserializer code and what it expects as input here:
    http://www.koders.com/35195/fidB834B20A6E1F27C22E6C95521F7419FB2511576A.aspx

    You may want to play around with different date string formats, such as a
    full GMT format. At worst, you could implement your own <xsd:complexType>
    date object.

    -Ankur

    "john" <> wrote in message
    news:...
    > I am generating client classes from a WSDL with the Axis WSDL2Java
    > tool.
    > Many of the attributes of the complexType objects described in the
    > wsdl
    > are xsd:date attributes. I can call some of the methods successfully,
    > but
    > when I call a method that returns an object that has an attribute
    > which maps
    > to an xsd:date attribute from the wsdl, the client fails with a
    > deserialization
    > error. Here is a snippet from the wsdl:
    >
    > <xsd:element name="base_currency_select_response">
    > <xsd:complexType>
    > <xsd:sequence>
    > <xsd:element name="currency" minOccurs="0" maxOccurs="1">
    > <xsd:complexType>
    > <xsd:attribute name="currency" type="xsd:string"
    > use="required"/>
    > <xsd:attribute name="user_code" type="xsd:string"
    > use="required"/>
    > <xsd:attribute name="description" type="xsd:string"/>
    > <xsd:attribute name="exchange_rate" type="s0:ZZMoney"
    > use="required"/>
    > <xsd:attribute name="n_decimal_places" type="xsd:int"
    > use="required"/>
    > <xsd:attribute name="change_date" type="xsd:date"
    > use="required"/>
    > <xsd:attribute name="currency_symbol" type="xsd:string"/>
    > <xsd:attribute name="html_symbol" type="xsd:string"/>
    > </xsd:complexType>
    > </xsd:element>
    > </xsd:sequence>
    > </xsd:complexType>
    > </xsd:element>
    >
    > I look at the xml being sent back to the client from the server, and
    > it looks
    > like:
    >
    > <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
    > soap:encodingStyle="" >
    > <soap:Body xmlns="http://Sandlot/XmlWebServices/" >
    > <base_currency_select_response table_specification="currency" >
    > <currency currency="USD" user_code="ZZS" description="US Dollar"
    > exchange_rate="1.000000" n_decimal_places="2" change_date="1998-01-01"
    > currency_symbol="$" />
    > </base_currency_select_response>
    > </soap:Body>
    > </soap:Envelope>
    >
    > Note the part: change_date="1998-01-01"
    >
    > In the Axis-WSDL2Java-generated data file representing this object,
    > this change_date is represented as a java.util.Date:
    > private java.util.Date change_date; // attribute
    >
    > This is what happens in the console when I call the web service
    > method:
    > There was 1 error:
    > 1)

    test8SandlotSoapBaseCurrencySelect(Sandlot.XmlWebServices.SandlotWSTestCase)
    A
    > xisFault
    > faultCode:

    {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
    > faultSubcode:
    > faultString: java.lang.NumberFormatException: Invalid date/time
    > faultActor:
    > faultNode:
    > faultDetail:
    >

    {http://xml.apache.org/axis/}stackTrace:java.lang.NumberFormatException:
    > Invalid date/time
    > at

    org.apache.axis.encoding.ser.BeanDeserializer.onStartElement(BeanDese
    > rializer.java:417)
    > at

    org.apache.axis.encoding.DeserializerImpl.startElement(DeserializerIm
    > pl.java:435)
    > at

    org.apache.axis.encoding.ser.BeanDeserializer.startElement(BeanDeseri
    > alizer.java:165)
    > at

    org.apache.axis.encoding.DeserializationContextImpl.startElement(Dese
    > rializationContextImpl.java:1053)
    > at

    org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.ja
    > va:198)
    >
    > I am using java 1.4.2_03. I have tried generating and calling the
    > service with
    > Axis 1.1 and 1.2 beta - same problem both times.
    >
    > Anybody know what I am doing wrong? Or is this just and Axis bug? Or
    > is this a bug in the web service server (I doubt that - the xml looks
    > good - but maybe..)? Any ideas or suggestions would be greatly
    > appreciated.
    >
    > Thanks.
    > -John
    >
    > Any ideas for fixing this would be greatly appreciated.
     
    Ankur Bulsara, Sep 30, 2004
    #2
    1. Advertising

  3. john

    john Guest

    Thank you for your advice. Unfortunately, I can't change the type of
    the
    attribute - I don't have control over the WSDL or the web service
    provider.
    I only have control over the client.

    I certainly think you are right: the server is sending someting back
    that
    the deserializer is not expecting. The server is sending back:
    change_date="1998-01-01"
    But as I say, I can't change the WSDL or what the server is sending.
    All
    I can do is try to figure out some way of getting the WSDL2Java client
    generator to create code that can deal with this. You kindly
    suggested that
    I play around with different date string formats - but isn't that a
    server-side
    thing? How can I play around with different date-string formats
    client-side
    with generated code? If there's a way you could show me, I'd really
    appreciate knowing it.

    Thanks again,
    John

    "Ankur Bulsara" <hotmail@N0_SPAM_gmail.com> wrote in message news:<>...
    > Based on the error (Invalid date/time), it could be that you're sending bad
    > date strings. I.e. the format of the xml you're sending is not what the
    > deserializer is expecting. What's interesting is that the AXIS
    > CalendarDeserializer was not in the stack trace.
    >
    > You can see the CalendarDeserializer code and what it expects as input here:
    > http://www.koders.com/35195/fidB834B20A6E1F27C22E6C95521F7419FB2511576A.aspx
    >
    > You may want to play around with different date string formats, such as a
    > full GMT format. At worst, you could implement your own <xsd:complexType>
    > date object.
    >
    > -Ankur
    >
    > "john" <> wrote in message
    > news:...
    > > I am generating client classes from a WSDL with the Axis WSDL2Java
    > > tool.
    > > Many of the attributes of the complexType objects described in the
    > > wsdl
    > > are xsd:date attributes. I can call some of the methods successfully,
    > > but
    > > when I call a method that returns an object that has an attribute
    > > which maps
    > > to an xsd:date attribute from the wsdl, the client fails with a
    > > deserialization
    > > error. Here is a snippet from the wsdl:
    > >
    > > <xsd:element name="base_currency_select_response">
    > > <xsd:complexType>
    > > <xsd:sequence>
    > > <xsd:element name="currency" minOccurs="0" maxOccurs="1">
    > > <xsd:complexType>
    > > <xsd:attribute name="currency" type="xsd:string"
    > > use="required"/>
    > > <xsd:attribute name="user_code" type="xsd:string"
    > > use="required"/>
    > > <xsd:attribute name="description" type="xsd:string"/>
    > > <xsd:attribute name="exchange_rate" type="s0:ZZMoney"
    > > use="required"/>
    > > <xsd:attribute name="n_decimal_places" type="xsd:int"
    > > use="required"/>
    > > <xsd:attribute name="change_date" type="xsd:date"
    > > use="required"/>
    > > <xsd:attribute name="currency_symbol" type="xsd:string"/>
    > > <xsd:attribute name="html_symbol" type="xsd:string"/>
    > > </xsd:complexType>
    > > </xsd:element>
    > > </xsd:sequence>
    > > </xsd:complexType>
    > > </xsd:element>
    > >
    > > I look at the xml being sent back to the client from the server, and
    > > it looks
    > > like:
    > >
    > > <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
    > > soap:encodingStyle="" >
    > > <soap:Body xmlns="http://Sandlot/XmlWebServices/" >
    > > <base_currency_select_response table_specification="currency" >
    > > <currency currency="USD" user_code="ZZS" description="US Dollar"
    > > exchange_rate="1.000000" n_decimal_places="2" change_date="1998-01-01"
    > > currency_symbol="$" />
    > > </base_currency_select_response>
    > > </soap:Body>
    > > </soap:Envelope>
    > >
    > > Note the part: change_date="1998-01-01"
    > >
    > > In the Axis-WSDL2Java-generated data file representing this object,
    > > this change_date is represented as a java.util.Date:
    > > private java.util.Date change_date; // attribute
    > >
    > > This is what happens in the console when I call the web service
    > > method:
    > > There was 1 error:
    > > 1)

    > test8SandlotSoapBaseCurrencySelect(Sandlot.XmlWebServices.SandlotWSTestCase)
    > A
    > > xisFault
    > > faultCode:

    > {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
    > > faultSubcode:
    > > faultString: java.lang.NumberFormatException: Invalid date/time
    > > faultActor:
    > > faultNode:
    > > faultDetail:
    > >

    > {http://xml.apache.org/axis/}stackTrace:java.lang.NumberFormatException:
    > > Invalid date/time
    > > at

    > org.apache.axis.encoding.ser.BeanDeserializer.onStartElement(BeanDese
    > > rializer.java:417)
    > > at

    > org.apache.axis.encoding.DeserializerImpl.startElement(DeserializerIm
    > > pl.java:435)
    > > at

    > org.apache.axis.encoding.ser.BeanDeserializer.startElement(BeanDeseri
    > > alizer.java:165)
    > > at

    > org.apache.axis.encoding.DeserializationContextImpl.startElement(Dese
    > > rializationContextImpl.java:1053)
    > > at

    > org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.ja
    > > va:198)
    > >
    > > I am using java 1.4.2_03. I have tried generating and calling the
    > > service with
    > > Axis 1.1 and 1.2 beta - same problem both times.
    > >
    > > Anybody know what I am doing wrong? Or is this just and Axis bug? Or
    > > is this a bug in the web service server (I doubt that - the xml looks
    > > good - but maybe..)? Any ideas or suggestions would be greatly
    > > appreciated.
    > >
    > > Thanks.
    > > -John
    > >
    > > Any ideas for fixing this would be greatly appreciated.
     
    john, Sep 30, 2004
    #3
  4. When the client gets back a SOAP message, you could transform the SOAP via
    XSLT into something more edible for the code generated by wsdl2Java.

    So, you would have something like:

    Incoming SOAP -> XSLT -> Transformed SOAP -> wsdl2java -> Happy client

    Here's some example code that performs XSLT transformations.
    http://www.koders.com/java/fid78E5DAFB4D7083A6D56ABA9FC0FC82666BE4DB13.aspx?s=transform xslt

    You would just need to define an XSL document that transforms the server bad
    date into an acceptable date.

    Hope this helps,
    Ankur

    "john" <> wrote in message
    news:...
    > Thank you for your advice. Unfortunately, I can't change the type of
    > the
    > attribute - I don't have control over the WSDL or the web service
    > provider.
    > I only have control over the client.
    >
    > I certainly think you are right: the server is sending someting back
    > that
    > the deserializer is not expecting. The server is sending back:
    > change_date="1998-01-01"
    > But as I say, I can't change the WSDL or what the server is sending.
    > All
    > I can do is try to figure out some way of getting the WSDL2Java client
    > generator to create code that can deal with this. You kindly
    > suggested that
    > I play around with different date string formats - but isn't that a
    > server-side
    > thing? How can I play around with different date-string formats
    > client-side
    > with generated code? If there's a way you could show me, I'd really
    > appreciate knowing it.
    >
    > Thanks again,
    > John
    >
    > "Ankur Bulsara" <hotmail@N0_SPAM_gmail.com> wrote in message

    news:<>...
    > > Based on the error (Invalid date/time), it could be that you're sending

    bad
    > > date strings. I.e. the format of the xml you're sending is not what the
    > > deserializer is expecting. What's interesting is that the AXIS
    > > CalendarDeserializer was not in the stack trace.
    > >
    > > You can see the CalendarDeserializer code and what it expects as input

    here:
    > >

    http://www.koders.com/35195/fidB834B20A6E1F27C22E6C95521F7419FB2511576A.aspx
    > >
    > > You may want to play around with different date string formats, such as

    a
    > > full GMT format. At worst, you could implement your own

    <xsd:complexType>
    > > date object.
    > >
    > > -Ankur
    > >
    > > "john" <> wrote in message
    > > news:...
    > > > I am generating client classes from a WSDL with the Axis WSDL2Java
    > > > tool.
    > > > Many of the attributes of the complexType objects described in the
    > > > wsdl
    > > > are xsd:date attributes. I can call some of the methods successfully,
    > > > but
    > > > when I call a method that returns an object that has an attribute
    > > > which maps
    > > > to an xsd:date attribute from the wsdl, the client fails with a
    > > > deserialization
    > > > error. Here is a snippet from the wsdl:
    > > >
    > > > <xsd:element name="base_currency_select_response">
    > > > <xsd:complexType>
    > > > <xsd:sequence>
    > > > <xsd:element name="currency" minOccurs="0" maxOccurs="1">
    > > > <xsd:complexType>
    > > > <xsd:attribute name="currency" type="xsd:string"
    > > > use="required"/>
    > > > <xsd:attribute name="user_code" type="xsd:string"
    > > > use="required"/>
    > > > <xsd:attribute name="description" type="xsd:string"/>
    > > > <xsd:attribute name="exchange_rate" type="s0:ZZMoney"
    > > > use="required"/>
    > > > <xsd:attribute name="n_decimal_places" type="xsd:int"
    > > > use="required"/>
    > > > <xsd:attribute name="change_date" type="xsd:date"
    > > > use="required"/>
    > > > <xsd:attribute name="currency_symbol" type="xsd:string"/>
    > > > <xsd:attribute name="html_symbol" type="xsd:string"/>
    > > > </xsd:complexType>
    > > > </xsd:element>
    > > > </xsd:sequence>
    > > > </xsd:complexType>
    > > > </xsd:element>
    > > >
    > > > I look at the xml being sent back to the client from the server, and
    > > > it looks
    > > > like:
    > > >
    > > > <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
    > > > soap:encodingStyle="" >
    > > > <soap:Body xmlns="http://Sandlot/XmlWebServices/" >
    > > > <base_currency_select_response table_specification="currency" >
    > > > <currency currency="USD" user_code="ZZS" description="US Dollar"
    > > > exchange_rate="1.000000" n_decimal_places="2" change_date="1998-01-01"
    > > > currency_symbol="$" />
    > > > </base_currency_select_response>
    > > > </soap:Body>
    > > > </soap:Envelope>
    > > >
    > > > Note the part: change_date="1998-01-01"
    > > >
    > > > In the Axis-WSDL2Java-generated data file representing this object,
    > > > this change_date is represented as a java.util.Date:
    > > > private java.util.Date change_date; // attribute
    > > >
    > > > This is what happens in the console when I call the web service
    > > > method:
    > > > There was 1 error:
    > > > 1)

    > >

    test8SandlotSoapBaseCurrencySelect(Sandlot.XmlWebServices.SandlotWSTestCase)
    > > A
    > > > xisFault
    > > > faultCode:

    > > {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
    > > > faultSubcode:
    > > > faultString: java.lang.NumberFormatException: Invalid date/time
    > > > faultActor:
    > > > faultNode:
    > > > faultDetail:
    > > >

    > >

    {http://xml.apache.org/axis/}stackTrace:java.lang.NumberFormatException:
    > > > Invalid date/time
    > > > at

    > > org.apache.axis.encoding.ser.BeanDeserializer.onStartElement(BeanDese
    > > > rializer.java:417)
    > > > at

    > > org.apache.axis.encoding.DeserializerImpl.startElement(DeserializerIm
    > > > pl.java:435)
    > > > at

    > > org.apache.axis.encoding.ser.BeanDeserializer.startElement(BeanDeseri
    > > > alizer.java:165)
    > > > at

    > > org.apache.axis.encoding.DeserializationContextImpl.startElement(Dese
    > > > rializationContextImpl.java:1053)
    > > > at

    > > org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.ja
    > > > va:198)
    > > >
    > > > I am using java 1.4.2_03. I have tried generating and calling the
    > > > service with
    > > > Axis 1.1 and 1.2 beta - same problem both times.
    > > >
    > > > Anybody know what I am doing wrong? Or is this just and Axis bug? Or
    > > > is this a bug in the web service server (I doubt that - the xml looks
    > > > good - but maybe..)? Any ideas or suggestions would be greatly
    > > > appreciated.
    > > >
    > > > Thanks.
    > > > -John
    > > >
    > > > Any ideas for fixing this would be greatly appreciated.
     
    Ankur Bulsara, Sep 30, 2004
    #4
  5. john

    kgarg01

    Joined:
    Oct 12, 2006
    Messages:
    1
    John,

    It's been a long time since you posted this, however, I am exactly in your shoes at this point. Can you please suggest what you did to resolve this issue if you happen to remember.

    I'll appreciate your response.

    Regards,
     
    kgarg01, Oct 12, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sandy Dunlop

    Problem with Apache AXIS WSDL2Java

    Sandy Dunlop, Oct 4, 2003, in forum: Java
    Replies:
    1
    Views:
    981
    Sandy Dunlop
    Oct 4, 2003
  2. eq
    Replies:
    1
    Views:
    4,708
    The Abrasive Sponge
    Oct 15, 2004
  3. Replies:
    0
    Views:
    993
  4. pico77
    Replies:
    1
    Views:
    3,445
  5. Alessandro
    Replies:
    0
    Views:
    1,008
    Alessandro
    Jun 4, 2009
Loading...

Share This Page