+ Start a Discussion
saariko.ax241saariko.ax241 

Wroking in Production and Development mode - how to do it

Our application uses the regular SF. During development we work our application with the sandbox, we use the webreference accordingly.

 

The big Q is:

Is there a way to work with one application, but to be able to login to either sandbox or production instances?

Best Answer chosen by Admin (Salesforce Developers) 
SuperfellSuperfell
If you're using the partner API (or you're using the enterprise API, and your schema is stable), then you can download the WSDL once, and just change the client stub Url property before calling login, login's to sandbox should goto test.salesforce.com, while regular production login's goto www.salesforce.com (with the rest of the path as it appears in the WSDL), there's a note about this in the API docs.

All Answers

SuperfellSuperfell
If you're using the partner API (or you're using the enterprise API, and your schema is stable), then you can download the WSDL once, and just change the client stub Url property before calling login, login's to sandbox should goto test.salesforce.com, while regular production login's goto www.salesforce.com (with the rest of the path as it appears in the WSDL), there's a note about this in the API docs.
This was selected as the best answer
chentwchentw

Hi Simon,

I am using Enterprise WSDL. Changing the URL doesn't work for me. Do you what else I have to change? Or is it even possible to do that? Thanks.

saariko.ax241saariko.ax241

Thanks Simon.

 

For the ones who will get to this q again, here is a code example.

 

Please remember that your prod and sandbox passwords aren't necessarily the same

 

protected void Button1_Click(object sender, EventArgs e) { Partner.SforceService binding = new SforceService(); if (CheckBox1.Checked) { // If true than production binding.Url = binding.Url.Replace("test", "www"); } else { // If not true than sandbox binding.Url = binding.Url.Replace("www", "test"); } LoginResult lr = binding.login(txtUsername.Text, txtPassword.Text); }