EndpointNotFoundException - 404 - 通过Visual Studio在IIS中通过HTTPS托管WCF服务

时间:2014-01-17 13:46:44

标签: c# asp.net wcf web-services iis

我正在使用传输安全设置开发WCF服务。在测试客户端代理和调用服务方法时,我得到了EndpointNotFoundException

  

https://MyPC/AMTA.WebService/BroadcastInfoService.svc没有可以接受该消息的端点。这通常是由错误的地址或SOAP操作引起的。有关更多详细信息,请参阅InnerException(如果存在)。

     

内部例外:
  远程服务器返回错误:(404)Not Found。

我通过visual studio托管我的服务。

web.config服务:

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

为客户配置:

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

我正在使用此虚拟目录将项目的Web属性页面部署到本地IIS:

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

我可以在点击F5后浏览https://MyPC:443/AMTA.WebService/BroadcastInfoService.svc,显示带有wsdl信息的页面。虽然当我尝试在客户端代理上调用方法时,会抛出端点未找到异常以及以下日志详细信息

  

System.ServiceModel.EndpointNotFoundException,System.ServiceModel,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089
  服务'/AMTA.WebService/BroadcastInfoService.svc/'不存在。
  堆栈跟踪
  在System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath,EventTraceActivity eventTraceActivity)
  在System.ServiceModel.ServiceHostingEnvironment.EnsureServiceAvailableFast(String relativeVirtualPath,EventTraceActivity eventTraceActivity)

为IIS启用了Https和Http主机头,Https与自签名证书相关联。

1 个答案:

答案 0 :(得分:5)

罪魁祸首缺失

  

bindingConfiguration = “TransportSecurity”

来自web.config中的端点元素。

顺便说一句,只需使用basicHttpsBinding即可满足安全性要求,这是.Net 4.5的新功能。这将导致更简洁的xml配置。无论如何,这都来自魔鬼。