You need to sign in to do that
Don't have an account?
dke01
Switch Web service between Live and Sandbox
How do you switch your .net app between connecting to Produciton and Sandbox web services?
I have code working on my Developer orgI now want to move to my Sandbox.
I generated the WSDL on my developer org, and just copied the Apex classes to my sandbox and have not regenerated the WSDL for it.
private const string _url = "https://test.salesforce.com/services/Soap/u/10.0";
protected void Button1_Click(object sender, EventArgs e)
{
if (!isConnected())
{
getSessionInfo();
}
MyService ws = new MyService();
ws.Url = Application["_serverUrl"].ToString();
ws.Proxy = getProxy();
ws.SessionHeaderValue = new SessionHeader();
ws.SessionHeaderValue.sessionId = Application["_sessionId"].ToString();
string foo= ws.HelloWolrd("bar");
}
public WebProxy getProxy()
{
System.Net.WebProxy proxy = System.Net.WebProxy.GetDefaultProxy();
proxy.Credentials = CredentialCache.DefaultCredentials;
return proxy;
}
public bool isConnected()
{
bool functionReturnValue = false;
if (Application["_sessionId"] != null )
{
if (DateTime.Now < (DateTime)(Application["_nextLoginTime"]) )
{
return true;
}
}
return false;
}
public void getSessionInfo()
{
SforceService ss = new SforceService();
ss.Proxy = getProxy();
ss.Url = _url;
LoginResult lr = ss.login(_userId, _password);
if (!lr.passwordExpired)
{
Application["SforceService"] = ss;
Application["_sessionId"] = lr.sessionId;
Application["_serverUrl"] = lr.serverUrl;
Application["_nextLoginTime"] = DateTime.Now.AddMinutes(_sessionTime);
}
}
this code works fine on my developer edition, but I cannot get it working on my sandbox.
The value for
serverUrl = "https://tapp0-api.salesforce.com/services/Soap/u/10.0/00DT0000000Gg4C"
The error I get is:
No operation available for request {http://soap.sforce.com/schemas/class/MyService}HelloWolrd
In the auto-generated cs file that was created from the WSDL, add a contructor that can get a URL.
For example, when I use the Enterprise WSDL, the c'tor looks like that
public SforceService()
{
this.Url = "https://www.salesforce.com/...";
}
You need to edit the file and add another c'tor
public SforceService(string url)
{
this.Url = url;
}
This is common not only when using SalesForce.com but when using other web services as well
All Answers
I got it working by looking at the WSDL on the sandbox and saw that the end point URL is
<soap:address location = https://tapp0-api.salesforce.com/services/Soap/class/MyLogging
So I just change the MyService end point URL dynamically to this and it works.
In the auto-generated cs file that was created from the WSDL, add a contructor that can get a URL.
For example, when I use the Enterprise WSDL, the c'tor looks like that
public SforceService()
{
this.Url = "https://www.salesforce.com/...";
}
You need to edit the file and add another c'tor
public SforceService(string url)
{
this.Url = url;
}
This is common not only when using SalesForce.com but when using other web services as well