How can I switch between "test" and "production" Salesforce Enterprise WSDL web reference classes?

150 Views Asked by At

I have created web references in my Visual Studio console project using WSDL files for Salesforce production and Salesforce sandbox.

I am trying to write the program like so:

ServiceClass client;
if(Debug)
{
     client = Test.SforceService;
}
else
{
     client = Prod.SforceService;
}

Problem is, the SforceService class is auto-generated, so I can't implement the ServiceClass in their files.

What are my options?

1

There are 1 best solutions below

0
eyescream On

When you inspect the WSDL at the end there should be something like this:

<service name="SforceService">
    <documentation>Sforce SOAP API</documentation>
    <port binding="tns:SoapBinding" name="Soap">
        <soap:address location="https://test.salesforce.com/services/Soap/u/48.0"/>
    </port>
</service>

My C# days are long gone but try to look for matching section in the generated class. If it's a String property you should be able to override the default value with login.salesforce.com (or other way around) in runtime?