function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
GrantMGrantM 

Connection and Sandbox advice

Hi

1) Connection Advice

I want some advice on the best method to create a salesforce binding.
Both from a username and password, and from a given session.

I would also like to make a connection pool where by i have a set of sf bindings, and for each concurrent thread use one of these connections.

If i can be pointed to an article on this or given some sample code that would be great

2) Sandbox

Now that salesforce have released the sandbox, i would like to take advantage of this in my dev environment.
Now, the way i use the sandbox, is i download the WSDL from test.salesforce.com, and reference this in my project.
To make this live, i download the wsdl from www.salesforce.com and reference this in my project.

Ideally, i would like a setting in my web.config that specifies which instance we are using so i can swap much faster.
how can i achieve this?


Any help on these matters would be greatly appreciate

Regards

Grant Merwitz
DevAngelDevAngel
Hi GrantM,

For number 2, the key item is the endpoing url. You can definitely put this in your web config, and then read it when the app starts or whenever you need to perform a login. If you are using the enterprise wsdl, you need to make sure your test and prod schemas match exactly. Prior to the login call you can set the url of the binding object to point to test or prod.

For number 1, I must question as to why you want a connection pool? We only allow 2 or 3 concurrent connections anyway. You could create a connection "stack" with new instances of you binding objects and then pop as you need a binding and push when you are done with it. You will still have to worry about session becoming stale.

For creating a binding you simply use new SalesforceService binding = SalesforceService(). If you are creating the connection from a session id and url then you would set the session header next. binding.SessionHeaderValue = new SessionHeaderValue() and set the session id, binding.SessionHeaderValue.sessionId = sid then set the binding url, binding.url = newUrl.

If the connection is from a username and passord you just call the login method and then setup the session id and url as shown above.

If you are using .NET 2.0 you should consider the async capabilities in web services.
SimplySfdcSimplySfdc
Hi, I am trying Sandbox login using SessionID, but I get error as below:
 
INVALID_SESSION_ID: Invalid Session ID found in SessionHeader. The Session ID may only be from the IP address it originated from because the organization has enabled this security setting.
 
But, If I use manual login to sandbox,
loginRes = binding.login("username@domainname.com","password") , it is working fine.
 
And using the same code of login using SessionID, it is working fine for standard API (not sandbox).
 
So, is the sandbox not support for login using SessionID and URL?
 
regards,
sq
SuperfellSuperfell
Yes its supported, however your sandbox org has the "Lock session to originating IP" which means that sessionId can only be used by the IP address that was using during login. So if you're sending the sessionId via a merge field to an external server, it'll have a different IP, and therefore fail this check. You'll need to disable the setting in your sandbox org's configuration for this to work.