.net 错误“没有协议绑定匹配给定的地址......”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4261180/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
error "No protocol binding matches the given address ..."
提问by VoimiX
I have 2 WCF serivces hosted in IIS server.
我在 IIS 服务器中托管了 2 个 WCF 服务。
Here is web.config
这是 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>
When I try to run it I got
当我尝试运行它时,我得到了
No protocol binding matches the given address 'http://localhost:9001/BubensService'. Protocol bindings are configured at the Site level in IIS or WAS configuration.
没有协议绑定匹配给定地址“http://localhost:9001/BubensService”。协议绑定在 IIS 或 WAS 配置中的站点级别进行配置。
What I missed in config?
我在配置中遗漏了什么?
回答by marc_s
When you host your WCF services in IIS, your address defined in the service endpoints is not the one you need to use.
当您在 IIS 中托管 WCF 服务时,您在服务终结点中定义的地址不是您需要使用的地址。
<endpoint
// this is **NOT** the address you can use to call your service!
address="http://localhost:9001/BubensService"
Rather, the web server, its port (usually 80) and the virtual directory plus the SVC file determine your service address. So you service addresses here would be:
相反,Web 服务器、它的端口(通常是 80)和虚拟目录加上 SVC 文件决定了您的服务地址。所以你这里的服务地址是:
http://YourServer/YourVirtualDirectory/YourServiceFile.svc/
What you can do is define relative addresses, e.g.:
您可以做的是定义相对地址,例如:
<service name="BShop.Services.BubensService">
<endpoint name=""
address="BubensService"
binding="basicHttpBinding" bindingConfiguration="HttpBinding"
contract="BShop.Services.IBubensService" />
</service>
Then this service would be callable at :
然后可以在以下位置调用此服务:
http://YourServer/YourVirtualDirectory/YourServiceFile.svc/BubensService
回答by HockeyJ
Just for the benefit of people searching. I came across this problem. To fix it I reviewed the web.config using marc_s's answer then did the following as I still had problems:
只是为了人们搜索的好处。我遇到了这个问题。为了修复它,我使用marc_s的答案查看了 web.config然后执行以下操作,因为我仍然遇到问题:
- Delete Virtual Directory.
- Went to project properties - > Web Panel -> Selected 'Use Local IIS Web Server' with project url of http://{localhost}/{myservice} (obviously without the braces) and re-created the virtual directory.
- Changed the App Pool to .NET 4 with integrated pipeline mode. The app pool change seemed to fix it.
- 删除虚拟目录。
- 转到项目属性 - > Web 面板 - > 选择“使用本地 IIS Web 服务器”,项目 url 为 http://{localhost}/{myservice}(显然没有大括号)并重新创建虚拟目录。
- 将应用程序池更改为具有集成管道模式的 .NET 4。应用程序池更改似乎修复了它。

