我正在开发使用传输安全设置的WCF服务。当测试客户端代理,并调用服务的方法,我得到以下EndpointNotFoundException
:EndpointNotFoundException - 404 - 在IIS中通过HTTPS托管WCF服务通过Visual Studio
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>
我使用这个虚拟目录中的项目,以本地IIS的网络属性页部署:
https://MyPC:443/AMTA.WebService/
点击F5后,我可以浏览https://MyPC:443/AMTA.WebService/BroadcastInfoService.svc
,它显示带有w sdl信息。虽然当我尝试致电客户端代理方法,端点未发现异常被抛出与以下日志细节
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和HTTP主机头的IIS和启用HTTPS是依赖于自签名证书。
主机和客户端之间是否打开443?主机和客户端在同一个盒子上吗?试试这个:https:[no space] //127.0.0.1:443/AMTA.WebService/BroadcastInfoService.svc – Brian
是的,一切都在同一台机器上。 – Cortlendt
因此,请尝试本地主机或127.0.0.1,看看你是否得到不同的结果。 – Brian