从C#代码附加证书后,SOAP调用中的身份验证失败

时间:2020-01-10 07:08:10

标签: soap

我们能够从SOAP UI中找到一个端点并获得正确的响应。但是,当我们尝试使用我们的代码库(使用代理引用)访问同一终结点时,会收到“身份验证失败”消息。根据我们的理解,我们能够将证书与代理调用一起发送。我们已经尝试了大部分Google搜索结果,但还是没有运气。如果您有任何建议,请告诉我们。

下面是我们正在尝试的代码。

        using (RegistrationDelegateClient proxy = new RegistrationDelegateClient("ServiceRealtimeIntegration"))
        {
            // checkUserNameAvailableType userNameAvailableRequest = new checkUserNameAvailableType();
            //if (String.IsNullOrWhiteSpace(memberInfo.EmailId))
            //{
            //   // memberInfo.EmailId = "BCRIPRIMARYCONSUMER_test@mailinator.com"; // "BCRIPRIMARYCONSUMER@mailinator.com";
            //}
            // var cert = Helper.GetActiveCertificateFromStore("af36eb8b385e8abee67f2382703b5737e5c125c7");

             ((BasicHttpBinding)proxy.Endpoint.Binding).Security.Mode = BasicHttpSecurityMode.Transport;
             ((BasicHttpBinding)proxy.Endpoint.Binding).Security.Transport.ClientCredentialType = HttpClientCredentialType.Certificate;

            proxy.ClientCredentials.ClientCertificate.Certificate = cert;

            //proxy.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = System.ServiceModel.Security.X509CertificateValidationMode.PeerOrChainTrust;
            //userNameAvailableRequest.userName = memberInfo.EmailId;
            // scope.Log("Calling RegisterUser.");
            try
            {

                // proxy.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None;
                //response = proxy.registerUser(userNameAvailableRequest);
                string brandField = "test";
string subbrandField = "tets";
userData[] userDataObj = new userData[10];
userDataObj[0] = new userData() { attributeName = "dob", attributeValue = "10102010" };
userDataObj[1] = new userData() { attributeName = "fname", attributeValue = "John" };
userDataObj[2] = new userData() { attributeName = "lname", attributeValue = "test" };
userDataObj[3] = new userData() { attributeName = "email", attributeValue = "test@gmail.com" };
userDataObj[4] = new userData() { attributeName = "contract", attributeValue = "12345678" };
userDataObj[5] = new userData() { attributeName = "hmfim", attributeValue = "test@test.com" };
userDataObj[5] = new userData() { attributeName = "eob", attributeValue = "0" };

registrationData regObj = new registrationData() { brand = brandField, subbrand = subbrandField, userData = userDataObj };
response = proxy.registerUser(regObj);

                //responseStatus = ResponseStatus.Ok;
                //scope.Log("RegisterUser execution complete.");
            }
            catch (FaultException fex)
            {
                //scope.Log(String.Format("RegisterUser call has been failed. Error: {0}, StackTrace: {1}.", fex.Message, fex.StackTrace), eventType: System.Diagnostics.TraceEventType.Critical);
                throw;
            }
            catch (Exception ex)
            {
                //scope.Log(String.Format("RegisterUser call has been failed. Error: {0}, StackTrace: {1}.", ex.Message, ex.StackTrace), eventType: System.Diagnostics.TraceEventType.Critical);
                throw;
            }

        }

关于, 阿尼克特(Aniket)

0 个答案:

没有答案