gpt4 book ai didi

.net - 错误 "No protocol binding matches the given address ..."

转载 作者:行者123 更新时间:2023-12-03 16:29:50 27 4
gpt4 key购买 nike

我在IIS服务器中托管了2个WCF服务。

这是web.config

<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="HttpBinding" />
</basicHttpBinding>
</bindings>
<services>
<service name="BShop.Services.BubensService">
<endpoint address="http://localhost:9001/BubensService" binding="basicHttpBinding"
bindingConfiguration="HttpBinding" name="" contract="BShop.Services.IBubensService" />
</service>
<service name="BShop.Services.OrdersService">
<endpoint address="http://localhost:9001/OrdersService" binding="basicHttpBinding"
bindingConfiguration="HttpBinding" contract="BShop.Services.IOrdersService" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="false" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>

当我尝试运行它时,我得到了

No protocol binding matches the given address 'http://localhost:9001/BubensService'. Protocol bindings are configured at the Site level in IIS or WAS configuration.



我在配置中错过了什么?

最佳答案

当您在IIS中托管WCF服务时,在服务端点中定义的地址不是您需要使用的地址。

<endpoint 
// this is **NOT** the address you can use to call your service!
address="http://localhost:9001/BubensService"

而是由Web服务器,其端口(通常为80),虚拟目录以及SVC文件确定您的服务地址。因此,您的服务地址为:
http://YourServer/YourVirtualDirectory/YourServiceFile.svc/

您可以做的是定义相对地址,例如:
<service name="BShop.Services.BubensService">
<endpoint name=""
address="BubensService"
binding="basicHttpBinding" bindingConfiguration="HttpBinding"
contract="BShop.Services.IBubensService" />
</service>

然后可以在以下位置调用此服务:
http://YourServer/YourVirtualDirectory/YourServiceFile.svc/BubensService

关于.net - 错误 "No protocol binding matches the given address ...",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4261180/

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