有人可以分享一下是否可以在.NET Core中编写以下配置吗?是否有任何明显的障碍以及是否有任何解决方法。
我使用了与
System.ServiceModel
6.0.0 包中可以找到的配置标签等效的代码。目前,我遇到了 PlatformNotSupported
异常。
<bindings>
<customBinding>
<binding name="WifNetTcpServiceBinding">
<transactionFlow transactionProtocol="WSAtomicTransaction11" />
<security defaultAlgorithmSuite="Default" authenticationMode="SecureConversation" requireDerivedKeys="false">
<secureConversationBootstrap defaultAlgorithmSuite="Default" authenticationMode="IssuedTokenOverTransport" requireDerivedKeys="false" >
<issuedTokenParameters >
<additionalRequestParameters>
<trust:SecondaryParameters xmlns:trust="">
<trust:TokenType xmlns:trust="">http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1</trust:TokenType>
<trust:KeyType xmlns:trust="http://docs.oasis-open.org/ws-sx/ws-trust/200512">http://docs.oasis-open.org/ws-sx/ws-trust/200512/SymmetricKey</trust:KeyType>
</trust:SecondaryParameters>
<apm:RequireUniqueDomainName xmlns:apm="">false</apm:RequireUniqueDomainName>
<apm:EpCode xmlns:apm="">APM</apm:EpCode>
</additionalRequestParameters>
<issuer address="" binding="ws2007HttpBinding" bindingConfiguration="SecurityTokenServiceBinding">
<identity>
<certificate encodedValue="AwAAAAEAAAAU" />
<dns value="abp-app3.abp.local" />
<userPrincipalName value="[email protected]" />
</identity>
</issuer>
<issuerMetadata address="https://abp-app3.abp.local:8035/apm/core" />
</issuedTokenParameters>
<localClientSettings detectReplays="false" />
<localServiceSettings detectReplays="false" />
</secureConversationBootstrap>
</security>
</binding>
</customBinding>
<ws2007HttpBinding>
<binding name="SecurityTokenServiceBinding">
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="None" />
<message establishSecurityContext="false" />
</security>
</binding>
</ws2007HttpBinding>
</bindings>
尝试使用
ServiceModel
nuget 包中的方法进行试验和错误。
我拥有的配置 C# 代码的要点
var issuedTokenParams = new System.ServiceModel.Security.Tokens.IssuedSecurityTokenParameters();
var securityBootstrapElement = System.ServiceModel.Channels.SecurityBindingElement
.CreateIssuedTokenOverTransportBindingElement(issuedTokenParams);
var securityBindingElement = System.ServiceModel.Channels.SecurityBindingElement.CreateSecureConversationBindingElement(securityBootstrapElement);
// Custom Binding
System.ServiceModel.Channels.CustomBinding result = new System.ServiceModel.Channels.CustomBinding();
result.Elements.Add(securityBindingElement);
result.Elements.Add(new System.ServiceModel.Channels.BinaryMessageEncodingBindingElement());
result.Elements.Add(new System.ServiceModel.Channels.SslStreamSecurityBindingElement());
// TCP transport
System.ServiceModel.Channels.TcpTransportBindingElement tcpTransport = new System.ServiceModel.Channels.TcpTransportBindingElement
{
TransferMode = System.ServiceModel.TransferMode.Streamed,
MaxBufferPoolSize = 2147483647,
MaxReceivedMessageSize = 2147483647,
ConnectionBufferSize = 32768,
MaxBufferSize = 2147483647
};
result.Elements.Add(tcpTransport);
如果您的 WCF 客户端 是引用 WCF 服务 的客户端。您所需要做的就是在 ASP.NET Core 中创建一个新项目并引用 WCF。它会自动生成 Reference.cs 文件。
我认为您指的是WCF 服务。您应该在将 WCF 服务升级到 ASP.NET Core时遇到问题。
由于 ASP.NET Core 不支持ServiceModel,ServiceModel的很多功能无法在ASP.NET Core上实现。近年来推出了CoreWCF,可以帮助你在ASP.NET Core上编写WCF服务。但并非所有功能都已转移。我查看了 Corewcf 中的 costumbinding 方法,你的一些配置没有显示在他的方法中。所以我认为你不应该只升级代码,而是查看 Corewcf 的源代码,尝试更接近你的期望。