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
Software EngineSoftware Engine 

Changing the Binding URL

Hi,
 
I have an application which should be test both in Production and QA Environment.
 
Can we change the binding URL to sand box  URL to production URL
 and production URL  to sandbox URL.
 
 
// Create service object
    SforceService sfdc = new SforceService(); 

    LoginResult lr = sfdc.login("username","password"); 

    sfdc.Url = lr.serverUrl; 
   
   sfdc.Url=SandBox URL. // Can we change like this.
 
Would it really point to the specified URL?
 
 
 
Thanks,
 
 
 
 
 
 
SuperfellSuperfell
To use sandbox, you need to send the login request to a different endpoint (test.salesforce.com vs www.salesforce.com), once you make this change, everything else "should just work"
Software EngineSoftware Engine
Thanks for yr reply.
 
LoginId and Password are same for  test.sandbox and www.salesforce.com.
But after login to salesforce can i switch to sandbox or salesforce.com.
 
SandBoxURL    = " https://test.sandbox.com "
SalesForceURL= "  www.salesforce.com "
 
m_loginRes = m_binding.login(UID, PWD)
m_binding.Url =  SandBoxURL / SalesForceURL
m_binding.SessionHeaderValue = New Sforce.SessionHeader
m_binding.SessionHeaderValue.sessionId = m_loginRes.sessionId
 
Is there any problem with Session Header and SessionID by switching to sandbox and salesforce.com?
 
 
 
 
 
SuperfellSuperfell
You need to make the login call to the right place, you need to switch the URL's BEFORE you call login, not afterwards.
Software EngineSoftware Engine
If i need to change the URL's before login, then i should have to create two login methods.
And also i have to configure Sand Box WSDL to sandbox login part and salesforce WSDL to salesforce login code part. Then its just like having two setups.
 
I want to create only one login, but after login i should be able to switch either to sandbox or salesforce.com.
 
Thanks,
 
 
 
 
 
SuperfellSuperfell
When your test instance copy is initially setup, yes you'll have the same username & password in both, but they are 2 separate records, and once the copy is over, one can change, while the other one doesn't. So they really are 2 different sets of credentials that just happen to start with the same values.

If you want to make API requests to your test instance version, then you need to send the login request to the test.salesforce.com endpoint, not to www.salesforce.com