簡體   English   中英

Net Core WCF 錯誤“發生一個或多個錯誤。(沒有端點偵聽”

[英]Net Core WCF error "One or more errors occurred. (There was no endpoint listening at"

我正在呼叫外部肥皂服務。 在開發中它工作正常,但在服務器上發布它會引發指示的錯誤。

“發生了一個或多個錯誤。(沒有端點偵聽https://myservice可以接受該消息。這通常是由不正確的地址或 SOAP 操作引起的。有關詳細信息,請參閱 InnerException(如果存在)。)”

如果我刷新頁面,錯誤會發生變化:

處理請求時發生未處理的異常。 AggregateException:發生一個或多個錯誤。 (對象是只讀的。) System.Threading.Tasks.Task.GetResultCore(bool waitCompletionNotification)

InvalidOperationException: 對象是只讀的。 System.ServiceModel.Security.X509CertificateRecipientClientCredential.ThrowIfImmutable()

這是代碼:

            PortTypeClient.ClientCredentials.ServiceCertificate.SslCertificateAuthentication= new X509ServiceCertificateAuthentication()
            {
                CertificateValidationMode = X509CertificateValidationMode.None,
                RevocationMode = X509RevocationMode.NoCheck
            };

根據錯誤消息"One or more errors occurred. (There was no endpoint listening at that https://myservice could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.)" ,您似乎沒有在服務的配置中定義綁定,因此您將獲得 wsHttpBinding 的默認值,而該綁定的 securityMode\\transport 的默認值是 Message。

您應該在應用程序目錄中打開“Web.config”並將以下配置代碼添加到文件中。 在運行時,WCF 基礎結構使用該信息來構建客戶端應用程序可以與之通信的端點。

配置:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <services>
      <service name="Microsoft.ServiceModel.Samples.CalculatorService">

        <!-- This endpoint is exposed at the base address provided by host: http://localhost/servicemodelsamples/service.svc -->
        <endpoint address=""
                  binding="wsHttpBinding"
                  contract="Microsoft.ServiceModel.Samples.ICalculator" />

        <!-- The mex endpoint is explosed at http://localhost/servicemodelsamples/service.svc/mex -->
        <endpoint address="mex"
                  binding="mexHttpBinding"
                  contract="IMetadataExchange" />
      </service>
    </services>
  </system.serviceModel>

</configuration>

有關如何在 IIS 上托管 wcf 應用程序的更多詳細信息,您可以參考這篇文章

暫無
暫無

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

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