If you don’t need HH:MM:SS resolution, try this for a test:

 

Generate your WSDL, and save it to a file.  Tweak the WSDL to use xsd:date instead of xsd:dateTime, point your Flex app to the modified WSDL, and see if that addresses the issue.  There are lots of posts I found on Google regarding .NET’s dateTime serialization woes…and it seems to, by default, serialize in varying formats depending on resolution and time zone.  To be fair, the formats it is generating should be properly parsed/processed on the Flex side based on the following:

 

Also, I experimented a bit with the DateFormatter object’s parseDateString method and it worked properly on all of the formats you generated

 

            <mx:Script>

                        <![CDATA[

                                    function parseDateString(str:String):Date

                                    {

                                                return DateFormatter.parseDateString(str);

                                    }

 

                                    function doTest() {

                                                alert(dateFmt.format(parseDateString("2005-06-01T00:00:00")));

                                                alert(dateFmt.format(parseDateString("2005-06-27T18:40:41.390625-07:00")));

                                                alert(dateFmt.format(parseDateString("2005-05-31T17:00:00-07:00")));

                                    }

                        ]]>

            </mx:Script>

 

            <mx:DateFormatter id="dateFmt" formatString="{'M/D/Y' + newline + 'JJ:NN:SS'}" />

 

 

Seems like there’s a disconnect somewhere inside of the deserialization in Flex, but I can’t be certain.  Sounds like it is worth creating a bug report.

 

- Rick

 

 


From: [email protected] [mailto:[email protected]] On Behalf Of Matthew Shirey
Sent: Monday, June 27, 2005 9:36 PM
To: [email protected]
Subject: Re: [flexcoders] Flex, C# Web Services, and Dates

 

well, the WSDL says:

<s:element minOccurs="1" maxOccurs=" 1" name="StartDate" type="s:dateTime" />

Because I am close to pulling all my hair out on this one, I decided to try something on the server end.  In the web method, I hard coded the StartDate propery to return DateTime.Now.  To my surpise, this actually worked.  I then tried hardcoding it to return new DateTime(2005, 6, 1, 0, 0, 0, 0).  This produced the original error.  It seems like things are a little wierd on both ends.  Depending on the date value on the server end, the server is actually sending the XML formatted differently.  I am more confused now than ever.  Does any one here have any experience using C# Web Services with Flex using the C# DateTime type?  I would be interested in some best practices type guidlines.  However the DateTime.Now value is delt with, it works, but any other date value I create doesn't work.  It's quite confusing...

-- Matthew





--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




YAHOO! GROUPS LINKS




Reply via email to