EndpointNotFoundException - 404 - Hosting WCF Service over HTTPS in IIS through Visual Studio

19,054

The culprit was missing

bindingConfiguration="TransportSecurity"

from endpoint element in web.config.

By the way you can meet security requirements by just using basicHttpsBinding, which is new to .Net 4.5. This will lead to a more concise xml configs. Which are from the devil anyways.

Share:
19,054
Cortlendt
Author by

Cortlendt

Updated on July 18, 2022

Comments

  • Cortlendt
    Cortlendt almost 2 years

    I'm developing a WCF service using transport security settings. When testing client proxy and calling service method I get following EndpointNotFoundException:

    There was no endpoint listening at https://MyPC/AMTA.WebService/BroadcastInfoService.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.

    Inner exception:
    The remote server returned an error: (404) Not Found.

    I'm hosting my service through visual studio.

    web.config for service:

    <system.serviceModel>
      <services>
      <service name="AMTA.WebService.Broadcasts.BroadcastInfoService">
        <endpoint address="/BroadcastInfoService.svc" binding="wsHttpBinding" contract="AMTA.WebService.Interface.Broadcasts.IBroadcastInfoService"/>
        <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <bindings>
      <wsHttpBinding>
        <binding name="TransportSecurity">
          <security mode="Transport">
            <transport clientCredentialType="None"/>
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
      <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
      </system.serviceModel>
    

    Config for client:

        <system.serviceModel>
        <bindings>
            <wsHttpBinding>
              <binding name="WSHttpBinding_IBroadcastInfoService">
                <security mode="Transport">
                  <transport clientCredentialType="None"/>
                </security>
              </binding>
            </wsHttpBinding>
        </bindings>
        <client>
            <endpoint address="https://MyPC/AMTA.WebService/BroadcastInfoService.svc"
                binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IBroadcastInfoService"
                contract="BroadcastInfoService.IBroadcastInfoService" name="WSHttpBinding_IBroadcastInfoService">
            </endpoint>
        </client>
    </system.serviceModel>
    

    I'm deploying using Web property page of the project to local IIS using this virtual directory:

    https://MyPC:443/AMTA.WebService/
    

    I can browse https://MyPC:443/AMTA.WebService/BroadcastInfoService.svc after hitting F5, which shows page with wsdl info. Though when I try to call methods on client proxy, endpoint not found exception is being thrown with following log details

    System.ServiceModel.EndpointNotFoundException, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
    The service '/AMTA.WebService/BroadcastInfoService.svc/' does not exist.
    StackTrace
    at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath, EventTraceActivity eventTraceActivity)
    at System.ServiceModel.ServiceHostingEnvironment.EnsureServiceAvailableFast(String relativeVirtualPath, EventTraceActivity eventTraceActivity)

    Https and Http host headers are enabled for IIS and Https is tied to self-signed certificate.