You need to sign in to do that
Don't have an account?
BGrimes
Persisting a binding object?
Hello everyone,
I'm working on an integration for my company and have a question regarding logging in and persisting the Binding object.
My main objective is to not have to login each time a call needs to be made to the Apex API. I'd like to have an initial login to get the session information, and then have the session info and the binding information persist. I'm creating a class library that will house the connectors and a generic wrapper, but have run into a problem with the binding object.
I have a class that handles and session management with a public sub called Login():
Code:
Code:
Code:
I'm really stuck and am looking for a jump start. It could just be that the property route is just bad, and I can live with that, but I'm not sure how to handle not having to login each time a call is made when there is a valid SFDC session already.
Thanks.
Bryan
I'm working on an integration for my company and have a question regarding logging in and persisting the Binding object.
My main objective is to not have to login each time a call needs to be made to the Apex API. I'd like to have an initial login to get the session information, and then have the session info and the binding information persist. I'm creating a class library that will house the connectors and a generic wrapper, but have run into a problem with the binding object.
I have a class that handles and session management with a public sub called Login():
Code:
Public Sub Login()What you see there is that the login is done and then a public property is set to hold the information. I then have a data object class for the API calls that will use this Binding property in lieu of having to login each to to get and set the object. so I'm thinking about something like:
Try
' login to salesforce.com to establish a session
_SforceLR = _binding.login(UserName, Password)
'Reset the SOAP endpoint to the returned server URL
_binding.Url = _SforceLR.serverUrl
_binding.SessionHeaderValue = New sforce.SessionHeader
_binding.SessionHeaderValue.sessionId = _SforceLR.sessionId
Binding = _binding
' write a new values for the session mgmt to the config file
ConfigSettings.WriteSetting("SessionID", _SforceLR.sessionId)
ConfigSettings.WriteSetting("SessionURL", _SforceLR.serverUrl)
ConfigSettings.WriteSetting("SessionLoginTime", GetTimeStamp.timestamp.ToString)
Catch ex As Exception
MsgBox(ex.Message.ToString)
End Try
End Sub
Code:
Dim ret() As sforce.sObjectWhat I'm running into is an Internal 500 Server error from the API when trying to do the retrieve. I think this is due to the public property not persisting across the classes and the property code being declared as:
' ret = _binding.retrieve(cField, cTable, New String() {cID})
ret = Binding.retrieve("LastName", "Contact", New String() {"0035000000MtAPH"})
If Not ret Is Nothing Then
' Return something
Else
' Return Nothing
End If
Code:
Public Property Binding() As SforceServiceCompressed Get Return _binding End Get Set(ByVal value As SforceServiceCompressed) _binding = value End Set End PropertyAny help at all would be great. Since this is a .NET class library I don't have access to things like the Session and all of that, so I'm not sur how to pass the Binding object around. For the session info I'm writing the strings out to an application config file to keep populated and updateable.
I'm really stuck and am looking for a jump start. It could just be that the property route is just bad, and I can live with that, but I'm not sure how to handle not having to login each time a call is made when there is a valid SFDC session already.
Thanks.
Bryan
I hade the same problem and the way I did it,
If you want to keep the logging session only in one page, declare the SforceService Object (binding object) global. I don’t know that’s a good idea when considering security of your application.
If you want to keep the logging session across multiple .net pages, write the session ID and URL in to .net Session variables or local cookies. And each time when a page loads check the session variable is empty. If it’s empty redirect them to the logging page.
I can pass you the C# code for both of these techniques.
If you get around with a better idea post if here please.
My problem was that I'm not creating a .NET site to be able to have a session and save items. I'm creating a DLL that will be used by other apps here to connect and do various methods via the salesforce.com API.
What I did (for the time being) was to create an app.config file in the solution that contains the sessionID, URL, and the login time. in my logic I do a "session check" or sorts using those values, by reading then writing to the file if a new session is created. All of this is done in a class created only for session management.
For the SforceService object (I call it the binding object), I created a shared public property in the management class. This allows my data layer to share that object all the time.
I am curious to take a look at your code though. Since this is my first dive into integration with salesforce, the more information I can get the better.
Thanks!
Bryan