コード例 #1
0
            public string Login(string username, string password)
            {
                var callApiForLogin = featureManager.IsEnabledAsync("CallAPIForLogin").Result;

                if (!callApiForLogin)
                {
                    var wsUrl            = options.Value.AuthWebServiceURL;
                    var webServiceClient = new AuthWebServiceSoapClient();
                    webServiceClient.Endpoint.Address = new EndpointAddress(wsUrl);
                    var response = webServiceClient.Login(username, password);
                    return($"WebService response from BCL : {response}");
                }
                else
                {
                    var wapiUrl     = options.Value.AuthApiURL;
                    var httpClient  = new HttpClient();
                    var requestBody = System.Text.Json.JsonSerializer.Serialize(new
                    {
                        username = username,
                        password = password
                    });
                    var stringContent = new StringContent(requestBody, encoding: System.Text.Encoding.UTF8, mediaType: "application/json");
                    var httpResponse  = httpClient.PostAsync($"{wapiUrl}/Login", stringContent).Result;
                    var response      = httpResponse.Content.ReadAsStringAsync().Result;
                    return($"WebAPI response from BCL : {response}");
                }
            }
コード例 #2
0
ファイル: LoginService.cs プロジェクト: mkokabi/AuthService
        public async Task <string> LoginUsingWebService(string username, string pasword)
        {
            var webServiceClient = new AuthWebServiceSoapClient(EndpointConfiguration.AuthWebServiceSoap12, options.Value.AuthWebServiceURL);
            var response         = await webServiceClient.LoginAsync(username, pasword);

            return($"WebService response: {response}");
        }
コード例 #3
0
            private int CallWebServiceForCreateUser(string username, string password)
            {
                var wsUrl            = options.Value.AuthWebServiceURL;
                var webServiceClient = new AuthWebServiceSoapClient();

                webServiceClient.Endpoint.Address = new EndpointAddress(wsUrl);
                var response = webServiceClient.CreateUser(username, password);

                return(response);
            }
コード例 #4
0
 public AuthWebServiceSoapClient(EndpointConfiguration endpointConfiguration, System.ServiceModel.EndpointAddress remoteAddress) :
     base(AuthWebServiceSoapClient.GetBindingForEndpoint(endpointConfiguration), remoteAddress)
 {
     this.Endpoint.Name = endpointConfiguration.ToString();
     ConfigureEndpoint(this.Endpoint, this.ClientCredentials);
 }
コード例 #5
0
 public AuthWebServiceSoapClient(EndpointConfiguration endpointConfiguration) :
     base(AuthWebServiceSoapClient.GetBindingForEndpoint(endpointConfiguration), AuthWebServiceSoapClient.GetEndpointAddress(endpointConfiguration))
 {
     this.Endpoint.Name = endpointConfiguration.ToString();
     ConfigureEndpoint(this.Endpoint, this.ClientCredentials);
 }