How to handle SalesForce WSDL files for sandbox and production sites in ASP.Net?

I need to authenticate users and get information about them from ASP.Net application. Since I have 2 sites (sandbox, production) and 2 organization IDs - I needed to create 2 SalesForce WSDL files.

I split 2 files (each about 600KB in size) and while they are 95% the same, there are enough differences scattered all over the place - enough for me to use both of them. I've added both links to web links to my solution and here's where my problem starts.

Obviously I cannot use both references in the same file as they contain the same classes / functions. Over the weekend I had to write a quick and dirty solution, so I just created 2 classes - each using a different web link, but otherwise the exact functionality, and I use the appropriate one, based on the URL the user comes from. This works well, but looks like a bad (read: quick and dirty) solution.

My question is, is there a way to do one or more of the following:

  • change web link on the fly?
  • use both web links in the same file, but put them in a different namespace?
  • find the best solution for the whole situation? I ran into a huge XmlSerializer.dll (3mb!) - possibly due to the use of huge WSDL files.

Thank you for your time.

+2


source to share


3 answers


In fact, the solution was much simpler and was hidden under my nose.
I just needed to use namespace aliases . This way I can enable both services at compile time and decide which to use at runtime:



using System.Web;
.
using ProductionAPI = MyCompany.SForce;
using SandboxAPI = MyCompany.SForce.Sandbox;
.
.
.
if(isSandbox)
  binding = new SandboxAPI.SForceService();
else
  binding = new ProductionAPI.SForceService();
.
.
.

      

+2


source


Maybe I'm missing something, but I'll try to answer:

1 I'm assuming you mean url? Yes, you can create a client object

var service = new Acmeco.AcmecoService();
service.Url = "oneUrlOrTheOther;   

      



2 What do you mean? When you add a link, you must give it a name that puts it in a unique namespace. As in the previous example, Acmeco.

3 It depends what in that 5% difference you mentioned? I'm not really clear on how you end up with a WSDL difference for the same web service on two different hosts. I would have thought that only the addresses would be different, but the methods and parameters would remain the same. Perhaps you can activate?

0


source


What are the differences between them? I suspect it's just that SalesForce.com is highly customizable so your sandboxes and production sites are not identical. The two should be identical if you are going to use the sandbox site's testing feature.

0


source







All Articles