我有一个wsdl与基本的身份验证保护,当我试图与 Postman 或通过浏览器其工作。
为了在我的代码中使用它,我已经通过visual code 2022连接了服务,并创建了代理类。
然后我用下面的代码来使用它的方法
BasicHttpBinding binding = new BasicHttpBinding
{
SendTimeout = TimeSpan.FromSeconds(500),
MaxBufferSize = int.MaxValue,
MaxReceivedMessageSize = int.MaxValue,
AllowCookies = true,
ReaderQuotas = XmlDictionaryReaderQuotas.Max
};
binding.Security.Mode = BasicHttpSecurityMode.Transport;
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
EndpointAddress address = new EndpointAddress("https://test/test/.wsdl");
ChannelFactory<TEST_Channel> factory = new ChannelFactory<TEST_Channel>(binding, address);
factory.Credentials.UserName.UserName = "abcd";
factory.Credentials.UserName.Password = "1234";
var f = factory.CreateChannel();
f.someMethod(param);
字符串
但是在调用someMethod()时出现以下错误
System.ServiceModel.Security.MessageSecurityException : The HTTP request is unauthorized with client authentication scheme 'Basic'. The authentication header received from the server was 'Digest realm="SOAP-Server", nonce="aasdasdasd1231313", algorithm="MD5", qop="auth"'.
型
如果你能帮忙的话
1条答案
按热度按时间w8f9ii691#
以下是我的解决方案[链接][1]
字符串