Web Services with Domino: Working around the GetValueAsNotesDateTime() bug
I have written about the problem with the XSD_DATE.GetValueAsNotesDateTime() method inside a Web Service in Domino 7. If you use this Method to get the date-value of a xsd:date element, your are in trouble on a non-us server. If the value for the day is smaller then 13, it gets returned as the month value.
This bug has been confirmed to me by IBM as SPR # BHUY76AF26.
Fortunately, there is a workaround until Lotus Quality Engineering releases a fix in one of the next Domino releases:
You can use XSD_DATE.GetValueAsString() to get the string fron the soap-request and parse it yourself.
My demo webservice now looks something like this:
1 Function GetMonthFromDate(parameter As XSD_DATE) As String
2 Dim datetime As NotesDateTime
3 Dim datetime2 As New NotesDateTime("")
4 Dim dateparts As Variant
5
6 Set datetime = parameter.GetValueAsNotesDateTime()
7
8 Print "XSD_DATE.GetValueAsNotesDateTime not working:"
9 Print "Date: " & Cstr(datetime.DateOnly)
10 Print "Month: " & Cstr(Month(datetime.DateOnly))
11 Print "————————————————————"
12 Print "Workaround:"
13 dateparts = Split(parameter.GetValueAsString(), "-")
14 datetime2.LSLocalTime = Datenumber( Cint(dateparts(0)), Cint(dateparts(1)), Cint(dateparts(2) ) )
15
16 Print "Date: " & Cstr(datetime2.DateOnly)
17 Print "Month: " & Cstr(Month(datetime2.DateOnly))
18
19 GetMonthFromDate = "Month: " & Cstr(Month(datetime2.DateOnly))
20
21 End Function
Tagged as: Domino, i18n, ibm, Lotus Notes, programming, rant, Show-n-tell thursday, SnTT, Web Service | Author: Martin Leyrer
[Donnerstag, 20070823, 21:01 | permanent link | 0 Kommentar(e)
Comments are closed for this story.