2013-07-26 1 views
0

나는이 튜토리얼 그러나 http://wiki.developerforce.com/page/Integrating_Force.com_with_Microsoft_.NET

다음하고 C#으로 세일즈 포스에 연결할 수 없음,이 오류가 점점 오전 :

static void Main(string[] args) 
     { 
      string userName; 
      string password; 
      userName = "[email protected]"; 
      password = "myPassword"; 

      SforceService SfdcBinding = null; 
      LoginResult CurrentLoginResult = null; 
      SfdcBinding = new SforceService(); 
      try 
      { 
       CurrentLoginResult = SfdcBinding.login(userName, password); 
      } 
      catch (System.Web.Services.Protocols.SoapException e) 
      { 
       // This is likley to be caused by bad username or password 
       SfdcBinding = null; 
       throw (e); 
      } 
      catch (Exception e) 
      { 
       // This is something else, probably comminication 
       SfdcBinding = null; 
       throw (e); 
      } 

     } 
: 이것은 내 콘솔 응용 프로그램에서 내 코드

LOGIN_MUST_USE_SECURITY_TOKEN: Invalid username, password, security token; or user locked out. Are you at a new location? When accessing Salesforce--either via a desktop client or the API--from outside of your company’s trusted networks, you must add a security token to your password to log in. To receive a new security token, log in to salesforce.com at http://login.salesforce.com and click Setup | My Personal Information | Reset Security Token.

입니다

보안 토큰이 필요하다는 오류가 있지만 문서에 언급 된 내용이없는 것 같아서 얻는 방법을 모르겠습니다.

+1

죄송합니다. 나는 동일한 튜토리얼을 따라 가고있다. 지시에 따라 wsdl xml 파일을 추가하고 서비스 참조를 추가했습니다. 다음 내 코드에서 위와 똑같이 있지만 BST.SFDC를 사용하여 추가했지만 줄 SforceService SfdcBinding = null; "유형 또는 네임 스페이스 이름 'SforceService'를 찾을 수 없습니다 (사용 지시문 또는 어셈블리 참조가 누락 되었습니까?)" –

+0

@TrevorDaniel '[WhateverNameYouGaveYourWSDLFile];'문을 사용해야한다고 생각합니다. . 내일 사무실에 올 때 다시 확인해 드릴 수 있습니다. 그러나 나는 상당히 확신한다. 그것이 당신을 위해 작동하는지 알려주세요. – user1477388

+0

IM이 잘못된 wsdl 파일을 사용했는지 궁금합니다. 엔터프라이즈 하나를 사용하고 있습니까? 어느 것을 사용 했습니까? –

답변

6

() 여기로 이동 :

https://na15.salesforce.com/_ui/system/security/ResetApiTokenConfirm?retURL=%2Fui%2Fsetup%2FSetup%3Fsetupid%3DPersonalInfo&setupid=ResetApiToken

내 토큰을 재설정하십시오. 그런 다음 비밀번호 끝에 다음과 같이 덧붙입니다.

If your password = "mypassword"

And your security token = "XXXXXXXXXX"

You must enter "mypasswordXXXXXXXXXX" in place of your password

Ref. http://docs.servicerocket.com/pages/viewpage.action?pageId=83099770

2

이와 같은 SOAP API를 사용하면 사용자 이름과 비밀번호를 제공하여 서비스에 대한 인증을 먼저 받아야합니다. 응답은 일정 기간 동안 유효하게 될 인증 토큰을 리턴해야합니다. 이후의 통신에서이 토큰을 API에 전달하여 자신이 누구인지를 알 수 있습니다.

//Change the binding to the new endpoint 
SfdcBinding.Url = CurrentLoginResult.serverUrl; 

//Create a new session header object and set the session id to that returned by the login 
SfdcBinding.SessionHeaderValue = new SessionHeader(); 
SfdcBinding.SessionHeaderValue.sessionId = CurrentLoginResult.sessionId; 

쿼리를 수행 : 세션이

SforceService SfdcBinding = null; 
LoginResult CurrentLoginResult = null; 
SfdcBinding = new SforceService(); 
try 
{ 
    CurrentLoginResult = SfdcBinding.login(userName, password); 
} 
catch (System.Web.Services.Protocols.SoapException e) 
{ 
    // This is likely to be caused by bad username or password 
    SfdcBinding = null; 
    throw (e); 
} 
catch (Exception e) 
{ 
    // This is something else, probably communication 
    SfdcBinding = null; 
    throw (e); 
} 

설정 :

하면 인증 토큰을 얻기 문서에 없었다 내가해야 할 일을했을 무엇

QueryResult queryResult = null; 
String SOQL = "select FirstName, LastName, Phone from Lead where email = '[email protected]'"; 
queryResult = SfdcBinding.query(SOQL); 
+0

내 이해력을 높이 려 고 주셔서 감사하지만 어떻게 내가 뭘하고있는 것과 다른가요? 문제는'LOGIN_MUST_USE_SECURITY_TOKEN' 오류가 발생했습니다 – user1477388

+1

사용자 이름/암호가 맞습니까? SalesForce.com에는 사용자 이름/비밀번호의 정확성을 테스트 할 수있는 API 도구가 있습니까? – JeremiahDotNet

+0

도움 주셔서 감사합니다. 마침내 보안 토큰을 재설정하고 암호 뒤에 토큰을 추가하여 해결했습니다. 이것은 제가 읽고 있던 문서가 아닙니다. 그러나 thankfully 히 나는 그것을 이해했다. – user1477388