IIS 8 - WCF 中的 EndpointNotFoundException

IIS 8 - EndpointNotFoundException in WCF

我在调用 C# Web 应用程序中托管的 WCF 时遇到问题。

我试过在服务器托管在本地时调用网络服务,并且没有任何问题。

但是,当服务器托管在 IIS 8 时,我收到错误 "There was no endpoint listening at https://cloud.my/MyService/GenerateWCF1.svc"。

注意: 当它托管在 IIS 8 时,我可以通过直接插入 link 来浏览它。

客户端代码隐藏

ERPGenerateWCF1.GenerateWCF1Client GenerateWCF1 = new ERPGenerateWCF1.GenerateWCF1Client();        GenerateGST03.ClientCredentials.Windows.AllowedImpersonationLevel =                                 System.Security.Principal.TokenImpersonationLevel.Impersonation;
var address = new EndpointAddress("https://cloud.my/MySystem/GenerateWCF1.svc");
GenerateWCF1 = new ERPGenerateWCF1.GenerateWCF1Client("BasicHttpBinding_IGenerateWCF1", address);
ErrorMsg = GenerateWCF1.DoWork();

客户Web.Config

<system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IGenerateWCF1" receiveTimeout="00:45:00"
          sendTimeout="00:45:00" maxReceivedMessageSize="600000000">
          <security mode="Transport">
            <transport clientCredentialType="Ntlm" proxyCredentialType="None"
              realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
        <binding name="BasicHttpBinding_IGenerateWCF2" />
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost:56498/MySystem/GenerateWCF1.svc"
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IGenerateWCF1"
        contract="ERPGenerateWCF1.IGenerateWCF1" name="BasicHttpBinding_IGenerateWCF1" />
      <endpoint address="http://localhost:55777/MySystem/GenerateWCF2.svc"
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IGenerateWCF2"
        contract="GenerateWCF2.IGenerateWCF2" name="BasicHttpBinding_IGenerateWCF2" />
      <endpoint address="mex"
                binding="mexHttpsBinding"
                contract="IMetadataExchange" />
    </client>
  </system.serviceModel>

服务器网络配置

 <system.serviceModel>
  <behaviors>
   <serviceBehaviors>
    <behavior>
     <serviceMetadata httpGetEnabled="true" />
     <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
   </serviceBehaviors>
  </behaviors>
  <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
  <bindings>
   <basicHttpBinding>
     <binding name="BasicHttpBinding_IGenerateWCF1" receiveTimeout="00:45:00"
  sendTimeout="00:45:00" maxReceivedMessageSize="600000000">
       <security mode="Transport">
         <transport clientCredentialType="Ntlm" proxyCredentialType="None"
           realm="" />
         <message clientCredentialType="UserName" algorithmSuite="Default" />
       </security>
     </binding>
     <binding name="BasicHttpBinding_IGenerateWCF2" />
   </basicHttpBinding>
  </bindings>
 </system.serviceModel>

问题已解决。

通过以下步骤解决:

  1. 将安全模式更改为 "TransportCredentialOnly" 而不是 "Transport"
  2. 地址设置为 http 而不是 https
  3. 设置或绕过 SSL 凭据。
  4. 将您的 URL 从名称更改为 IP 地址(例如:https://myurltest.com/WCFName.svc to http://192.1.1.1/WCFName.svc

已编辑:重要的步骤 4 我上次忘记添加了。