2016-08-26 2 views
0

C# 콘솔 응용 프로그램을 thridparty SOAP WSDL API로 연결하려고하지만 작동하지 못합니다. 나는 비주얼 스튜디오의 서비스 의지로 WSDL 문자열을 사용하여 서비스에 연결 : https://domain.tld/SimpleAPI/SimpleAPIService.svc?singleWsdlVisual Studio에서 SOAP WSDL에 연결 C#

문서는 말한다 : 인증 기반 세션입니다. 요청자는 각 요청의 인증 필드에 유효한 세션 토큰을 제공해야합니다. 세션은 주어진 사용자와 동일한 자원 및 기능에 대한 액세스 권한을가집니다. 세션 토큰을 얻으려면 GetSessionToken 메서드를 사용하십시오. 세션의 유효성을 검사하려면 PingPong 메서드를 사용하십시오. 설명서는 나를위한 옵션이 아닌 REST API에 중점을 둡니다. 다음과 같이 연결하기위한 두 가지 방법은 다음과 같습니다이 이런 식으로 뭔가를 반환해야

curl \ -H "Content-Type: application/json" \ -X POST -d '{ "username": "[email protected]", "password": "VerySecure123" }' \ https://domain.tld/SimpleAPI/SimpleAPIService.svc/rest/GetSessionToken 

: C9C5MlqrpMwG/6bQ3mAVlm0Z6hi/eh1vsQs4i1I/g == 이 부분은, 난 다시 토큰을 얻을 괜찮습니다. 그러나 PingPong 메서드를 시도 할 때 잘못된 토큰 또는 세션이 만료되었다는 오류가 발생합니다.

static void Main(string[] args) 
     { 
      string apiUsername = "user"; 
      string apiPassword = "pass"; 

      using (var client = new acmp.SimpleAPIServiceClient()) 
      { 
       client.ClientCredentials.UserName.UserName = apiUsername; 
       client.ClientCredentials.UserName.Password = apiPassword; 

       string token = client.GetSessionToken(apiUsername, apiPassword); 
       string tokenText = string.Format("CCPSessionId {0}", token); 

       using (OperationContextScope contextScope = new OperationContextScope(client.InnerChannel)) 
       { 
        var httpRequestProperty = new HttpRequestMessageProperty(); 

        httpRequestProperty.Headers[HttpRequestHeader.Authorization] = token; //tokenText 

        OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = httpRequestProperty; 

        client.PingPong(); 
       } 
      } 

      Console.WriteLine("End..."); 
      Console.ReadLine(); 
     } 

지금이 이론은 내 스크립트가 올바른 헤더를 전달되지 않는 것입니다 다음과 같이

curl \ -H "Content-Type: application/json" \ -H "Authenticate:CCPSessionId C9C5MlqrpMwG/6bQ3mAVlm0Z6hi/eh1vsQs4i1I/g==" \ -X POST -d '{}' \ https://domain.tld/SimpleAPI/SimpleAPIService.svc/rest/PingPong 

내 코드입니다.

디버깅에 많은 시간을 할애 해주세요.

답변

0

약간의 독서가 있었으며 어디서나 "CCPSessionsid"토큰 텍스트를 찾을 수 없습니다. 내가 "베어러"를 참조

, token.AccessToken의 라인을 따라

= 새로운 AuthenticationHeaderValue

client.DefaultRequestHeaders.Authorization ("베어러", token.AccessToken);

+0

잘 모르겠습니까? –

관련 문제