簡體   English   中英

在 .Net Core 3.1 中使用 WCF 服務

[英]Using WCF Service in .Net Core 3.1

我正在將 .Net framework 4 中的 Web API 轉換為 .NET Core 3.1,並且在 API 中我正在使用供應商 WCF 服務。 WCF 服務使用相互證書身份驗證和basicHttpBinding 和customBinding。 我可以通過 wsdl 在項目的“連接服務”中添加代理類。 但是我正在努力轉換 appsettings.json 中舊 web.config 中的配置部分,以及如何在 startup.cs 中使用它。 在舊 Web.config 的 <syste.ServiceModel> 配置部分下方(來自 .Net Framework 4 中的 Web API)

<system.serviceModel>
    <services />
    <behaviors>
        <endpointBehaviors>
            <behavior name="hz.behavior.rdy">
                <clientCredentials>
                    <clientCertificate findValue="TestWCF" storeLocation="LocalMachine" storeName="Root" x509FindType="FindBySubjectName" />
                    <serviceCertificate>
                        <defaultCertificate findValue="de607fe9qwrqwrtqtqetqetq74bf292ebe87c0dbbe3716" storeLocation="LocalMachine" storeName="Root" x509FindType="FindByThumbprint" />
                    </serviceCertificate>
                </clientCredentials>
            </behavior>
        </endpointBehaviors>
        <serviceBehaviors />
    </behaviors>
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding_IDebitCard" closeTimeout="00:05:00" openTimeout="00:05:00" receiveTimeout="00:10:00" sendTimeout="00:05:00" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
                <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
                <security mode="None">
                    <transport clientCredentialType="None" proxyCredentialType="None" />
                    <message clientCredentialType="UserName" algorithmSuite="Default" />
                </security>
            </binding>
            <binding name="BasicHttpBinding_IAuthentication" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <security mode="None">
                    <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
                    <message clientCredentialType="UserName" algorithmSuite="Default" />
                </security>
            </binding>
        </basicHttpBinding>
        <wsHttpBinding>
            <binding name="wsHttpEndpoint" closeTimeout="00:05:00" openTimeout="00:05:00" receiveTimeout="00:10:00" sendTimeout="00:05:00" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" >
                <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
                <security mode="TransportWithMessageCredential">
                    <transport clientCredentialType="None" />
                    <message clientCredentialType="UserName" establishSecurityContext="false" />
                </security>
            </binding>
        </wsHttpBinding>
        <customBinding>
            <binding name="BalanceInquiryServiceSoapBinding" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00">
                <textMessageEncoding messageVersion="Soap12" />
                <security defaultAlgorithmSuite="Basic128Rsa15" allowSerializedSigningTokenOnReply="true" authenticationMode="MutualCertificate" securityHeaderLayout="Lax" allowInsecureTransport="false" messageProtectionOrder="SignBeforeEncrypt" messageSecurityVersion="WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10" requireSecurityContextCancellation="false" />
                <httpsTransport />
            </binding>
            <binding name="CardStatusChangeServiceSoapBinding" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00">
                <textMessageEncoding messageVersion="Soap12" />
                <security defaultAlgorithmSuite="Basic128Rsa15" allowSerializedSigningTokenOnReply="true" authenticationMode="MutualCertificate" securityHeaderLayout="Lax" allowInsecureTransport="false" messageProtectionOrder="SignBeforeEncrypt" messageSecurityVersion="WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10" requireSecurityContextCancellation="false" />
                <httpsTransport />
            </binding>
            <binding name="CardNumberInquiryServiceSoapBinding" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00">
                <textMessageEncoding messageVersion="Soap12" />
                <security defaultAlgorithmSuite="Basic128Rsa15" allowSerializedSigningTokenOnReply="true" authenticationMode="MutualCertificate" securityHeaderLayout="Lax" allowInsecureTransport="false" messageProtectionOrder="SignBeforeEncrypt" messageSecurityVersion="WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10" requireSecurityContextCancellation="false" />
                <httpsTransport />
            </binding>
            <binding name="PinInquiryServiceSoapBinding" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00">
                <textMessageEncoding messageVersion="Soap12" />
                <security defaultAlgorithmSuite="Basic128Rsa15" allowSerializedSigningTokenOnReply="true" authenticationMode="MutualCertificate" securityHeaderLayout="Lax" allowInsecureTransport="false" messageProtectionOrder="SignBeforeEncrypt" messageSecurityVersion="WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10" requireSecurityContextCancellation="false" />
                <httpsTransport />
            </binding>
            <binding name="LoadUnloadPurseServiceSoapBinding" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00">
                <textMessageEncoding messageVersion="Soap12" />
                <security defaultAlgorithmSuite="Basic128Rsa15" allowSerializedSigningTokenOnReply="true" authenticationMode="MutualCertificate" securityHeaderLayout="Lax" allowInsecureTransport="false" messageProtectionOrder="SignBeforeEncrypt" messageSecurityVersion="WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10" requireSecurityContextCancellation="false" />
                <httpsTransport />
            </binding>
            <binding name="TransactionHistoryServiceSoapBinding" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00">
                <textMessageEncoding messageVersion="Soap12" />
                <security defaultAlgorithmSuite="Basic128Rsa15" allowSerializedSigningTokenOnReply="true" authenticationMode="MutualCertificate" securityHeaderLayout="Lax" allowInsecureTransport="false" messageProtectionOrder="SignBeforeEncrypt" messageSecurityVersion="WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10" requireSecurityContextCancellation="false" />
                <httpsTransport maxReceivedMessageSize="2147483647" />
            </binding>
            <binding name="CustomerInfoUpdateServiceSoapBinding" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00">
                <textMessageEncoding messageVersion="Soap12" />
                <security defaultAlgorithmSuite="Basic128Rsa15" allowSerializedSigningTokenOnReply="true" authenticationMode="MutualCertificate" securityHeaderLayout="Lax" allowInsecureTransport="false" messageProtectionOrder="SignBeforeEncrypt" messageSecurityVersion="WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10" requireSecurityContextCancellation="false" />
                <httpsTransport maxReceivedMessageSize="2147483647" />
            </binding>
        </customBinding>
    </bindings>
    <client>
        <endpoint address="" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IAuthentication" contract="AuthWS.IAuthentication" name="AuthWs.IAuthentication" />
        <endpoint address="https://services.debitcardprovider.com/hzwbsvc/services/BalanceInquiryServicePort" binding="customBinding" bindingConfiguration="BalanceInquiryServiceSoapBinding" contract="BalanceInquiryService.BalanceInquiryService" name="BalanceInquiryServicePort" behaviorConfiguration="hz.behavior.rdy" />
        <endpoint address="https://services.debitcardprovider.com/hzwbsvc/services/CardStatusChangeServicePort" binding="customBinding" bindingConfiguration="CardStatusChangeServiceSoapBinding" contract="CardStatusChangeService.CardStatusChangeService" name="CardStatusChangeServicePort" behaviorConfiguration="hz.behavior.rdy" />
        <endpoint address="https://services.debitcardprovider.com/hzwbsvc/services/CardNumberInquiryServicePort" binding="customBinding" bindingConfiguration="CardNumberInquiryServiceSoapBinding" contract="CardNumberInquiryService.CardNumberInquiryService" name="CardNumberInquiryServicePort" behaviorConfiguration="hz.behavior.rdy" />
        <endpoint address="https://services.debitcardprovider.com/hzwbsvc/services/PinInquiryServicePort" binding="customBinding" bindingConfiguration="PinInquiryServiceSoapBinding" contract="PinInquiryService.PinInquiryService" name="PinInquiryServicePort" behaviorConfiguration="hz.behavior.rdy" />
        <endpoint address="https://services.debitcardprovider.com/hzwbsvc/services/LoadUnloadPurseServicePort" binding="customBinding" bindingConfiguration="LoadUnloadPurseServiceSoapBinding" contract="LoadUnloadPurseService.LoadUnloadPurseService" name="LoadUnloadPurseServicePort" behaviorConfiguration="hz.behavior.rdy" />
        <endpoint address="https://services.debitcardprovider.com/hzwbsvc/services/TransactionHistoryServicePort" binding="customBinding" bindingConfiguration="TransactionHistoryServiceSoapBinding" contract="TransactionHistoryService.TransactionHistoryService" name="TransactionHistoryServicePort" behaviorConfiguration="hz.behavior.rdy" />
        <endpoint address="https://services.debitcardprovider.com/hzwbsvc/services/CustomerInfoUpdateServicePort" binding="customBinding" bindingConfiguration="CustomerInfoUpdateServiceSoapBinding" contract="CustomerInfoUpdateService.CustomerInfoUpdateService" name="CustomerInfoUpdateServicePort" behaviorConfiguration="hz.behavior.rdy" />
    </client>
</system.serviceModel>

如果我理解正確的話,你的問題就是這樣。 NET Framework 4 轉換為 . NET Core 3.1 更改哪個配置。

下面的鏈接可以回答你的問題。

https://www.outsystems.com/blog/posts/migrating-from-net-framework-to-net-core/

謝謝。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM