EndpointNotFoundException - 404 - 通过Visual Studio在IIS中通过HTTPS托管WCF服务 [英] EndpointNotFoundException - 404 - Hosting WCF Service over HTTPS in IIS through Visual Studio

查看:148
本文介绍了EndpointNotFoundException - 404 - 通过Visual Studio在IIS中通过HTTPS托管WCF服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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


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

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.

内部异常:

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

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

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

I'm hosting my service through 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:

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

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

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

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

服务'/AMTA.WebService/BroadcastInfoService.svc/'不存在。

StackTrace < br>
在System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath,EventTraceActivity eventTraceActivity)

at System.ServiceModel.ServiceHostingEnvironment.EnsureServiceAvailableFast(String relativeVirtualPath,EventTraceActivity eventTraceActivity)

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)

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

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

推荐答案

罪魁祸首缺失


bindingConfiguration =TransportSecurity

bindingConfiguration="TransportSecurity"

来自web.config中的endpoint元素。

from endpoint element in web.config.

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

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.

这篇关于EndpointNotFoundException - 404 - 通过Visual Studio在IIS中通过HTTPS托管WCF服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆