我正在尝试从 .NET Core 调用肥皂网络服务。
我使用构建了代理dotnet-svcutil,发现它与同一端点的旧版 .NET 4.6 实现有很大不同。
.NET Core 代理没有继承自System.Web.Services.Protocols.SoapHttpClientProtocol. 我知道这个命名空间在 .NET Core 中已经消失了,但是什么取代了它呢?
我有一个运行良好的WSDL服务(并且仍在.net 4.x中运行),并且是.NET Core 2.0的新手。
我创建了WSDL Web服务参考(与https://docs.microsoft.com/en-us/dotnet/core/additional-tools/wcf-web-service-reference-guide相同的步骤)
我的问题是如何使用这项服务?有人知道好的教程吗?任何帮助将不胜感激。
先感谢您
我正在尝试使用来自 ASP.NET Core 库项目的 SOAP Web 服务。
我已经安装了 Mictosoft WCF Web 服务参考提供程序,它为我创建了代理类,但我遇到了身份验证问题。
我的代码目前看起来像这样:
var binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportWithMessageCredential);
var address = new EndpointAddress(@"https://myserviceaddress.asmx");
var client = new TestApiClient(binding, address);
client.ClientCredentials.UserName.UserName = "testusername";
client.ClientCredentials.UserName.Password = "testpassword";
var result = await client.GetDataAsync(params);
Run Code Online (Sandbox Code Playgroud)
我尝试了一些不同的方法,但我要么得到了未经授权,要么得到了以下内容的变体:The value 'TransportWithMessageCredential' is not supported in this context for the binding security property 'securityMode'..
我想我也应该在 上设置一些属性binding.Security.Message,但存在的唯一属性binding.Security是Transport和Mode。
有人知道如何正确设置吗?
从 ASP.NET Core 使用 SOAP 服务还有其他更好的方法吗?我喜欢一种不必创建代理类的动态方式,但是如果必须的话,我可以使用代理,但是我需要能够使用用户和密码进行身份验证,而且我必须使用 https。