我正在使用 .NetCore6 并拥有 System.ServiceModel 的 6.0 Nuget 包,这是这个开源代码:https://github.com/dotnet/wcf
我正在尝试从 .net Framework 4.6 项目复制客户端绑定。有人能告诉我是否支持这些绑定吗?
<system.serviceModel>
<bindings>
<wsFederationHttpBinding>
<binding name="wsFederationHttpBindingConfiguration" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:11:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="6553600" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="1638400" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
<security mode="TransportWithMessageCredential">
<message algorithmSuite="Default" issuedKeyType="SymmetricKey" issuedTokenType="http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1" negotiateServiceCredential="true">
<issuer address="...SecurityTokenService.svc" binding="wsHttpBinding" bindingConfiguration="wsHttpBindingConfiguration">
<headers>
<ServiceContractType xmlns="http://schemas.test/Contracts">ServiceContracts.ISecurityTokenService</ServiceContractType>
</headers>
</issuer>
<issuerMetadata address="...SecurityTokenService.svc/mex" />
</message>
</security>
</binding>
</wsFederationHttpBinding>
<wsHttpBinding>
<binding name="wsHttpBindingConfiguration" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:11:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="6553600" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" negotiateServiceCredential="true" algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="...location.svc" binding="wsFederationHttpBinding" bindingConfiguration="wsFederationHttpBindingConfiguration" contract="ILocationService" name="LocationServiceEndpoint" />
<endpoint address="...admin.svc" binding="wsFederationHttpBinding" bindingConfiguration="wsFederationHttpBindingConfiguration" contract="ServiceRef.IAdminService" name="AdminEndpoint">
<headers>
<ServiceContractType xmlns="http://schemas.test.Contracts">AdminService.Contracts.IAdminService</ServiceContractType>
</headers>
</endpoint>
</client>
</system.serviceModel>
希望有人在我深入了解之前知道这是否受支持
据我所知,Core 中已经支持 WSHttpBinding 和 WSFederationHttpBinding。 此项目包括创建绑定的示例。
另外.NET Framework WCF和.NET Core WCF场景的区别在于后者的绑定只能在代码中配置,不能在app.config中配置。
您可以参考以下文章详细讲解这些应用场景:
CoreWCF 1.0 已发布,WCF for .NET Core 和 .NET 5+
.NET 标准中的 WSFederationHttpBinding
希望有帮助。