【发布时间】:2019-12-12 10:24:47
【问题描述】:
当我尝试从我的 asp.net core 2.2 控制器中的 BC365 soap 服务检索数据时,我收到以下错误:
HTTP 请求未经客户端身份验证方案授权 '匿名的'。从服务器收到的身份验证标头是 '谈判'。
有趣的是: 如果我在本地调试项目,它可以使用以下代码按预期工作:
var binding = new BasicHttpBinding(BasicHttpSecurityMode.None);
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
binding.MaxBufferSize = int.MaxValue;
binding.MaxReceivedMessageSize = int.MaxValue;
var endpointAddress = new System.ServiceModel.EndpointAddress(this.soapBaseUrl + "Page/WEB_Item");
var itemPortClient = new WEB_Item_PortClient(binding, endpointAddress);
itemPortClient.ClientCredentials.UserName.UserName = this.soapUserName;
itemPortClient.ClientCredentials.UserName.Password = this.soapPassword;
return itemPortClient;
但每当我在 IIS 上发布它时,它都无法按预期工作(我已经在远程和本地机器上尝试过)。 我已按照 https://stackify.com/how-to-deploy-asp-net-core-to-iis/ 上的说明部署我的 asp.net 核心应用程序。
我的基础设施项目 .csproj 文件的内容如下所示:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.ServiceModel.Duplex" Version="4.5.3"/>
<PackageReference Include="System.ServiceModel.Http" Version="4.5.3" />
<PackageReference Include="System.ServiceModel.NetTcp" Version="4.5.3"/>
<PackageReference Include="System.ServiceModel.Security" Version="4.5.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BakWebshop.Core\BakWebshop.Core.csproj" />
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Connected Services" />
</ItemGroup>
</Project>
如果有人知道可能有什么问题或我可以检查什么,我现在有点卡在这里。非常感谢任何帮助。
【问题讨论】:
标签: c# soap asp.net-core-2.2