gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 21:36:47 24 4
gpt4 key购买 nike

我正在使用传输安全设置开发 WCF 服务。当测试客户端代理并调用服务方法时,我得到以下 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.

我通过 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
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 主机 header ,并且 Https 与自签名证书绑定(bind)。

最佳答案

凶手失踪

bindingConfiguration="TransportSecurity"

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

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

关于c# - EndpointNotFoundException - 404 - 通过 Visual Studio 在 IIS 中通过 HTTPS 托管 WCF 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21187550/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com