通过尝试从 soap 服务检索数据而未授权 HTTP 请求
HTTP request is unauthorized by trying to retrieve data from a soap service
当我尝试从我的 asp.net 核心 2.2 控制器中的 BC365 soap 服务检索数据时,出现以下错误:
The HTTP request is unauthorized with client authentication scheme
'Anonymous'. The authentication header received from the server was
'Negotiate'.
有趣的是:
如果我在本地调试项目,它会按预期使用以下代码:
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>
如果有人知道可能有什么问题或我可以检查什么,我现在有点被困在这里了。非常感谢任何帮助。
问题与用于启动 soap 请求的不同用户有关,使用 2.2 .net 核心。该请求是使用手动定义的凭据发出的,但不知何故,框架在触发请求时并未考虑这些凭据。
运行 从 VS2019 开始,本地用户被使用并能够连接(在 soap 端点上被允许)。
运行 在具有使用应用程序池标识的应用程序池的 IIS 上无法正常工作,因为不知何故没有使用 soap 请求的指定用户凭据,而是 ApplicationPoolIdentity - 未被授予对 soap 的访问权限端点。
解决方法是为 iis 池使用用户定义的帐户。
看起来与 and
相关
当我尝试从我的 asp.net 核心 2.2 控制器中的 BC365 soap 服务检索数据时,出现以下错误:
The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'Negotiate'.
有趣的是: 如果我在本地调试项目,它会按预期使用以下代码:
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>
如果有人知道可能有什么问题或我可以检查什么,我现在有点被困在这里了。非常感谢任何帮助。
问题与用于启动 soap 请求的不同用户有关,使用 2.2 .net 核心。该请求是使用手动定义的凭据发出的,但不知何故,框架在触发请求时并未考虑这些凭据。
运行 从 VS2019 开始,本地用户被使用并能够连接(在 soap 端点上被允许)。
运行 在具有使用应用程序池标识的应用程序池的 IIS 上无法正常工作,因为不知何故没有使用 soap 请求的指定用户凭据,而是 ApplicationPoolIdentity - 未被授予对 soap 的访问权限端点。
解决方法是为 iis 池使用用户定义的帐户。 看起来与 and
相关