web-services - HTTP 请求未经客户端身份验证方案“基本”授权。从服务器收到的身份验证标头为“基本领域 =”
问题描述
我正在尝试访问需要身份验证的 Soap Web 服务 (HTTP)。我正在使用 WCF 来使用该服务。我收到错误消息,因为 HTTP 请求未经客户端身份验证方案“基本”授权。从服务器收到的身份验证标头是“Basic realm="weblogic"”。
任何帮助表示赞赏,谢谢。
这就是我的代码的样子:
var binding = new BasicHttpBinding();
binding.MaxBufferSize = 2147483647;
binding.MaxReceivedMessageSize = 2147483647;
binding.Security = new BasicHttpSecurity
{
Mode = BasicHttpSecurityMode.TransportCredentialOnly,
Transport = new HttpTransportSecurity()
{
ClientCredentialType = HttpClientCredentialType.Basic
}
};
var endpoint = new System.ServiceModel.EndpointAddress(configuration["webserviceAddres"]);
servicio = new ConsultaMontosOperadosFondosClient(binding, endpoint);
servicio.ClientCredentials.UserName.Password = MyPass;
servicio.ClientCredentials.UserName.UserName = MyUser;
解决方案
如果服务不是通过 https,那么尝试添加领域:(我不确定它是否是 weblogic,只是按照您在错误中发布的内容)
binding.Security = new BasicHttpSecurity
{
Mode = BasicHttpSecurityMode.TransportCredentialOnly,
Transport = new HttpTransportSecurity()
{
ClientCredentialType = HttpClientCredentialType.Basic,
Realm = "weblogic"
}
};
推荐阅读
- vba - 我的代码在单元格(i,1)上运行良好,但在单元格(i,2)上出现类型不匹配错误。衷心欢迎您的建议
- angular-material - Angular Material 组件不会在通用应用程序中呈现
- visual-studio - 使用 cmake 构建的可执行文件找不到共享库
- react-native - 如何使用 react-native-fs 访问 ios NoCloud/ 目录?它在文档中没有提到
- r - 如何在 ggplot 的图中订购子图?
- python - 面临python中的问题
- java - Java 中 Mono 的条件响应式执行
- java - 向上或向下滚动列表视图的问题
- mysql - 如何使用 mysql.exe 在 windows 命令行中执行多行 sql 语句?
- python - 为什么 colab 会抛出此错误,但不会在 kaggle 中抛出此错误,ValueError: Failed to find data adapter that can handle input