SalesForce Web Service By WSDL - Invalid Login SOAP Error
I am trying to connect to the SalesForce web service and return some data in a web page. I am new to this WSDL stuff. So first I created a very simple console application. I just wanted to see if I could connect to the web service. That worked fine. I was able to see our tables and return data.
So next I used the EXCELLENT sample code at http://www.developer.com/net/net/salesforce-integration-with-.net-web-services-soap-api-.html. Changed my web.config settings to mine, etc. However, I keep getting the below SOAP error.
Thrown: "INVALID_LOGIN: Invalid username, password, security token; or user locked out." (System.Web.Services.Protocols.SoapException) Exception Message = "INVALID_LOGIN: Invalid username, password, security token; or user locked out.", Exception Type = "System.Web.Services.Protocols.SoapException"
The debugging data shows that the correct login credentials are being sent. They are the same credentials that the console app passed successfully.
Any help would be very very very appreciated!!!! or if anyone has another code example I am开发者_JS百科 open to that as well...
When logging in through the API (i.e. not through the web app), there are some additional security measures in place.
You need to either:
- connect from an a trusted IP address (trusted on your user's profile (see profile detail page) or generally in the org ("Security controls --> Network Access")
or
- append your security token to your password (reset it from "My Personal Information --> Reset Security Token")
If you are using the new API (e.g. 26.0) then the login method requires a LoginScopeHeader
parameter. When calling the soap proxy generated by Visual Studio you need to make the call to login()
passing null as the parameter for the LoginScopeHeader
:
SoapClient client = new SoapClient();
string username = "user@salesforce.com";
string password = "password";
string securityToken = "xxxxxxxxxxxxxxxxxxxxxxxxx";
LoginResult loginResult = client.login(null, username, password + securityToken);
Of course you need to make sure that you have the API enabled
setting (in the profile)
精彩评论