2013-12-09 9 views
1

GetSessionId 메서드를 호출하기 위해 eBay API를 사용하고 있지만 ASP.NET MVC4 응용 프로그램에서 SessionID이라는 빈 메서드를 반환하는 메서드를 사용하고 있습니다.eBay API GetSessionID 메소드가 세션 ID를 반환하지 않습니다.

누구든지 나를 도와 줄 수 있습니까?

다음 코드 단편을 사용 중입니다.

string signinURL = "https://api.sandbox.ebay.com/wsapi"; 
     string callname = "GetSessionID"; 
     string appID = ConfigurationManager.AppSettings["ebay_AppId"]; 
     string version = "768"; 
     string eBayToken = ConfigurationManager.AppSettings["testToken"]; 
     string endpoint = signinURL + "?callname=" + callname + 
          "&appid=" + appID + 
          "&version=" + version + 
          "&routing=default"; 



     eBayAPIInterfaceClient service = new eBayAPIInterfaceClient("eBayAPI", endpoint); 
     GetSessionIDRequest req = new GetSessionIDRequest(); 
     req.RequesterCredentials = new CustomSecurityHeaderType(); 

     req.RequesterCredentials.Credentials = new UserIdPasswordType(); 
     req.RequesterCredentials.Credentials.AppId = AppConstants.AppId; 
     req.RequesterCredentials.Credentials.DevId = AppConstants.DevId; 
     req.RequesterCredentials.Credentials.AuthCert = AppConstants.CertId; 
     req.RequesterCredentials.eBayAuthToken = AppConstants.ebayToken; 
     GetSessionIDRequestType reqType = new GetSessionIDRequestType(); 
     reqType.RuName = AppConstants.RuName; 
     reqType.Version = version; 
     GetSessionIDResponseType res = service.GetSessionID(ref req.RequesterCredentials, reqType); 
     if (res.Ack == AckCodeType.Success) 
     { 
      string ebaySignInUrl = "https://signin.ebay.com/ws/eBayISAPI.dll?SignIn&RuName=" + AppConstants.RuName 
             + "&SessionID=" + res.SessionID; 
      Response.Redirect(ebaySignInUrl); 
     } 

답변

0

마지막으로 문제는 eBay API에 있습니다. SessionID 필드를 채우지 않습니다. API의 버그 일 수 있습니다. retured 값은 응답 개체의 XmlElement Array 필드에서 찾을 수 있습니다. 그래서 여기에 SessionID가 표시됩니다.

if (response.Any.Length >= 1) 
     { 
     var SessionId=response.Any.First().InnerText; 
     }