J
john
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.
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.