+ Start a Discussion
Vineet GogiaVineet Gogia 

problem of invalid date format in Query Filter Sample Code..!

Hi,

Im trying to develope an application in .NET environment with SForce API. While trying to run the code downloaded from sForce.com in VB.NET the following error is shown

The server returned the following fault information:

Fault Code: 0

Fault string: invalid date format: 0001-01-01T00:00:00.0000000+0530

The program '[1636] QueryFilter.exe' has exited with code 0 (0x0).

The Function where the error is reported is reproduced for your reference: (class clsSForce.vb in QueryFilter_2003 Sample Code for VB.NET)

++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Friend Function SampleQueryFilter_Simple(ByVal SelectList() As String) As Boolean

Dim ret() As Object

Dim filter(0) As Object 'Final filter array

'Create simple filter

filter(0) = MakeSimpleFilter("ownerID", MyID, "equals")

Try

ret = sForce.query("filter", "contact", 20, SelectList, filter, Nothing, Nothing, False)

Catch ex As System.Web.Services.Protocols.SoapHeaderException

'This is typical error handling for fault detection and reporting, the .Net Proxy client actually throws an

'error rather than return the fault SOAP Message.

Trace.WriteLine("The server returned the following fault information:")

Trace.WriteLine("Fault Code: " & CType(CType(ex, System.Web.Services.Protocols.SoapException).Code, System.Xml.XmlQualifiedName).Name())

Trace.WriteLine("Fault string: " & ex.Message)

Return False

End Try

Try

Dim i As Integer = 1

Dim j As Integer

Dim rootNode As System.Xml.XmlElement = ret(0)

If rootNode.InnerText.Length > 0 Then

Dim children As System.Xml.XmlNodeList = rootNode.SelectNodes("valueMap")

Dim valueNode As System.Xml.XmlNode

For Each valueNode In children

Console.WriteLine("record " & i)

For j = SelectList.GetLowerBound(0) To SelectList.GetUpperBound(0)

Console.Write(vbTab & SelectList(j) & ": ")

Dim textNode As Xml.XmlNode = valueNode.SelectSingleNode(SelectList(j))

If Not textNode Is Nothing Then

Console.Write(valueNode.SelectSingleNode(SelectList(j)).InnerText)

Else

Console.Write("")

End If

Console.WriteLine(", ")

Next

Console.WriteLine(" ")

i += 1

Next

Return True

Else

Return False

End If

Catch ex As System.Exception

System.Diagnostics.Trace.WriteLine("Unexpected error: " & ex.Message)

Return False

End Try

End Function

++++++++++++++++++++++++++++++++++++++++++++++++++++

Please help
Vineet Gogia

DevAngelDevAngel

Hi Vineet,

Did you modify the SelectList parameter to include a date field?  Can you send me the soap request?  Are you using Visual Studio 2003 or 2002? 

Vineet GogiaVineet Gogia

hi, thanx for prompt response

i have tried the the query filter code with and without date field in the select list, but error is same in the both case,
im using VS.NET 2003  and used ur sample - queryfilter 2003,
even when i run it without making any chage it gives the same problem 
please varify ur code also..

i didnt got any clue to find soap request there how can i do that

thanx

DotNetDevilDotNetDevil
hi dave,

the sample code for the queryfilter runs fine, but gives a unique problem when called from a diffrent time zone, ie in my case GMT+5.30 (india)

this gives error in datetime format, but when i change my computer's time zone to GMT:00.00, the code starts running fine.


i did'nt understand the problem and the reason for it,

thanx and regards,

Gagan B
DevAngelDevAngel

Hi DotNetDevil and Vineet,

Thanks for your great detective work, this was a strange one.

I think you have identified a bug on our SOAP stack.  The offending part of the SOAP message is the ifModifiedSince parameter, which in the sample is set to nothing, yet still gets included in the SOAP message.  Any timezones east of GMT are not being interpreted or parsed correctly.  Setting the ifModifiedSince param to nothing still causes a date to be sent to the service, the difference is that it has a positive GMT offset.  And I think this positive character (+) is where we are not properly validating the format.  Not real global.

I do have a work-around until a patch to the service can be made.  If you are in VB you will need to modify the reference.vb class, if C#, the reference.cs class.  The modification can be one of 2 things.

First option - Change the query and Beginquery functions in the reference class by removing the ifModifiedSince parameter.  The service will still accept and properly execute the call.  sample:

Public Function query(ByVal scope As String, ByVal type As String, ByVal maxRows As Integer, ByVal [select]() As Object, ByVal filter() As Object, ByVal idList() As String, ByVal useCaseSafeIDs As Boolean) As Object

Public Function Beginquery(ByVal scope As String, ByVal type As String, ByVal maxRows As Integer, ByVal [select]() As Object, ByVal filter() As Object, ByVal idList() As String, ByVal useCaseSafeIDs As Boolean, ByVal callback As System.AsyncCallback, ByVal asyncState As Object) As System.IAsyncResult

Second Option - Add new functions to the reference class that has the ifModifiedSince removed.  This option will allow you to preserve the ifModifiedSince query so that when the bug is fixed, you can begin using it.  This option requires that you leave the existing query function declarations intact and add the following:

'

System.Web.Services.Protocols.SoapRpcMethodAttribute("sfconnector:SalesforceConnector#query", RequestNamespace:="sfconnector:SalesforceConnector", ResponseNamespace:="sfconnector:SalesforceConnector"), vbSoapLogger("qtest.txt")> _

Public Function queryNoModifiedSince(ByVal scope As String, ByVal type As String, ByVal maxRows As Integer, ByVal [select]() As Object, ByVal filter() As Object, ByVal idList() As String, ByVal useCaseSafeIDs As Boolean) As Object

Dim results() As Object = Me.Invoke("query", New Object() {scope, type, maxRows, [select], filter, idList, useCaseSafeIDs})

Return CType(results(0), Object)

End Function

'

Public Function BeginqueryNoModifiedSince(ByVal scope As String, ByVal type As String, ByVal maxRows As Integer, ByVal [select]() As Object, ByVal filter() As Object, ByVal idList() As String, ByVal useCaseSafeIDs As Boolean, ByVal callback As System.AsyncCallback, ByVal asyncState As Object) As System.IAsyncResult

Return Me.BeginInvoke("query", New Object() {scope, type, maxRows, [select], filter, idList, useCaseSafeIDs}, callback, asyncState)

End Function

'

Public Function EndqueryNoModifiedSince(ByVal asyncResult As System.IAsyncResult) As Object

Dim results() As Object = Me.EndInvoke(asyncResult)

Return CType(results(0), Object)

End Function

 

I will post a notification to this thread when the patch has been released and is available.

 

 

Message Edited by DevAngel on 08-29-2003 08:52 AM

Brian.ax17Brian.ax17

Dave,

Is this a more general problem?

I am trying to query Opportunities by closeDate and get the same error. Being British Summer Time, times are GMT+1.

I'm using VB.net, but since I'm new to the Salesforce API, I might just be passing the wrong type of date. I was hoping to find a sample which included dates.

Regards,

Brian

DevAngelDevAngel

Hi Brian,

Currently we are not properly accepting GMT+ anything.  I realize the problems this creates and am doing my best to get a fix put in place.  I will let you know when we do.

DevAngelDevAngel
The problem with the GMT offset has been fixed and is available in production.