• Pat Wimberly
  • NEWBIE
  • 0 Points
  • Member since 2007

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies
I have a program running as a service; it handles custom syncronization, polling and notification tasks. When initially run it logs into SF via the API and runs fine until the session times out. I've tried catching the exception and logging in again, as well as preemptively refreshing the session every few hours, in each case simply calling the login code again. This does not do the trick.

The login routine borrows heavily from stock code and is a method of a custom class, of the form MyClass.loginSalesForceServer(Username, Password).

What do I need to do to refresh/reestablish an API connection to prevent timeout problems?

I hope I stated my problem clearly enough.

    Thanks

Code Follows:

        Public Function loginSalesForceServer(ByVal UserName As String, ByVal Password As String) As Boolean
        Dim loginRes As sforce.LoginResult

        Dim un As String = UserName
        If un.Length = 0 Then
            Return False
        End If

        Dim pw As String = Password
        If pw.Length = 0 Then
            Return False
        End If

        '/*
        '* Create the sfbinding to the sforce servics
        '*/
        sfbinding = New sforce.SforceService

        '// Time out after a minute
        sfbinding.Timeout = 60000

        Try
            loginRes = sfbinding.login(un, pw)
        Catch e As System.Web.Services.Protocols.SoapException
            '// This is likley to be caused by bad username or password
            Return False
        Catch ex As System.Exception
            '// This is something else, probably comminication
            Return False
        End Try

        sfSessionID = loginRes.sessionId
        sfServerURL = loginRes.serverUrl

        '//Change the sfbinding to the new endpoint
        sfbinding.Url = loginRes.serverUrl

        '//Create a new session header object and set the session id to that returned by the login
        sfbinding.SessionHeaderValue = New sforce.SessionHeader
        sfbinding.SessionHeaderValue.sessionId = loginRes.sessionId

        prvSalesForceLoginState = "Logged In"

        Return True
    End Function
Hi
 
We are using API call in our integration application which is in .net.  Is there any specific error code or message which specifically states that error was due to invalid username and or password. Based on which next steps would be taken like telling the user to re-enter his credentials.
 
Thanks
Srinik
  • December 20, 2007
  • Like
  • 0
Code:
string strQueryData = "select Id,Field1__c, Field2__c from CustomObj__c Where Contact__c = '0033000000GsPwn'";
arQueryResult = o2.query(strQueryData);

if (arQueryResult.records == null) {
    strErrorMsg = "No records matched query parameters";
}
else
{
    arQueryResult.records[p].Any[1].InnerText = "true";
    arQueryResult.records[p].Any[2].InnerText = "'18 09 2006'";

 
I've created a custom field of type text. but i am unable to update this via the api. The code above  is a sample of what i am trying to do:-
 
(Field1 = Checkbox
Field2 = Text)

The Update works ok and reports no errors but if i query the object straight after the second field is not set where as the first one is set correctly, this is also mirrored by the salesforce frontend

Any help would be most appreciated,is there a special way of updating move than one field or is it that the field is not updateable?

  • September 18, 2006
  • Like
  • 0