You need to sign in to do that
Don't have an account?

C# Sample Code does not work.
Ok, trying to integrate with the WSDL from a C# web app in VS2005. After fixing some simple mistakes in the example code such as "qr.recrods" etc, I'm still having issues. In the login method there is this line:
sfdc.GetUserInfoResult userInfo = lr.userInfo;The closest I see in intellisense is getUserInfo but that does not work. Is there anotehr example that works? I apologize but I'm completely new to SalesForce and just trying to estimate a project to integrate some simple web forms on a client site to automatically push the data to their salesforce database. I've worked with WebServices before just not this API.
However, GetUserInfoResult is not a member of that object.
// Create a new session header object
// Add the session ID returned from the login
sfdc.SessionHeaderValue = new SalesForce.SessionHeader();
sfdc.SessionHeaderValue.sessionId = lr.sessionId;
sfdc.GetUserInfoResult userInfo = lr.userInfo;
The error is only on the last line. If I comment it out like:
// Create a new session header object
// Add the session ID returned from the login
sfdc.SessionHeaderValue = new SalesForce.SessionHeader();
sfdc.SessionHeaderValue.sessionId = lr.sessionId;
//sfdc.GetUserInfoResult userInfo = lr.userInfo;
It compiles fine.
And if I type sfdc. in VS2005, "GetUserInfoResult" is not a choice.
Sample code is here:
http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_quickstart_samplecode.htm#topic-title_csharp
private SforceService binding = new SforceService();
And then use binding through the project instead of the SforceService 'sfdc' that you create inside the login call, but I was working with a webapp, not a console app like the samples.
private SforceService binding = new SforceService();
protected void Page_Load(object sender, EventArgs e)
{
if (login())
{
doWhatever();
}
}
private bool login()
{
LoginResult lr = binding.login("name", "pass"); if (!lr.passwordExpired) { binding.Url = lr.serverUrl; binding.SessionHeaderValue = new SessionHeader(); binding.SessionHeaderValue.sessionId = lr.sessionId; GetUserInfoResult userInfo = lr.userInfo; return true; } else { Response.Write("Your password is expired."); return false; }
}
I think its syntax error. I found this in the API Doc too. You should change the code little bit then it will work. :smileywink:
Code:
Zitizon X