我一直在尝试在 IIS 下托管的服务中添加一个新端点,但在过去一天左右一直无法弄清楚。
这是我的理解:
- 只要它们具有唯一的地址,您就可以在 IIS 下拥有多个端点。
- 您可以分配一个基地址,但它将被 IIS 中的虚拟目录设置覆盖。
我的虚拟目录是http://localhost/WcfCert/
<services>
<service name="WcfCertServer.Service1" behaviorConfiguration="WcfCertServer.Service1Behavior">
<endpoint address="" binding="wsHttpBinding" contract="WcfCertServer.IService1"/>
<endpoint address="test" binding="wsHttpBinding" contract="WcfCertServer.IService1"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
我可以使用http://localhost/wcfcert/service1.svc启动服务
但http://localhost/wcfcert/test/service1.svc/test在 IE 或客户端应用程序中没有返回任何内容
我在这里想念什么?
编辑:
所以我做了进一步的测试,这就是我发现的。
如果我启动 WcfTestClient.exe 并添加http://localhost:1523/Service1.svc或http://localhost:1523/Service1.svc/mex它将在该地址下添加两个端点。所以这是我的问题不应该http://localhost:1523/Service1.svc只代表第一个端点吗?为什么添加该地址会同时显示两个端点?
但如果我尝试添加http://localhost:1523/Service1.svc/test我得到
错误:无法从http://localhost:1523/Service1.svc/test获取元数据如果这是您有权访问的 Windows (R) Communication Foundation 服务,请检查您是否已在指定地址启用元数据发布。有关启用元数据发布的帮助,请参阅位于http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata Exchange Error URI: http://localhost:1523/Service1.svc/test的 MSDN 文档的 MSDN 文档 元数据包含无法解析的引用:“ http://localhost:1523/Service1.svc/test ”。
Sendera:BadContextToken
无法处理该消息。这很可能是因为操作' http://schemas.xmlsoap.org/ws/2004/09/transfer/Get' 不正确,或者因为消息包含无效或过期的安全上下文令牌,或者因为绑定之间不匹配。如果服务由于不活动而中止通道,则安全上下文令牌将无效。为防止服务过早中止空闲会话,请增加服务端点绑定的接收超时。HTTP GET 错误 URI:http://localhost:1523/Service1.svc/test 下载时出错“ http://localhost:1523 ” /Service1.svc/test '。请求失败,HTTP 状态为 400:错误请求。