gpt4 book ai didi

c# - IIS 下的多个端点

转载 作者:行者123 更新时间:2023-11-30 12:37:23 24 4
gpt4 key购买 nike

我一直在尝试在 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我明白了

Error: Cannot obtain Metadata from http://localhost:1523/Service1.svc/test If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address. For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata Exchange Error URI: http://localhost:1523/Service1.svc/test Metadata contains a reference that cannot be resolved: 'http://localhost:1523/Service1.svc/test'. Sendera:BadContextTokenThe message could not be processed. This is most likely because the action 'http://schemas.xmlsoap.org/ws/2004/09/transfer/Get' is incorrect or because the message contains an invalid or expired security context token or because there is a mismatch between bindings. The security context token would be invalid if the service aborted the channel due to inactivity. To prevent the service from aborting idle sessions prematurely increase the Receive timeout on the service endpoint's binding.HTTP GET Error URI: http://localhost:1523/Service1.svc/test There was an error downloading 'http://localhost:1523/Service1.svc/test'. The request failed with HTTP status 400: Bad Request.

最佳答案

实际上是:

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

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

关于c# - IIS 下的多个端点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1182725/

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