简体   繁体   中英

IIS 8 - EndpointNotFoundException in WCF

I'm facing an issue in calling a WCF hosted in c# web application.

I have tried calling the webservice when the server is hosted at local and it worked without any issue.

However, I got the error "There was no endpoint listening at https://cloud.my/MyService/GenerateWCF1.svc " when the server is hosted at IIS 8.

Note : I can browse it by directly inserting the link when it is hosted at IIS 8.

Client Code Behind

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();

Client 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>

Server Web Config

 <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>

Issue solved.

Solved by following steps:

  1. Change securitymode to "TransportCredentialOnly" instead of "Transport"
  2. Address set to http instead of https
  3. Set or Bypass SSL credential.
  4. Change your URL from name to IP address (Eg.: https://myurltest.com/WCFName.svc to http://192.1.1.1/WCFName.svc )

Edited : Important step 4 I forgot to add in last time.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM