WCF 서비스에 대한 호출을 구형 VB6 응용 프로그램에 구두를 신어야합니다. 이렇게하려면 wcf 메서드를 호출하는 C# DLL을 참조합니다. DLL에서 나는 설정 파일을 사용하는 것과 반대되는 설정을하고있다. 내 단위 테스트를 실행할 때 DLL은 작동하지만, 나는 VB6 응용 프로그램 내에서 실행하면, 나는 다음과 같은 오류가 발생합니다 : 서비스가 기본 인증을 사용WCF (401) DLL을 참조 할 때 무단으로
System.Net.WebException: The remote server returned an error: (401) Unauthorized. at System.Net.HttpWebRequest.GetResponse() at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest. WaitForReply(TimeSpan timeout) The HTTP request is unauthorized with client authentication scheme 'Basic'. The authentication header received from the server was 'Negotiate,NTLM,Basic realm=[the ip]
. 두 시나리오에서 동일한 URL, 사용자 이름 및 암호를 사용하고 있습니다. 다음은 코드에서 수행중인 구성입니다.
BasicHttpBinding binding = new BasicHttpBinding
{
SendTimeout = TimeSpan.FromMinutes(1),
OpenTimeout = TimeSpan.FromMinutes(1),
CloseTimeout = TimeSpan.FromMinutes(1),
ReceiveTimeout = TimeSpan.FromMinutes(10),
AllowCookies = false,
BypassProxyOnLocal = false,
HostNameComparisonMode = HostNameComparisonMode.StrongWildcard,
MessageEncoding = WSMessageEncoding.Mtom,
TextEncoding = System.Text.Encoding.UTF8,
TransferMode = TransferMode.Buffered,
UseDefaultWebProxy = true,
};
binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
var wcf = new [servicename](binding, new EndpointAddress([the url]));
if (wcf .ChannelFactory.Credentials != null)
{
wcf .ChannelFactory.Credentials.UserName.UserName = [the username];
wcf .ChannelFactory.Credentials.UserName.Password = [the pw];
}
VB6 응용 프로그램에서 실행될 때 어떤 점이 다른지 알 수 없습니다. 모든 입력을 부탁드립니다.
VB6 응용 프로그램은 어떤 자격 증명을 실행합니까? – Tim
Tim의 질문에 더 가깝습니다. VB6 앱이 서비스로 실행되고 있습니까? COM 구성 요소 또는 COM +/Component 서비스에서 실행 중입니까? 다른 응용 프로그램에서 시작 했습니까? – Zippit
서비스에서 추적 기능을 활성화하고 메시지 헤더의 추적 로그에서 유닛 테스트에서 호출 할 때 및 VB6 응용 프로그램에서 호출 할 때 전달되는 사용자 이름/암호를 확인하십시오. 401 오류가 발생하는 이유를 알려 주어야합니다. – Rajesh