You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-user@axis.apache.org by Jean ANDRE <ja...@cmtek.com> on 2004/12/09 16:30:34 UTC
float type and date time format
Bonjour everybody!
Well, I have a strange behavior with floating number and date time format.
1 ) With float number, 77.99 becomes 77.989998 output string under
Axis. Why I lost some digits ??????!!!
2) With datetime format , in c++ test code, I just moved some fields
to another one of the same structure and I get the following output
string: with Axis
<txnDate>*2004-12-09T19:54:32Z*</txnDate>
I supposed that Z is for TimeZone ? But how to construct a time to
obtain such string ?
With dot-net client application and a java application I got the
following string:
<txnDate>2004-12-08T00:00:00.0000000-05:00</txnDate>
Thanks a lot for your answers. Take care!
Jean .A - Canada
In c++ test code, I put the following code according to the WSDL.
C++ Test code under Microsoft Visual C++
==============================
class TxnAmount
{
public:
float amount;
xsd__string currency;
TxnAmount();
~TxnAmount();
};
xsd__dateTime txnDate;
tm* curTime;
time_t timer;
amount.amount = 77.99; // paymentForm.amount
amount.currency = "USD"; // paymentForm.currency
memset(&txnDate, 0x00, sizeof(xsd__dateTime));
timer = time(NULL);
curTime = localtime( &timer );
txnDate.tm_isdst = curTime->tm_isdst;
txnDate.tm_hour = curTime->tm_hour;
txnDate.tm_min = curTime->tm_min;
txnDate.tm_sec = curTime->tm_sec;
txnDate.tm_wday = curTime->tm_wday;
txnDate.tm_yday = curTime->tm_yday;
txnDate.tm_mday = curTime->tm_mday; //
paymentForm.txnDateD - day of the month - [1,31]
txnDate.tm_mon = curTime->tm_mon; //
paymentForm.txnDateM - months since January - [0,11]
txnDate.tm_year = curTime->tm_year; //
paymentForm.txnDateY - years since 1900
Fragment of the WDSL:
==================
<xs:element name="txnDate" type="xs:dateTime" minOccurs="0">
</xs:element>
<xs:complexType name="TxnAmount">
<xs:sequence>
<xs:element name="amount">
<xs:simpleType>
<xs:restriction base="xs:float">
<xs:minInclusive value="0.00"/>
<xs:maxInclusive value="9999999999.99"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="currency" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="USD"/>
<xs:enumeration value="CAD"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
Fragment of the string sent by AXIS ?? Look the field amount !!!!
=============================================
<ns1:txnRequest>
<orderTotal>
<amount>77.989998</amount>
<currency>USD</currency>
</orderTotal>
<billTo>
<txnDate>*2004-12-09T19:54:32Z*</txnDate>
Re: float type and date time format
Posted by Jean ANDRE <ja...@cmtek.com>.
Bonjour,
It seens there are 2 kind of implementation depending if the soap
implementation use the "tm" structure or the "time_t" stucture ?
Axis use the "tm" structure and produce the output format
"2004-12-13T14:45:11Z" while some other soap implementations use
"time_t" structure to specify a date-time format and it produces the
output format *2004-12-14T02:17:47+05:00*.
Jean A.
John Hawkins wrote:
>
>
>John Hawkins
>
>One can either represent date time as Z (UTC) or the offest from Z as ->
>2002-09-24-06:00 (where the "-06:00" says this is 6 hours behind UTC. This
>is all I have gathered from the xsd specs.
>
>
>Jean ANDRE <ja...@cmtek.com> wrote on 13/12/2004 14:43:27:
>
>
>
>>Hello Samisa Abeysinghe,
>>
>>According to John Bofish email, the "Z" is for UTC time and Zero Zone.
>>The time format is correct but under other developpment tools as .Net
>>and Java (but not Axis), the time is given in GMT. "UTC is the
>>successor of Greenwich Mean Time </wiki/Greenwich_Mean_Time>,". So,
>>the question is now, could we support both format or translate one to
>>another one easily, under the hood. It if really necessary to support
>>both formats, does existing architectures and softwares understand the
>>UTC format ?
>>As I wasn't able to complete test under Axis due to some bug with
>>Complex Structure (soaq response) , I can't tell you if the Z is an
>>
>>
>issue.
>
>
>>>That's a good guess. 'Z' is for "UTC", or Coordinated Universal Time.
>>>
>>>
>See
>
>
>>>http://en.wikipedia.org/wiki/Coordinated_Universal_Time for more on
>>>
>>>
>UTC.
>
>
>>>The World Wide Web Consortium has a note about date and time formats
>>>(http://www.w3.org/TR/NOTE-datetime) where it states:
>>>
>>>
>>Thank you very much for your answers.
>>
>>Best regards,
>>
>>Jean A. - Canada -
>>
>>
>>
>>
>>Samisa Abeysinghe wrote:
>>
>>
>>
>>>Bonjour Jean,
>>>
>>>Re: the datetime problem.
>>>I had a look at the source and the trailing 'Z' character seems to be
>>>hard coded in the serialize code in src/common/AxisTime.cpp. There is
>>>no mention of why Z has been used there - not even a comment, so I am
>>>not sure what it means.
>>>
>>>However, if we want to change the format, we can do that by fixing the
>>>
>>>
>code.
>
>
>>>Also, I used Axis Java's echo service and client samples, and saw that
>>>Axis Java also send something similar to "2004-12-13T14:45:11Z".
>>>
>>>BTW, you have copied values from tm struct to xsd__dateTime struct.
>>>This is not necessary, as the xsd__dateTime is defined to be of type
>>>tm. So you can use type tm directly as the parameter to the web
>>>service method.
>>>
>>>Thanks,
>>>Samisa...
>>>
>>>
>>>On Thu, 09 Dec 2004 20:30:34 +0500, Jean ANDRE <ja...@cmtek.com> wrote:
>>>
>>>
>>>
>>>
>>>>Bonjour everybody!
>>>>
>>>>Well, I have a strange behavior with floating number and date time
>>>>
>>>>
>format.
>
>
>>>>1 ) With float number, 77.99 becomes 77.989998 output string under
>>>>Axis. Why I lost some digits ??????!!!
>>>>
>>>>2) With datetime format , in c++ test code, I just moved some fields
>>>>to another one of the same structure and I get the following output
>>>>string: with Axis
>>>> <txnDate>*2004-12-09T19:54:32Z*</txnDate>
>>>>
>>>>I supposed that Z is for TimeZone ? But how to construct a time to
>>>>obtain such string ?
>>>>
>>>>With dot-net client application and a java application I got the
>>>>following string:
>>>><txnDate>2004-12-08T00:00:00.0000000-05:00</txnDate>
>>>>
>>>>Thanks a lot for your answers. Take care!
>>>>
>>>>Jean .A - Canada
>>>>
>>>>In c++ test code, I put the following code according to the WSDL.
>>>>
>>>>C++ Test code under Microsoft Visual C++
>>>>==============================
>>>>class TxnAmount
>>>>{
>>>>public:
>>>> float amount;
>>>> xsd__string currency;
>>>> TxnAmount();
>>>> ~TxnAmount();
>>>>};
>>>>
>>>> xsd__dateTime txnDate;
>>>> tm* curTime;
>>>> time_t timer;
>>>>
>>>> amount.amount = 77.99; // paymentForm.amount
>>>> amount.currency = "USD"; // paymentForm.currency
>>>>
>>>> memset(&txnDate, 0x00, sizeof(xsd__dateTime));
>>>> timer = time(NULL);
>>>> curTime = localtime( &timer );
>>>> txnDate.tm_isdst = curTime->tm_isdst;
>>>> txnDate.tm_hour = curTime->tm_hour;
>>>> txnDate.tm_min = curTime->tm_min;
>>>> txnDate.tm_sec = curTime->tm_sec;
>>>> txnDate.tm_wday = curTime->tm_wday;
>>>> txnDate.tm_yday = curTime->tm_yday;
>>>> txnDate.tm_mday = curTime->tm_mday; //
>>>>paymentForm.txnDateD - day of the month - [1,31]
>>>> txnDate.tm_mon = curTime->tm_mon; //
>>>>paymentForm.txnDateM - months since January - [0,11]
>>>> txnDate.tm_year = curTime->tm_year; //
>>>>paymentForm.txnDateY - years since 1900
>>>>
>>>>Fragment of the WDSL:
>>>>==================
>>>> <xs:element name="txnDate" type="xs:dateTime" minOccurs="0">
>>>> </xs:element>
>>>> <xs:complexType name="TxnAmount">
>>>> <xs:sequence>
>>>> <xs:element name="amount">
>>>> <xs:simpleType>
>>>> <xs:restriction base="xs:float">
>>>> <xs:minInclusive value="0.00"/>
>>>> <xs:maxInclusive value="9999999999.99"/>
>>>> </xs:restriction>
>>>> </xs:simpleType>
>>>> </xs:element>
>>>> <xs:element name="currency" minOccurs="0">
>>>> <xs:simpleType>
>>>> <xs:restriction base="xs:string">
>>>> <xs:enumeration value="USD"/>
>>>> <xs:enumeration value="CAD"/>
>>>> </xs:restriction>
>>>> </xs:simpleType>
>>>> </xs:element>
>>>> </xs:sequence>
>>>> </xs:complexType>
>>>>
>>>>Fragment of the string sent by AXIS ?? Look the field amount !!!!
>>>>=============================================
>>>><ns1:txnRequest>
>>>><orderTotal>
>>>><amount>77.989998</amount>
>>>><currency>USD</currency>
>>>></orderTotal>
>>>><billTo>
>>>>
>>>><txnDate>*2004-12-09T19:54:32Z*</txnDate>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>
>
>
>
Re: float type and date time format
Posted by John Hawkins <HA...@uk.ibm.com>.
John Hawkins
One can either represent date time as Z (UTC) or the offest from Z as ->
2002-09-24-06:00 (where the "-06:00" says this is 6 hours behind UTC. This
is all I have gathered from the xsd specs.
Jean ANDRE <ja...@cmtek.com> wrote on 13/12/2004 14:43:27:
> Hello Samisa Abeysinghe,
>
> According to John Bofish email, the "Z" is for UTC time and Zero Zone.
> The time format is correct but under other developpment tools as .Net
> and Java (but not Axis), the time is given in GMT. "UTC is the
> successor of Greenwich Mean Time </wiki/Greenwich_Mean_Time>,". So,
> the question is now, could we support both format or translate one to
> another one easily, under the hood. It if really necessary to support
> both formats, does existing architectures and softwares understand the
> UTC format ?
> As I wasn't able to complete test under Axis due to some bug with
> Complex Structure (soaq response) , I can't tell you if the Z is an
issue.
>
> > That's a good guess. 'Z' is for "UTC", or Coordinated Universal Time.
See
> > http://en.wikipedia.org/wiki/Coordinated_Universal_Time for more on
UTC.
>
> > The World Wide Web Consortium has a note about date and time formats
> > (http://www.w3.org/TR/NOTE-datetime) where it states:
>
> Thank you very much for your answers.
>
> Best regards,
>
> Jean A. - Canada -
>
>
>
>
> Samisa Abeysinghe wrote:
>
> >Bonjour Jean,
> >
> >Re: the datetime problem.
> >I had a look at the source and the trailing 'Z' character seems to be
> >hard coded in the serialize code in src/common/AxisTime.cpp. There is
> >no mention of why Z has been used there - not even a comment, so I am
> >not sure what it means.
> >
> >However, if we want to change the format, we can do that by fixing the
code.
> >
> >Also, I used Axis Java's echo service and client samples, and saw that
> >Axis Java also send something similar to "2004-12-13T14:45:11Z".
> >
> >BTW, you have copied values from tm struct to xsd__dateTime struct.
> >This is not necessary, as the xsd__dateTime is defined to be of type
> >tm. So you can use type tm directly as the parameter to the web
> >service method.
> >
> >Thanks,
> >Samisa...
> >
> >
> >On Thu, 09 Dec 2004 20:30:34 +0500, Jean ANDRE <ja...@cmtek.com> wrote:
> >
> >
> >>Bonjour everybody!
> >>
> >>Well, I have a strange behavior with floating number and date time
format.
> >>
> >> 1 ) With float number, 77.99 becomes 77.989998 output string under
> >>Axis. Why I lost some digits ??????!!!
> >>
> >> 2) With datetime format , in c++ test code, I just moved some fields
> >>to another one of the same structure and I get the following output
> >>string: with Axis
> >> <txnDate>*2004-12-09T19:54:32Z*</txnDate>
> >>
> >> I supposed that Z is for TimeZone ? But how to construct a time to
> >>obtain such string ?
> >>
> >>With dot-net client application and a java application I got the
> >>following string:
> >><txnDate>2004-12-08T00:00:00.0000000-05:00</txnDate>
> >>
> >>Thanks a lot for your answers. Take care!
> >>
> >>Jean .A - Canada
> >>
> >>In c++ test code, I put the following code according to the WSDL.
> >>
> >>C++ Test code under Microsoft Visual C++
> >>==============================
> >>class TxnAmount
> >>{
> >>public:
> >> float amount;
> >> xsd__string currency;
> >> TxnAmount();
> >> ~TxnAmount();
> >>};
> >>
> >> xsd__dateTime txnDate;
> >> tm* curTime;
> >> time_t timer;
> >>
> >> amount.amount = 77.99; // paymentForm.amount
> >> amount.currency = "USD"; // paymentForm.currency
> >>
> >> memset(&txnDate, 0x00, sizeof(xsd__dateTime));
> >> timer = time(NULL);
> >> curTime = localtime( &timer );
> >> txnDate.tm_isdst = curTime->tm_isdst;
> >> txnDate.tm_hour = curTime->tm_hour;
> >> txnDate.tm_min = curTime->tm_min;
> >> txnDate.tm_sec = curTime->tm_sec;
> >> txnDate.tm_wday = curTime->tm_wday;
> >> txnDate.tm_yday = curTime->tm_yday;
> >> txnDate.tm_mday = curTime->tm_mday; //
> >>paymentForm.txnDateD - day of the month - [1,31]
> >> txnDate.tm_mon = curTime->tm_mon; //
> >>paymentForm.txnDateM - months since January - [0,11]
> >> txnDate.tm_year = curTime->tm_year; //
> >>paymentForm.txnDateY - years since 1900
> >>
> >>Fragment of the WDSL:
> >>==================
> >> <xs:element name="txnDate" type="xs:dateTime" minOccurs="0">
> >> </xs:element>
> >> <xs:complexType name="TxnAmount">
> >> <xs:sequence>
> >> <xs:element name="amount">
> >> <xs:simpleType>
> >> <xs:restriction base="xs:float">
> >> <xs:minInclusive value="0.00"/>
> >> <xs:maxInclusive value="9999999999.99"/>
> >> </xs:restriction>
> >> </xs:simpleType>
> >> </xs:element>
> >> <xs:element name="currency" minOccurs="0">
> >> <xs:simpleType>
> >> <xs:restriction base="xs:string">
> >> <xs:enumeration value="USD"/>
> >> <xs:enumeration value="CAD"/>
> >> </xs:restriction>
> >> </xs:simpleType>
> >> </xs:element>
> >> </xs:sequence>
> >> </xs:complexType>
> >>
> >>Fragment of the string sent by AXIS ?? Look the field amount !!!!
> >>=============================================
> >><ns1:txnRequest>
> >><orderTotal>
> >><amount>77.989998</amount>
> >><currency>USD</currency>
> >></orderTotal>
> >><billTo>
> >>
> >><txnDate>*2004-12-09T19:54:32Z*</txnDate>
> >>
> >>
> >>
> >>
> >
> >
> >
>
Re: float type and date time format
Posted by Jean ANDRE <ja...@cmtek.com>.
Hello Samisa Abeysinghe,
According to John Bofish email, the "Z" is for UTC time and Zero Zone.
The time format is correct but under other developpment tools as .Net
and Java (but not Axis), the time is given in GMT. "UTC is the
successor of Greenwich Mean Time </wiki/Greenwich_Mean_Time>,". So,
the question is now, could we support both format or translate one to
another one easily, under the hood. It if really necessary to support
both formats, does existing architectures and softwares understand the
UTC format ?
As I wasn't able to complete test under Axis due to some bug with
Complex Structure (soaq response) , I can't tell you if the Z is an issue.
> That's a good guess. 'Z' is for "UTC", or Coordinated Universal Time. See
> http://en.wikipedia.org/wiki/Coordinated_Universal_Time for more on UTC.
> The World Wide Web Consortium has a note about date and time formats
> (http://www.w3.org/TR/NOTE-datetime) where it states:
Thank you very much for your answers.
Best regards,
Jean A. - Canada -
Samisa Abeysinghe wrote:
>Bonjour Jean,
>
>Re: the datetime problem.
>I had a look at the source and the trailing 'Z' character seems to be
>hard coded in the serialize code in src/common/AxisTime.cpp. There is
>no mention of why Z has been used there - not even a comment, so I am
>not sure what it means.
>
>However, if we want to change the format, we can do that by fixing the code.
>
>Also, I used Axis Java's echo service and client samples, and saw that
>Axis Java also send something similar to "2004-12-13T14:45:11Z".
>
>BTW, you have copied values from tm struct to xsd__dateTime struct.
>This is not necessary, as the xsd__dateTime is defined to be of type
>tm. So you can use type tm directly as the parameter to the web
>service method.
>
>Thanks,
>Samisa...
>
>
>On Thu, 09 Dec 2004 20:30:34 +0500, Jean ANDRE <ja...@cmtek.com> wrote:
>
>
>>Bonjour everybody!
>>
>>Well, I have a strange behavior with floating number and date time format.
>>
>> 1 ) With float number, 77.99 becomes 77.989998 output string under
>>Axis. Why I lost some digits ??????!!!
>>
>> 2) With datetime format , in c++ test code, I just moved some fields
>>to another one of the same structure and I get the following output
>>string: with Axis
>> <txnDate>*2004-12-09T19:54:32Z*</txnDate>
>>
>> I supposed that Z is for TimeZone ? But how to construct a time to
>>obtain such string ?
>>
>>With dot-net client application and a java application I got the
>>following string:
>><txnDate>2004-12-08T00:00:00.0000000-05:00</txnDate>
>>
>>Thanks a lot for your answers. Take care!
>>
>>Jean .A - Canada
>>
>>In c++ test code, I put the following code according to the WSDL.
>>
>>C++ Test code under Microsoft Visual C++
>>==============================
>>class TxnAmount
>>{
>>public:
>> float amount;
>> xsd__string currency;
>> TxnAmount();
>> ~TxnAmount();
>>};
>>
>> xsd__dateTime txnDate;
>> tm* curTime;
>> time_t timer;
>>
>> amount.amount = 77.99; // paymentForm.amount
>> amount.currency = "USD"; // paymentForm.currency
>>
>> memset(&txnDate, 0x00, sizeof(xsd__dateTime));
>> timer = time(NULL);
>> curTime = localtime( &timer );
>> txnDate.tm_isdst = curTime->tm_isdst;
>> txnDate.tm_hour = curTime->tm_hour;
>> txnDate.tm_min = curTime->tm_min;
>> txnDate.tm_sec = curTime->tm_sec;
>> txnDate.tm_wday = curTime->tm_wday;
>> txnDate.tm_yday = curTime->tm_yday;
>> txnDate.tm_mday = curTime->tm_mday; //
>>paymentForm.txnDateD - day of the month - [1,31]
>> txnDate.tm_mon = curTime->tm_mon; //
>>paymentForm.txnDateM - months since January - [0,11]
>> txnDate.tm_year = curTime->tm_year; //
>>paymentForm.txnDateY - years since 1900
>>
>>Fragment of the WDSL:
>>==================
>> <xs:element name="txnDate" type="xs:dateTime" minOccurs="0">
>> </xs:element>
>> <xs:complexType name="TxnAmount">
>> <xs:sequence>
>> <xs:element name="amount">
>> <xs:simpleType>
>> <xs:restriction base="xs:float">
>> <xs:minInclusive value="0.00"/>
>> <xs:maxInclusive value="9999999999.99"/>
>> </xs:restriction>
>> </xs:simpleType>
>> </xs:element>
>> <xs:element name="currency" minOccurs="0">
>> <xs:simpleType>
>> <xs:restriction base="xs:string">
>> <xs:enumeration value="USD"/>
>> <xs:enumeration value="CAD"/>
>> </xs:restriction>
>> </xs:simpleType>
>> </xs:element>
>> </xs:sequence>
>> </xs:complexType>
>>
>>Fragment of the string sent by AXIS ?? Look the field amount !!!!
>>=============================================
>><ns1:txnRequest>
>><orderTotal>
>><amount>77.989998</amount>
>><currency>USD</currency>
>></orderTotal>
>><billTo>
>>
>><txnDate>*2004-12-09T19:54:32Z*</txnDate>
>>
>>
>>
>>
>
>
>
Re: float type and date time format
Posted by Samisa Abeysinghe <sa...@gmail.com>.
Bonjour Jean,
Re: the datetime problem.
I had a look at the source and the trailing 'Z' character seems to be
hard coded in the serialize code in src/common/AxisTime.cpp. There is
no mention of why Z has been used there - not even a comment, so I am
not sure what it means.
However, if we want to change the format, we can do that by fixing the code.
Also, I used Axis Java's echo service and client samples, and saw that
Axis Java also send something similar to "2004-12-13T14:45:11Z".
BTW, you have copied values from tm struct to xsd__dateTime struct.
This is not necessary, as the xsd__dateTime is defined to be of type
tm. So you can use type tm directly as the parameter to the web
service method.
Thanks,
Samisa...
On Thu, 09 Dec 2004 20:30:34 +0500, Jean ANDRE <ja...@cmtek.com> wrote:
> Bonjour everybody!
>
> Well, I have a strange behavior with floating number and date time format.
>
> 1 ) With float number, 77.99 becomes 77.989998 output string under
> Axis. Why I lost some digits ??????!!!
>
> 2) With datetime format , in c++ test code, I just moved some fields
> to another one of the same structure and I get the following output
> string: with Axis
> <txnDate>*2004-12-09T19:54:32Z*</txnDate>
>
> I supposed that Z is for TimeZone ? But how to construct a time to
> obtain such string ?
>
> With dot-net client application and a java application I got the
> following string:
> <txnDate>2004-12-08T00:00:00.0000000-05:00</txnDate>
>
> Thanks a lot for your answers. Take care!
>
> Jean .A - Canada
>
> In c++ test code, I put the following code according to the WSDL.
>
> C++ Test code under Microsoft Visual C++
> ==============================
> class TxnAmount
> {
> public:
> float amount;
> xsd__string currency;
> TxnAmount();
> ~TxnAmount();
> };
>
> xsd__dateTime txnDate;
> tm* curTime;
> time_t timer;
>
> amount.amount = 77.99; // paymentForm.amount
> amount.currency = "USD"; // paymentForm.currency
>
> memset(&txnDate, 0x00, sizeof(xsd__dateTime));
> timer = time(NULL);
> curTime = localtime( &timer );
> txnDate.tm_isdst = curTime->tm_isdst;
> txnDate.tm_hour = curTime->tm_hour;
> txnDate.tm_min = curTime->tm_min;
> txnDate.tm_sec = curTime->tm_sec;
> txnDate.tm_wday = curTime->tm_wday;
> txnDate.tm_yday = curTime->tm_yday;
> txnDate.tm_mday = curTime->tm_mday; //
> paymentForm.txnDateD - day of the month - [1,31]
> txnDate.tm_mon = curTime->tm_mon; //
> paymentForm.txnDateM - months since January - [0,11]
> txnDate.tm_year = curTime->tm_year; //
> paymentForm.txnDateY - years since 1900
>
> Fragment of the WDSL:
> ==================
> <xs:element name="txnDate" type="xs:dateTime" minOccurs="0">
> </xs:element>
> <xs:complexType name="TxnAmount">
> <xs:sequence>
> <xs:element name="amount">
> <xs:simpleType>
> <xs:restriction base="xs:float">
> <xs:minInclusive value="0.00"/>
> <xs:maxInclusive value="9999999999.99"/>
> </xs:restriction>
> </xs:simpleType>
> </xs:element>
> <xs:element name="currency" minOccurs="0">
> <xs:simpleType>
> <xs:restriction base="xs:string">
> <xs:enumeration value="USD"/>
> <xs:enumeration value="CAD"/>
> </xs:restriction>
> </xs:simpleType>
> </xs:element>
> </xs:sequence>
> </xs:complexType>
>
> Fragment of the string sent by AXIS ?? Look the field amount !!!!
> =============================================
> <ns1:txnRequest>
> <orderTotal>
> <amount>77.989998</amount>
> <currency>USD</currency>
> </orderTotal>
> <billTo>
>
> <txnDate>*2004-12-09T19:54:32Z*</txnDate>
>
>
Re: float type and date time format
Posted by Jean ANDRE <ja...@cmtek.com>.
Hello,
Finally I've downloaded the source code to see that the "Z" at the end
of date-time string of the soap request inside Axis was hard-coded. This
behavior is clearly not the same under java and dot-net application.
Source file is AxisTime.cpp into src/common folder. What's the
specification for date-time and why we have such difference ? Does the
1.4 solve the problem ?
AxisString & AxisTime::serialize(struct tm tValue, XSDTYPE nType)
{
/*formats the output date in the format CCYY-MM-DDThh:mm:ssZ */
switch (nType)
{
case XSD_DATETIME:
strftime (buf1, TIMEBUFFSIZE, "%Y-%m-%dT%H:%M:%SZ", &tValue);
strXSDDate = buf1;
//AxisUtils::convert(strXSDDate, buf1);
break;
case XSD_DATE:
strftime (buf1, TIMEBUFFSIZE, "%Y-%m-%dZ", &tValue);
strXSDDate = buf1;
//AxisUtils::convert(strXSDDate, buf1);
break;
case XSD_TIME:
strftime (buf1, TIMEBUFFSIZE, "%H:%M:%SZ", &tValue);
strXSDDate = buf1;
//AxisUtils::convert(strXSDDate, buf1);
break;
default:;
}
return strXSDDate;
}
Jean ANDRE wrote:
> Bonjour everybody!
>
> Well, I have a strange behavior with floating number and date time
> format.
>
> 1 ) With float number, 77.99 becomes 77.989998 output string under
> Axis. Why I lost some digits ??????!!!
>
> 2) With datetime format , in c++ test code, I just moved some fields
> to another one of the same structure and I get the following output
> string: with Axis
> <txnDate>*2004-12-09T19:54:32Z*</txnDate>
>
> I supposed that Z is for TimeZone ? But how to construct a time to
> obtain such string ?
>
> With dot-net client application and a java application I got the
> following string:
> <txnDate>2004-12-08T00:00:00.0000000-05:00</txnDate>
>
> Thanks a lot for your answers. Take care!
>
> Jean .A - Canada
>
>
> In c++ test code, I put the following code according to the WSDL.
>
> C++ Test code under Microsoft Visual C++
> ==============================
> class TxnAmount
> {
> public:
> float amount;
> xsd__string currency;
> TxnAmount();
> ~TxnAmount();
> };
>
> xsd__dateTime txnDate;
> tm* curTime;
> time_t timer;
>
>
> amount.amount = 77.99; // paymentForm.amount
> amount.currency = "USD"; // paymentForm.currency
>
>
> memset(&txnDate, 0x00, sizeof(xsd__dateTime));
> timer = time(NULL);
> curTime = localtime( &timer );
> txnDate.tm_isdst = curTime->tm_isdst;
> txnDate.tm_hour = curTime->tm_hour;
> txnDate.tm_min = curTime->tm_min;
> txnDate.tm_sec = curTime->tm_sec;
> txnDate.tm_wday = curTime->tm_wday;
> txnDate.tm_yday = curTime->tm_yday;
> txnDate.tm_mday = curTime->tm_mday; //
> paymentForm.txnDateD - day of the month - [1,31]
> txnDate.tm_mon = curTime->tm_mon; //
> paymentForm.txnDateM - months since January - [0,11]
> txnDate.tm_year = curTime->tm_year; //
> paymentForm.txnDateY - years since 1900
>
> Fragment of the WDSL:
> ==================
> <xs:element name="txnDate" type="xs:dateTime" minOccurs="0">
> </xs:element>
> <xs:complexType name="TxnAmount">
> <xs:sequence>
> <xs:element name="amount">
> <xs:simpleType>
> <xs:restriction base="xs:float">
> <xs:minInclusive value="0.00"/>
> <xs:maxInclusive value="9999999999.99"/>
> </xs:restriction>
> </xs:simpleType>
> </xs:element>
> <xs:element name="currency" minOccurs="0">
> <xs:simpleType>
> <xs:restriction base="xs:string">
> <xs:enumeration value="USD"/>
> <xs:enumeration value="CAD"/>
> </xs:restriction>
> </xs:simpleType>
> </xs:element>
> </xs:sequence>
> </xs:complexType>
>
>
> Fragment of the string sent by AXIS ?? Look the field amount !!!!
> =============================================
> <ns1:txnRequest>
> <orderTotal>
> <amount>77.989998</amount>
> <currency>USD</currency>
> </orderTotal>
> <billTo>
>
> <txnDate>*2004-12-09T19:54:32Z*</txnDate>
>
>
Re: float type and date time format
Posted by Jean ANDRE <ja...@cmtek.com>.
Bonjour Samisa Abeysinghe,
Thank's a lot for this quick fix ;). I imagine that fix will help many
other developpers!
Take care and have a nice day.
Jean A. - Canada
Samisa Abeysinghe wrote:
>Hi Jean,
> I provided a quick fix for the floating point problem.
> Obviously, the problem is with the serilization of the float values.
>
> With the fix, it will work correctly upto 4 decimal places. But
>for the fifth, it rounds off. Please see
>http://nagoya.apache.org/jira/browse/AXISCPP-320 for details.
>
> If we wish to convert float values with more than four decimal
>places correctly, we may have to write our own sprintf for float
>values. Also we have the 4 decimal pace restriction with
>deserialization as well. The function used, strtod, can only deal with
>upto 4 decimal places correctly. If we want more precision, we may
>have to write our own function for strtod as well.
>
>Thanks,
>Samisa...
>
>
>On Thu, 09 Dec 2004 21:40:36 +0500, Jean ANDRE <ja...@cmtek.com> wrote:
>
>
>>Bonjour John,
>>
>>Thank you very much for your answer.
>>In my case, as we talk about money and paiement system, it is
>>"unacceptable" to pay 98.989998 when the price is 98.99 !.
>>Well, well, as I sent the correct type according to the WSDL and Axis
>>generation classes and as I have no way to modify the third party wsdl
>>file, that means it is a serious problem from Axis, whitout no quick
>>solution ? hum, hum... :(
>>
>>So, to return back to the time date, do you think that is not a problem
>>for the webservice to understand such datetime? because I've still have
>>a problem of the XML parser. It is not the name space ns1 instead of
>>nothing (see related answer, it should be ok)- . It is not the float
>>number ?, it is not the date-time format ? and I still have a bat ptr
>>in Axis.... to get my value after a complex type on the answer from the
>>web services!
>>
>>Take care and thank again for your answer!
>>
>>Jean A - Canada
>>
>>
>>
>>
>>John Bodfish wrote:
>>
>>
>>
>>>Bonjour aussi!
>>>
>>>I don't know the answer to most of your questions, but here are some
>>>comments.
>>>
>>>You wrote:
>>> With float number, 77.99 becomes 77.989998 output string under Axis.
>>>
>>>I think that's probably because conversion of a string "77.99" to the
>>>representation of a floating point number and back again is likely to lead
>>>to "small" differences. Whether you think 0.000002 is a "small" difference
>>>probably depends on whether you're calculating the size of the moon or your
>>>trajectory to it. :) There's probably a way to restrict the number of
>>>decimal digits in the string representation of the floating point number, in
>>>which case "77.989998" internal representation would get rounded up to
>>>"77.99" when converted to a string.
>>>
>>>
>>>You also wrote:
>>> I supposed that Z is for TimeZone?
>>>
>>>That's a good guess. 'Z' is for "UTC", or Coordinated Universal Time. See
>>>http://en.wikipedia.org/wiki/Coordinated_Universal_Time for more on UTC.
>>>
>>>The World Wide Web Consortium has a note about date and time formats
>>>(http://www.w3.org/TR/NOTE-datetime) where it states:
>>>
>>>"This profile defines two ways of handling time zone offsets:
>>>
>>>1. Times are expressed in UTC (Coordinated Universal Time), with a special
>>>UTC designator ("Z").
>>>2. Times are expressed in local time, together with a time zone offset in
>>>hours and minutes. A time zone offset of "+hh:mm" indicates that the
>>>date/time uses a local time zone which is "hh" hours and "mm" minutes ahead
>>>of UTC. A time zone offset of "-hh:mm" indicates that the date/time uses a
>>>local time zone which is "hh" hours and "mm" minutes behind UTC.
>>>
>>>A standard referencing this profile should permit one or both of these ways
>>>of handling time zone offsets."
>>>
>>>I don't know what the relevant SOAP standards state, but the date strings
>>>you get look like they both conform.
>>>
>>>The string "2004-12-08T00:00:00.0000000-05:00" that .NET/Java produces
>>>represents midnight, the morning of December 8th, 2004 in a time zone that
>>>is 5 hours behind UTC (such as the Eastern Time zone of Canada).
>>>
>>>The string "2004-12-09T19:54:32Z" that Axis produces represents December
>>>9th, 2004 at 19:54:32 UTC, which would be 14:54:32 in the Eastern Time Zone
>>>of Canada.
>>>
>>>I don't know where the asterisks in the Axis date string come from.
>>>
>>>I hope others help with the rest of your questions!
>>>
>>>John
>>>
>>>
>>>
>>>-----Original Message-----
>>>From: Jean ANDRE [mailto:jandre@cmtek.com]
>>>Sent: Thursday, December 09, 2004 9:31 AM
>>>To: axis-c-user@ws.apache.org
>>>Subject: float type and date time format
>>>
>>>Bonjour everybody!
>>>
>>>Well, I have a strange behavior with floating number and date time format.
>>>
>>>1 ) With float number, 77.99 becomes 77.989998 output string under
>>>Axis. Why I lost some digits ??????!!!
>>>
>>>2) With datetime format , in c++ test code, I just moved some fields
>>>to another one of the same structure and I get the following output
>>>string: with Axis
>>> <txnDate>*2004-12-09T19:54:32Z*</txnDate>
>>>
>>>I supposed that Z is for TimeZone ? But how to construct a time to
>>>obtain such string ?
>>>
>>>With dot-net client application and a java application I got the
>>>following string:
>>><txnDate>2004-12-08T00:00:00.0000000-05:00</txnDate>
>>>
>>>Thanks a lot for your answers. Take care!
>>>
>>>Jean .A - Canada
>>>
>>>
>>>In c++ test code, I put the following code according to the WSDL.
>>>
>>>C++ Test code under Microsoft Visual C++
>>>==============================
>>>class TxnAmount
>>>{
>>>public:
>>> float amount;
>>> xsd__string currency;
>>> TxnAmount();
>>> ~TxnAmount();
>>>};
>>>
>>> xsd__dateTime txnDate;
>>> tm* curTime;
>>> time_t timer;
>>>
>>>
>>> amount.amount = 77.99; // paymentForm.amount
>>> amount.currency = "USD"; // paymentForm.currency
>>>
>>>
>>> memset(&txnDate, 0x00, sizeof(xsd__dateTime));
>>> timer = time(NULL);
>>> curTime = localtime( &timer );
>>> txnDate.tm_isdst = curTime->tm_isdst;
>>> txnDate.tm_hour = curTime->tm_hour;
>>> txnDate.tm_min = curTime->tm_min;
>>> txnDate.tm_sec = curTime->tm_sec;
>>> txnDate.tm_wday = curTime->tm_wday;
>>> txnDate.tm_yday = curTime->tm_yday;
>>> txnDate.tm_mday = curTime->tm_mday; //
>>>paymentForm.txnDateD - day of the month - [1,31]
>>> txnDate.tm_mon = curTime->tm_mon; //
>>>paymentForm.txnDateM - months since January - [0,11]
>>> txnDate.tm_year = curTime->tm_year; //
>>>paymentForm.txnDateY - years since 1900
>>>
>>>Fragment of the WDSL:
>>>==================
>>> <xs:element name="txnDate" type="xs:dateTime" minOccurs="0">
>>> </xs:element>
>>> <xs:complexType name="TxnAmount">
>>> <xs:sequence>
>>> <xs:element name="amount">
>>> <xs:simpleType>
>>> <xs:restriction base="xs:float">
>>> <xs:minInclusive value="0.00"/>
>>> <xs:maxInclusive value="9999999999.99"/>
>>> </xs:restriction>
>>> </xs:simpleType>
>>> </xs:element>
>>> <xs:element name="currency" minOccurs="0">
>>> <xs:simpleType>
>>> <xs:restriction base="xs:string">
>>> <xs:enumeration value="USD"/>
>>> <xs:enumeration value="CAD"/>
>>> </xs:restriction>
>>> </xs:simpleType>
>>> </xs:element>
>>> </xs:sequence>
>>> </xs:complexType>
>>>
>>>
>>>Fragment of the string sent by AXIS ?? Look the field amount !!!!
>>>=============================================
>>><ns1:txnRequest>
>>><orderTotal>
>>><amount>77.989998</amount>
>>><currency>USD</currency>
>>></orderTotal>
>>><billTo>
>>>
>>><txnDate>*2004-12-09T19:54:32Z*</txnDate>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>
>>
>
>
>
Re: float type and date time format
Posted by Samisa Abeysinghe <sa...@gmail.com>.
Hi Jean,
I provided a quick fix for the floating point problem.
Obviously, the problem is with the serilization of the float values.
With the fix, it will work correctly upto 4 decimal places. But
for the fifth, it rounds off. Please see
http://nagoya.apache.org/jira/browse/AXISCPP-320 for details.
If we wish to convert float values with more than four decimal
places correctly, we may have to write our own sprintf for float
values. Also we have the 4 decimal pace restriction with
deserialization as well. The function used, strtod, can only deal with
upto 4 decimal places correctly. If we want more precision, we may
have to write our own function for strtod as well.
Thanks,
Samisa...
On Thu, 09 Dec 2004 21:40:36 +0500, Jean ANDRE <ja...@cmtek.com> wrote:
> Bonjour John,
>
> Thank you very much for your answer.
> In my case, as we talk about money and paiement system, it is
> "unacceptable" to pay 98.989998 when the price is 98.99 !.
> Well, well, as I sent the correct type according to the WSDL and Axis
> generation classes and as I have no way to modify the third party wsdl
> file, that means it is a serious problem from Axis, whitout no quick
> solution ? hum, hum... :(
>
> So, to return back to the time date, do you think that is not a problem
> for the webservice to understand such datetime? because I've still have
> a problem of the XML parser. It is not the name space ns1 instead of
> nothing (see related answer, it should be ok)- . It is not the float
> number ?, it is not the date-time format ? and I still have a bat ptr
> in Axis.... to get my value after a complex type on the answer from the
> web services!
>
> Take care and thank again for your answer!
>
> Jean A - Canada
>
>
>
>
> John Bodfish wrote:
>
> >Bonjour aussi!
> >
> >I don't know the answer to most of your questions, but here are some
> >comments.
> >
> >You wrote:
> > With float number, 77.99 becomes 77.989998 output string under Axis.
> >
> >I think that's probably because conversion of a string "77.99" to the
> >representation of a floating point number and back again is likely to lead
> >to "small" differences. Whether you think 0.000002 is a "small" difference
> >probably depends on whether you're calculating the size of the moon or your
> >trajectory to it. :) There's probably a way to restrict the number of
> >decimal digits in the string representation of the floating point number, in
> >which case "77.989998" internal representation would get rounded up to
> >"77.99" when converted to a string.
> >
> >
> >You also wrote:
> > I supposed that Z is for TimeZone?
> >
> >That's a good guess. 'Z' is for "UTC", or Coordinated Universal Time. See
> >http://en.wikipedia.org/wiki/Coordinated_Universal_Time for more on UTC.
> >
> >The World Wide Web Consortium has a note about date and time formats
> >(http://www.w3.org/TR/NOTE-datetime) where it states:
> >
> >"This profile defines two ways of handling time zone offsets:
> >
> >1. Times are expressed in UTC (Coordinated Universal Time), with a special
> >UTC designator ("Z").
> >2. Times are expressed in local time, together with a time zone offset in
> >hours and minutes. A time zone offset of "+hh:mm" indicates that the
> >date/time uses a local time zone which is "hh" hours and "mm" minutes ahead
> >of UTC. A time zone offset of "-hh:mm" indicates that the date/time uses a
> >local time zone which is "hh" hours and "mm" minutes behind UTC.
> >
> >A standard referencing this profile should permit one or both of these ways
> >of handling time zone offsets."
> >
> >I don't know what the relevant SOAP standards state, but the date strings
> >you get look like they both conform.
> >
> >The string "2004-12-08T00:00:00.0000000-05:00" that .NET/Java produces
> >represents midnight, the morning of December 8th, 2004 in a time zone that
> >is 5 hours behind UTC (such as the Eastern Time zone of Canada).
> >
> >The string "2004-12-09T19:54:32Z" that Axis produces represents December
> >9th, 2004 at 19:54:32 UTC, which would be 14:54:32 in the Eastern Time Zone
> >of Canada.
> >
> >I don't know where the asterisks in the Axis date string come from.
> >
> >I hope others help with the rest of your questions!
> >
> >John
> >
> >
> >
> >-----Original Message-----
> >From: Jean ANDRE [mailto:jandre@cmtek.com]
> >Sent: Thursday, December 09, 2004 9:31 AM
> >To: axis-c-user@ws.apache.org
> >Subject: float type and date time format
> >
> >Bonjour everybody!
> >
> >Well, I have a strange behavior with floating number and date time format.
> >
> > 1 ) With float number, 77.99 becomes 77.989998 output string under
> >Axis. Why I lost some digits ??????!!!
> >
> > 2) With datetime format , in c++ test code, I just moved some fields
> >to another one of the same structure and I get the following output
> >string: with Axis
> > <txnDate>*2004-12-09T19:54:32Z*</txnDate>
> >
> > I supposed that Z is for TimeZone ? But how to construct a time to
> >obtain such string ?
> >
> >With dot-net client application and a java application I got the
> >following string:
> ><txnDate>2004-12-08T00:00:00.0000000-05:00</txnDate>
> >
> >Thanks a lot for your answers. Take care!
> >
> >Jean .A - Canada
> >
> >
> >In c++ test code, I put the following code according to the WSDL.
> >
> >C++ Test code under Microsoft Visual C++
> >==============================
> >class TxnAmount
> >{
> >public:
> > float amount;
> > xsd__string currency;
> > TxnAmount();
> > ~TxnAmount();
> >};
> >
> > xsd__dateTime txnDate;
> > tm* curTime;
> > time_t timer;
> >
> >
> > amount.amount = 77.99; // paymentForm.amount
> > amount.currency = "USD"; // paymentForm.currency
> >
> >
> > memset(&txnDate, 0x00, sizeof(xsd__dateTime));
> > timer = time(NULL);
> > curTime = localtime( &timer );
> > txnDate.tm_isdst = curTime->tm_isdst;
> > txnDate.tm_hour = curTime->tm_hour;
> > txnDate.tm_min = curTime->tm_min;
> > txnDate.tm_sec = curTime->tm_sec;
> > txnDate.tm_wday = curTime->tm_wday;
> > txnDate.tm_yday = curTime->tm_yday;
> > txnDate.tm_mday = curTime->tm_mday; //
> >paymentForm.txnDateD - day of the month - [1,31]
> > txnDate.tm_mon = curTime->tm_mon; //
> >paymentForm.txnDateM - months since January - [0,11]
> > txnDate.tm_year = curTime->tm_year; //
> >paymentForm.txnDateY - years since 1900
> >
> >Fragment of the WDSL:
> >==================
> > <xs:element name="txnDate" type="xs:dateTime" minOccurs="0">
> > </xs:element>
> > <xs:complexType name="TxnAmount">
> > <xs:sequence>
> > <xs:element name="amount">
> > <xs:simpleType>
> > <xs:restriction base="xs:float">
> > <xs:minInclusive value="0.00"/>
> > <xs:maxInclusive value="9999999999.99"/>
> > </xs:restriction>
> > </xs:simpleType>
> > </xs:element>
> > <xs:element name="currency" minOccurs="0">
> > <xs:simpleType>
> > <xs:restriction base="xs:string">
> > <xs:enumeration value="USD"/>
> > <xs:enumeration value="CAD"/>
> > </xs:restriction>
> > </xs:simpleType>
> > </xs:element>
> > </xs:sequence>
> > </xs:complexType>
> >
> >
> >Fragment of the string sent by AXIS ?? Look the field amount !!!!
> >=============================================
> ><ns1:txnRequest>
> ><orderTotal>
> ><amount>77.989998</amount>
> ><currency>USD</currency>
> ></orderTotal>
> ><billTo>
> >
> ><txnDate>*2004-12-09T19:54:32Z*</txnDate>
> >
> >
> >
> >
> >
> >
>
>
Re: float type and date time format
Posted by Samisa Abeysinghe <sa...@gmail.com>.
Hi Jean,
I provided a quick fix for the floating point problem.
Obviously, the problem is with the serilization of the float values.
With the fix, it will work correctly upto 4 decimal places. But
for the fifth, it rounds off. Please see
http://nagoya.apache.org/jira/browse/AXISCPP-320 for details.
If we wish to convert float values with more than four decimal
places correctly, we may have to write our own sprintf for float
values. Also we have the 4 decimal pace restriction with
deserialization as well. The function used, strtod, can only deal with
upto 4 decimal places correctly. If we want more precision, we may
have to write our own function for strtod as well.
Thanks,
Samisa...
On Thu, 09 Dec 2004 21:40:36 +0500, Jean ANDRE <ja...@cmtek.com> wrote:
> Bonjour John,
>
> Thank you very much for your answer.
> In my case, as we talk about money and paiement system, it is
> "unacceptable" to pay 98.989998 when the price is 98.99 !.
> Well, well, as I sent the correct type according to the WSDL and Axis
> generation classes and as I have no way to modify the third party wsdl
> file, that means it is a serious problem from Axis, whitout no quick
> solution ? hum, hum... :(
>
> So, to return back to the time date, do you think that is not a problem
> for the webservice to understand such datetime? because I've still have
> a problem of the XML parser. It is not the name space ns1 instead of
> nothing (see related answer, it should be ok)- . It is not the float
> number ?, it is not the date-time format ? and I still have a bat ptr
> in Axis.... to get my value after a complex type on the answer from the
> web services!
>
> Take care and thank again for your answer!
>
> Jean A - Canada
>
>
>
>
> John Bodfish wrote:
>
> >Bonjour aussi!
> >
> >I don't know the answer to most of your questions, but here are some
> >comments.
> >
> >You wrote:
> > With float number, 77.99 becomes 77.989998 output string under Axis.
> >
> >I think that's probably because conversion of a string "77.99" to the
> >representation of a floating point number and back again is likely to lead
> >to "small" differences. Whether you think 0.000002 is a "small" difference
> >probably depends on whether you're calculating the size of the moon or your
> >trajectory to it. :) There's probably a way to restrict the number of
> >decimal digits in the string representation of the floating point number, in
> >which case "77.989998" internal representation would get rounded up to
> >"77.99" when converted to a string.
> >
> >
> >You also wrote:
> > I supposed that Z is for TimeZone?
> >
> >That's a good guess. 'Z' is for "UTC", or Coordinated Universal Time. See
> >http://en.wikipedia.org/wiki/Coordinated_Universal_Time for more on UTC.
> >
> >The World Wide Web Consortium has a note about date and time formats
> >(http://www.w3.org/TR/NOTE-datetime) where it states:
> >
> >"This profile defines two ways of handling time zone offsets:
> >
> >1. Times are expressed in UTC (Coordinated Universal Time), with a special
> >UTC designator ("Z").
> >2. Times are expressed in local time, together with a time zone offset in
> >hours and minutes. A time zone offset of "+hh:mm" indicates that the
> >date/time uses a local time zone which is "hh" hours and "mm" minutes ahead
> >of UTC. A time zone offset of "-hh:mm" indicates that the date/time uses a
> >local time zone which is "hh" hours and "mm" minutes behind UTC.
> >
> >A standard referencing this profile should permit one or both of these ways
> >of handling time zone offsets."
> >
> >I don't know what the relevant SOAP standards state, but the date strings
> >you get look like they both conform.
> >
> >The string "2004-12-08T00:00:00.0000000-05:00" that .NET/Java produces
> >represents midnight, the morning of December 8th, 2004 in a time zone that
> >is 5 hours behind UTC (such as the Eastern Time zone of Canada).
> >
> >The string "2004-12-09T19:54:32Z" that Axis produces represents December
> >9th, 2004 at 19:54:32 UTC, which would be 14:54:32 in the Eastern Time Zone
> >of Canada.
> >
> >I don't know where the asterisks in the Axis date string come from.
> >
> >I hope others help with the rest of your questions!
> >
> >John
> >
> >
> >
> >-----Original Message-----
> >From: Jean ANDRE [mailto:jandre@cmtek.com]
> >Sent: Thursday, December 09, 2004 9:31 AM
> >To: axis-c-user@ws.apache.org
> >Subject: float type and date time format
> >
> >Bonjour everybody!
> >
> >Well, I have a strange behavior with floating number and date time format.
> >
> > 1 ) With float number, 77.99 becomes 77.989998 output string under
> >Axis. Why I lost some digits ??????!!!
> >
> > 2) With datetime format , in c++ test code, I just moved some fields
> >to another one of the same structure and I get the following output
> >string: with Axis
> > <txnDate>*2004-12-09T19:54:32Z*</txnDate>
> >
> > I supposed that Z is for TimeZone ? But how to construct a time to
> >obtain such string ?
> >
> >With dot-net client application and a java application I got the
> >following string:
> ><txnDate>2004-12-08T00:00:00.0000000-05:00</txnDate>
> >
> >Thanks a lot for your answers. Take care!
> >
> >Jean .A - Canada
> >
> >
> >In c++ test code, I put the following code according to the WSDL.
> >
> >C++ Test code under Microsoft Visual C++
> >==============================
> >class TxnAmount
> >{
> >public:
> > float amount;
> > xsd__string currency;
> > TxnAmount();
> > ~TxnAmount();
> >};
> >
> > xsd__dateTime txnDate;
> > tm* curTime;
> > time_t timer;
> >
> >
> > amount.amount = 77.99; // paymentForm.amount
> > amount.currency = "USD"; // paymentForm.currency
> >
> >
> > memset(&txnDate, 0x00, sizeof(xsd__dateTime));
> > timer = time(NULL);
> > curTime = localtime( &timer );
> > txnDate.tm_isdst = curTime->tm_isdst;
> > txnDate.tm_hour = curTime->tm_hour;
> > txnDate.tm_min = curTime->tm_min;
> > txnDate.tm_sec = curTime->tm_sec;
> > txnDate.tm_wday = curTime->tm_wday;
> > txnDate.tm_yday = curTime->tm_yday;
> > txnDate.tm_mday = curTime->tm_mday; //
> >paymentForm.txnDateD - day of the month - [1,31]
> > txnDate.tm_mon = curTime->tm_mon; //
> >paymentForm.txnDateM - months since January - [0,11]
> > txnDate.tm_year = curTime->tm_year; //
> >paymentForm.txnDateY - years since 1900
> >
> >Fragment of the WDSL:
> >==================
> > <xs:element name="txnDate" type="xs:dateTime" minOccurs="0">
> > </xs:element>
> > <xs:complexType name="TxnAmount">
> > <xs:sequence>
> > <xs:element name="amount">
> > <xs:simpleType>
> > <xs:restriction base="xs:float">
> > <xs:minInclusive value="0.00"/>
> > <xs:maxInclusive value="9999999999.99"/>
> > </xs:restriction>
> > </xs:simpleType>
> > </xs:element>
> > <xs:element name="currency" minOccurs="0">
> > <xs:simpleType>
> > <xs:restriction base="xs:string">
> > <xs:enumeration value="USD"/>
> > <xs:enumeration value="CAD"/>
> > </xs:restriction>
> > </xs:simpleType>
> > </xs:element>
> > </xs:sequence>
> > </xs:complexType>
> >
> >
> >Fragment of the string sent by AXIS ?? Look the field amount !!!!
> >=============================================
> ><ns1:txnRequest>
> ><orderTotal>
> ><amount>77.989998</amount>
> ><currency>USD</currency>
> ></orderTotal>
> ><billTo>
> >
> ><txnDate>*2004-12-09T19:54:32Z*</txnDate>
> >
> >
> >
> >
> >
> >
>
>
RE: float type and date time format
Posted by John Bodfish <jb...@fdusa.com>.
Jean:
I don't think I can be of any further assistance since I don't have a
current copy of Axis C++.
IMHO monetary amounts should *NEVER* be encoded into strings as a floating
point number. They should be "normalized" (all modern currencies have 2 or
(very rarely) 3 decimal digits) so that $10.05 becomes "1005" and there's an
implied decimal point. Belt-and-suspenders types can add an attribute that
explicitly states the number of decimal positions. This would eliminate the
problem you're having. Also currencies need currency codes - or else there's
too great a chance of being misunderstood (for example, was the "$" in my
example US dollars or Canadian dollars?).
Of course as you say you can't modify the third party wsdl. Let's hope
nobody uses systems built with it! ;)
John
-----Original Message-----
From: Jean ANDRE [mailto:jandre@cmtek.com]
Sent: Thursday, December 09, 2004 10:41 AM
To: Apache AXIS C User List
Subject: Re: float type and date time format
Bonjour John,
Thank you very much for your answer.
In my case, as we talk about money and paiement system, it is
"unacceptable" to pay 98.989998 when the price is 98.99 !.
Well, well, as I sent the correct type according to the WSDL and Axis
generation classes and as I have no way to modify the third party wsdl
file, that means it is a serious problem from Axis, whitout no quick
solution ? hum, hum... :(
So, to return back to the time date, do you think that is not a problem
for the webservice to understand such datetime? because I've still have
a problem of the XML parser. It is not the name space ns1 instead of
nothing (see related answer, it should be ok)- . It is not the float
number ?, it is not the date-time format ? and I still have a bat ptr
in Axis.... to get my value after a complex type on the answer from the
web services!
Take care and thank again for your answer!
Jean A - Canada
John Bodfish wrote:
>Bonjour aussi!
>
>I don't know the answer to most of your questions, but here are some
>comments.
>
>You wrote:
> With float number, 77.99 becomes 77.989998 output string under Axis.
>
>I think that's probably because conversion of a string "77.99" to the
>representation of a floating point number and back again is likely to lead
>to "small" differences. Whether you think 0.000002 is a "small" difference
>probably depends on whether you're calculating the size of the moon or your
>trajectory to it. :) There's probably a way to restrict the number of
>decimal digits in the string representation of the floating point number,
in
>which case "77.989998" internal representation would get rounded up to
>"77.99" when converted to a string.
>
>
>You also wrote:
> I supposed that Z is for TimeZone?
>
>That's a good guess. 'Z' is for "UTC", or Coordinated Universal Time. See
>http://en.wikipedia.org/wiki/Coordinated_Universal_Time for more on UTC.
>
>The World Wide Web Consortium has a note about date and time formats
>(http://www.w3.org/TR/NOTE-datetime) where it states:
>
>"This profile defines two ways of handling time zone offsets:
>
>1. Times are expressed in UTC (Coordinated Universal Time), with a special
>UTC designator ("Z").
>2. Times are expressed in local time, together with a time zone offset in
>hours and minutes. A time zone offset of "+hh:mm" indicates that the
>date/time uses a local time zone which is "hh" hours and "mm" minutes ahead
>of UTC. A time zone offset of "-hh:mm" indicates that the date/time uses a
>local time zone which is "hh" hours and "mm" minutes behind UTC.
>
>A standard referencing this profile should permit one or both of these ways
>of handling time zone offsets."
>
>I don't know what the relevant SOAP standards state, but the date strings
>you get look like they both conform.
>
>The string "2004-12-08T00:00:00.0000000-05:00" that .NET/Java produces
>represents midnight, the morning of December 8th, 2004 in a time zone that
>is 5 hours behind UTC (such as the Eastern Time zone of Canada).
>
>The string "2004-12-09T19:54:32Z" that Axis produces represents December
>9th, 2004 at 19:54:32 UTC, which would be 14:54:32 in the Eastern Time Zone
>of Canada.
>
>I don't know where the asterisks in the Axis date string come from.
>
>I hope others help with the rest of your questions!
>
>John
>
>
>
>-----Original Message-----
>From: Jean ANDRE [mailto:jandre@cmtek.com]
>Sent: Thursday, December 09, 2004 9:31 AM
>To: axis-c-user@ws.apache.org
>Subject: float type and date time format
>
>Bonjour everybody!
>
>Well, I have a strange behavior with floating number and date time format.
>
> 1 ) With float number, 77.99 becomes 77.989998 output string under
>Axis. Why I lost some digits ??????!!!
>
> 2) With datetime format , in c++ test code, I just moved some fields
>to another one of the same structure and I get the following output
>string: with Axis
> <txnDate>*2004-12-09T19:54:32Z*</txnDate>
>
> I supposed that Z is for TimeZone ? But how to construct a time to
>obtain such string ?
>
>With dot-net client application and a java application I got the
>following string:
><txnDate>2004-12-08T00:00:00.0000000-05:00</txnDate>
>
>Thanks a lot for your answers. Take care!
>
>Jean .A - Canada
>
>
>In c++ test code, I put the following code according to the WSDL.
>
>C++ Test code under Microsoft Visual C++
>==============================
>class TxnAmount
>{
>public:
> float amount;
> xsd__string currency;
> TxnAmount();
> ~TxnAmount();
>};
>
> xsd__dateTime txnDate;
> tm* curTime;
> time_t timer;
>
>
> amount.amount = 77.99; // paymentForm.amount
> amount.currency = "USD"; // paymentForm.currency
>
>
> memset(&txnDate, 0x00, sizeof(xsd__dateTime));
> timer = time(NULL);
> curTime = localtime( &timer );
> txnDate.tm_isdst = curTime->tm_isdst;
> txnDate.tm_hour = curTime->tm_hour;
> txnDate.tm_min = curTime->tm_min;
> txnDate.tm_sec = curTime->tm_sec;
> txnDate.tm_wday = curTime->tm_wday;
> txnDate.tm_yday = curTime->tm_yday;
> txnDate.tm_mday = curTime->tm_mday; //
>paymentForm.txnDateD - day of the month - [1,31]
> txnDate.tm_mon = curTime->tm_mon; //
>paymentForm.txnDateM - months since January - [0,11]
> txnDate.tm_year = curTime->tm_year; //
>paymentForm.txnDateY - years since 1900
>
>Fragment of the WDSL:
>==================
> <xs:element name="txnDate" type="xs:dateTime" minOccurs="0">
> </xs:element>
> <xs:complexType name="TxnAmount">
> <xs:sequence>
> <xs:element name="amount">
> <xs:simpleType>
> <xs:restriction base="xs:float">
> <xs:minInclusive value="0.00"/>
> <xs:maxInclusive value="9999999999.99"/>
> </xs:restriction>
> </xs:simpleType>
> </xs:element>
> <xs:element name="currency" minOccurs="0">
> <xs:simpleType>
> <xs:restriction base="xs:string">
> <xs:enumeration value="USD"/>
> <xs:enumeration value="CAD"/>
> </xs:restriction>
> </xs:simpleType>
> </xs:element>
> </xs:sequence>
> </xs:complexType>
>
>
>Fragment of the string sent by AXIS ?? Look the field amount !!!!
>=============================================
><ns1:txnRequest>
><orderTotal>
><amount>77.989998</amount>
><currency>USD</currency>
></orderTotal>
><billTo>
>
><txnDate>*2004-12-09T19:54:32Z*</txnDate>
>
>
>
>
>
>
Re: float type and date time format
Posted by Jean ANDRE <ja...@cmtek.com>.
Bonjour John,
Thank you very much for your answer.
In my case, as we talk about money and paiement system, it is
"unacceptable" to pay 98.989998 when the price is 98.99 !.
Well, well, as I sent the correct type according to the WSDL and Axis
generation classes and as I have no way to modify the third party wsdl
file, that means it is a serious problem from Axis, whitout no quick
solution ? hum, hum... :(
So, to return back to the time date, do you think that is not a problem
for the webservice to understand such datetime? because I've still have
a problem of the XML parser. It is not the name space ns1 instead of
nothing (see related answer, it should be ok)- . It is not the float
number ?, it is not the date-time format ? and I still have a bat ptr
in Axis.... to get my value after a complex type on the answer from the
web services!
Take care and thank again for your answer!
Jean A - Canada
John Bodfish wrote:
>Bonjour aussi!
>
>I don't know the answer to most of your questions, but here are some
>comments.
>
>You wrote:
> With float number, 77.99 becomes 77.989998 output string under Axis.
>
>I think that's probably because conversion of a string "77.99" to the
>representation of a floating point number and back again is likely to lead
>to "small" differences. Whether you think 0.000002 is a "small" difference
>probably depends on whether you're calculating the size of the moon or your
>trajectory to it. :) There's probably a way to restrict the number of
>decimal digits in the string representation of the floating point number, in
>which case "77.989998" internal representation would get rounded up to
>"77.99" when converted to a string.
>
>
>You also wrote:
> I supposed that Z is for TimeZone?
>
>That's a good guess. 'Z' is for "UTC", or Coordinated Universal Time. See
>http://en.wikipedia.org/wiki/Coordinated_Universal_Time for more on UTC.
>
>The World Wide Web Consortium has a note about date and time formats
>(http://www.w3.org/TR/NOTE-datetime) where it states:
>
>"This profile defines two ways of handling time zone offsets:
>
>1. Times are expressed in UTC (Coordinated Universal Time), with a special
>UTC designator ("Z").
>2. Times are expressed in local time, together with a time zone offset in
>hours and minutes. A time zone offset of "+hh:mm" indicates that the
>date/time uses a local time zone which is "hh" hours and "mm" minutes ahead
>of UTC. A time zone offset of "-hh:mm" indicates that the date/time uses a
>local time zone which is "hh" hours and "mm" minutes behind UTC.
>
>A standard referencing this profile should permit one or both of these ways
>of handling time zone offsets."
>
>I don't know what the relevant SOAP standards state, but the date strings
>you get look like they both conform.
>
>The string "2004-12-08T00:00:00.0000000-05:00" that .NET/Java produces
>represents midnight, the morning of December 8th, 2004 in a time zone that
>is 5 hours behind UTC (such as the Eastern Time zone of Canada).
>
>The string "2004-12-09T19:54:32Z" that Axis produces represents December
>9th, 2004 at 19:54:32 UTC, which would be 14:54:32 in the Eastern Time Zone
>of Canada.
>
>I don't know where the asterisks in the Axis date string come from.
>
>I hope others help with the rest of your questions!
>
>John
>
>
>
>-----Original Message-----
>From: Jean ANDRE [mailto:jandre@cmtek.com]
>Sent: Thursday, December 09, 2004 9:31 AM
>To: axis-c-user@ws.apache.org
>Subject: float type and date time format
>
>Bonjour everybody!
>
>Well, I have a strange behavior with floating number and date time format.
>
> 1 ) With float number, 77.99 becomes 77.989998 output string under
>Axis. Why I lost some digits ??????!!!
>
> 2) With datetime format , in c++ test code, I just moved some fields
>to another one of the same structure and I get the following output
>string: with Axis
> <txnDate>*2004-12-09T19:54:32Z*</txnDate>
>
> I supposed that Z is for TimeZone ? But how to construct a time to
>obtain such string ?
>
>With dot-net client application and a java application I got the
>following string:
><txnDate>2004-12-08T00:00:00.0000000-05:00</txnDate>
>
>Thanks a lot for your answers. Take care!
>
>Jean .A - Canada
>
>
>In c++ test code, I put the following code according to the WSDL.
>
>C++ Test code under Microsoft Visual C++
>==============================
>class TxnAmount
>{
>public:
> float amount;
> xsd__string currency;
> TxnAmount();
> ~TxnAmount();
>};
>
> xsd__dateTime txnDate;
> tm* curTime;
> time_t timer;
>
>
> amount.amount = 77.99; // paymentForm.amount
> amount.currency = "USD"; // paymentForm.currency
>
>
> memset(&txnDate, 0x00, sizeof(xsd__dateTime));
> timer = time(NULL);
> curTime = localtime( &timer );
> txnDate.tm_isdst = curTime->tm_isdst;
> txnDate.tm_hour = curTime->tm_hour;
> txnDate.tm_min = curTime->tm_min;
> txnDate.tm_sec = curTime->tm_sec;
> txnDate.tm_wday = curTime->tm_wday;
> txnDate.tm_yday = curTime->tm_yday;
> txnDate.tm_mday = curTime->tm_mday; //
>paymentForm.txnDateD - day of the month - [1,31]
> txnDate.tm_mon = curTime->tm_mon; //
>paymentForm.txnDateM - months since January - [0,11]
> txnDate.tm_year = curTime->tm_year; //
>paymentForm.txnDateY - years since 1900
>
>Fragment of the WDSL:
>==================
> <xs:element name="txnDate" type="xs:dateTime" minOccurs="0">
> </xs:element>
> <xs:complexType name="TxnAmount">
> <xs:sequence>
> <xs:element name="amount">
> <xs:simpleType>
> <xs:restriction base="xs:float">
> <xs:minInclusive value="0.00"/>
> <xs:maxInclusive value="9999999999.99"/>
> </xs:restriction>
> </xs:simpleType>
> </xs:element>
> <xs:element name="currency" minOccurs="0">
> <xs:simpleType>
> <xs:restriction base="xs:string">
> <xs:enumeration value="USD"/>
> <xs:enumeration value="CAD"/>
> </xs:restriction>
> </xs:simpleType>
> </xs:element>
> </xs:sequence>
> </xs:complexType>
>
>
>Fragment of the string sent by AXIS ?? Look the field amount !!!!
>=============================================
><ns1:txnRequest>
><orderTotal>
><amount>77.989998</amount>
><currency>USD</currency>
></orderTotal>
><billTo>
>
><txnDate>*2004-12-09T19:54:32Z*</txnDate>
>
>
>
>
>
>
RE: float type and date time format
Posted by John Bodfish <jb...@fdusa.com>.
Bonjour aussi!
I don't know the answer to most of your questions, but here are some
comments.
You wrote:
With float number, 77.99 becomes 77.989998 output string under Axis.
I think that's probably because conversion of a string "77.99" to the
representation of a floating point number and back again is likely to lead
to "small" differences. Whether you think 0.000002 is a "small" difference
probably depends on whether you're calculating the size of the moon or your
trajectory to it. :) There's probably a way to restrict the number of
decimal digits in the string representation of the floating point number, in
which case "77.989998" internal representation would get rounded up to
"77.99" when converted to a string.
You also wrote:
I supposed that Z is for TimeZone?
That's a good guess. 'Z' is for "UTC", or Coordinated Universal Time. See
http://en.wikipedia.org/wiki/Coordinated_Universal_Time for more on UTC.
The World Wide Web Consortium has a note about date and time formats
(http://www.w3.org/TR/NOTE-datetime) where it states:
"This profile defines two ways of handling time zone offsets:
1. Times are expressed in UTC (Coordinated Universal Time), with a special
UTC designator ("Z").
2. Times are expressed in local time, together with a time zone offset in
hours and minutes. A time zone offset of "+hh:mm" indicates that the
date/time uses a local time zone which is "hh" hours and "mm" minutes ahead
of UTC. A time zone offset of "-hh:mm" indicates that the date/time uses a
local time zone which is "hh" hours and "mm" minutes behind UTC.
A standard referencing this profile should permit one or both of these ways
of handling time zone offsets."
I don't know what the relevant SOAP standards state, but the date strings
you get look like they both conform.
The string "2004-12-08T00:00:00.0000000-05:00" that .NET/Java produces
represents midnight, the morning of December 8th, 2004 in a time zone that
is 5 hours behind UTC (such as the Eastern Time zone of Canada).
The string "2004-12-09T19:54:32Z" that Axis produces represents December
9th, 2004 at 19:54:32 UTC, which would be 14:54:32 in the Eastern Time Zone
of Canada.
I don't know where the asterisks in the Axis date string come from.
I hope others help with the rest of your questions!
John
-----Original Message-----
From: Jean ANDRE [mailto:jandre@cmtek.com]
Sent: Thursday, December 09, 2004 9:31 AM
To: axis-c-user@ws.apache.org
Subject: float type and date time format
Bonjour everybody!
Well, I have a strange behavior with floating number and date time format.
1 ) With float number, 77.99 becomes 77.989998 output string under
Axis. Why I lost some digits ??????!!!
2) With datetime format , in c++ test code, I just moved some fields
to another one of the same structure and I get the following output
string: with Axis
<txnDate>*2004-12-09T19:54:32Z*</txnDate>
I supposed that Z is for TimeZone ? But how to construct a time to
obtain such string ?
With dot-net client application and a java application I got the
following string:
<txnDate>2004-12-08T00:00:00.0000000-05:00</txnDate>
Thanks a lot for your answers. Take care!
Jean .A - Canada
In c++ test code, I put the following code according to the WSDL.
C++ Test code under Microsoft Visual C++
==============================
class TxnAmount
{
public:
float amount;
xsd__string currency;
TxnAmount();
~TxnAmount();
};
xsd__dateTime txnDate;
tm* curTime;
time_t timer;
amount.amount = 77.99; // paymentForm.amount
amount.currency = "USD"; // paymentForm.currency
memset(&txnDate, 0x00, sizeof(xsd__dateTime));
timer = time(NULL);
curTime = localtime( &timer );
txnDate.tm_isdst = curTime->tm_isdst;
txnDate.tm_hour = curTime->tm_hour;
txnDate.tm_min = curTime->tm_min;
txnDate.tm_sec = curTime->tm_sec;
txnDate.tm_wday = curTime->tm_wday;
txnDate.tm_yday = curTime->tm_yday;
txnDate.tm_mday = curTime->tm_mday; //
paymentForm.txnDateD - day of the month - [1,31]
txnDate.tm_mon = curTime->tm_mon; //
paymentForm.txnDateM - months since January - [0,11]
txnDate.tm_year = curTime->tm_year; //
paymentForm.txnDateY - years since 1900
Fragment of the WDSL:
==================
<xs:element name="txnDate" type="xs:dateTime" minOccurs="0">
</xs:element>
<xs:complexType name="TxnAmount">
<xs:sequence>
<xs:element name="amount">
<xs:simpleType>
<xs:restriction base="xs:float">
<xs:minInclusive value="0.00"/>
<xs:maxInclusive value="9999999999.99"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="currency" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="USD"/>
<xs:enumeration value="CAD"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
Fragment of the string sent by AXIS ?? Look the field amount !!!!
=============================================
<ns1:txnRequest>
<orderTotal>
<amount>77.989998</amount>
<currency>USD</currency>
</orderTotal>
<billTo>
<txnDate>*2004-12-09T19:54:32Z*</txnDate>