IIS下的多个端点

时间:2009-07-25 18:43:01

标签: c# .net wcf iis endpoints

我一直在尝试在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.svchttp://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错误URI上的MSDN文档:http://localhost:1523/Service1.svc/test元数据包含无法解析的引用:“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:错误请求。

2 个答案:

答案 0 :(得分:2)

实际上是:

http://localhost/wcfcert/service1.svc/test

如果您希望网址为“http://localhost/wcfcert/test/service1.svc”,则需要在地址属性中指定完整的网址。

答案 1 :(得分:0)

我最近遇到了类似的问题,我相信原因是因为WcfTestClient需要mex端点来查询它正在测试的服务的元数据。

当您将服务地址"http://localhost:1523/Service1.svc"添加到WcfTestClient时,它实际上会查询端点"http://localhost:1523/Service1.svc/mex"以获取服务描述。

显示错误“无法从"http://localhost:1523/Service1.svc/test"获取元数据”,因为WcfTestClient正在寻找“/ test / mex”端点以在“/ test”获取服务的元数据。

要解决此问题,您需要添加另一个端点以提供有关在地址“/ test”中托管的服务的元数据:

<endpoint address="/test/mex" binding="mexHttpBinding" contract="IMetadataExchange"/>

这是对我有用的解决方案。

相关问题