• SF Sandhya
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies

Hi,

 

I am getting below exception while getting the opportunity objects from my account.

"UNKNOWN_EXCEPTION: Destination URL not reset. The URL returned from login must be set in the SforceService"

 

While login  i am setting the one url and once its done i am setting one more URL.

 

Before login

//if debug_mode use the following service urlif(isSalesForceDebugModeEnabled)

binding.Url =

"https://cs3-api.salesforce.com/services/Soap/c/22.0/00DQ0000000HABh";

 

After login

 

binding.Url = loginResult.serverUrl;

 

This is my login function.

privatestaticbool SalesForceLogin(SforceServicebinding)

{

LoginResult loginResult = null;

 

GetUserInfoResult userInfo = null;

 

// Time out after a minute

binding.Timeout = 60000;

// Try to log in the usertry

{

string username = username@uname.com;

 

string password = "password";

loginResult = binding.login(username, password);

}

catch (System.Web.Services.Protocols.SoapException)

{

// This is likley to be caused by bad username or password//AppError.AddError("SalesForce Login [Soap Exception]: " + e.Message, AppError.AudienceEnum.TechnicalTeam, AppError.LevelEnum.Exception);returnfalse;

}

catch (Exception)

{

// This is something else, probably comminication//AppError.AddError("SalesForce Login [Other Error]: " + e.Message, AppError.AudienceEnum.TechnicalTeam, AppError.LevelEnum.Exception);returnfalse;

}

//Create a new session header object and set the session id to that returned by the login

binding.SessionHeaderValue =

newSessionHeader();

binding.SessionHeaderValue.sessionId = loginResult.sessionId;

userInfo = loginResult.userInfo;

//Change the binding to the new endpoint

binding.Url = loginResult.serverUrl;

returntrue;

}

 

While getting the opportunities it is raising the exception

 

publicvoidQueryOpportunity()

{

QueryResult qr = null;

binding.QueryOptionsValue =

newQueryOptions();

binding.QueryOptionsValue.batchSize = 250;

binding.QueryOptionsValue.batchSizeSpecified =

true;

 

DescribeSObjectResult result = binding.describeSObject("Opportunity");

 

boolcanCreate = result.createable;

 

foreach(Field f inresult.fields)

{

lstProductInfo.Items.Add(f.name);

}

qr = binding.query(

"select Name,Web_Order_Number__c,CloseDate,StageName,Tax_Amount__cSpecified,Promo_Code_Discount_Amount__cSpecified from Opportunity");

 

// qr = binding.query("select ID, Name, ProductCode, Description from Product2");

 

 

grdProducts.DataSource = qr.records;

grdProducts.DataBind(); 

 

}

 In describeresult object i am getting exception.What is the problem i could nt able to understand,

Note:I am new bie of salesforce.I dont know anything abt SF.Why they are setting 2 urls,who will give those urls,Is there any proper document .I have searched in net but full high teminology.I could nt able to understand.

Please provide me answer for above prob and Doc for SF

 

-Sandhya