.net “错误”;没有与给定地址匹配的协议绑定…”;
我在IIS服务器上托管了2个WCF服务 这里是web.config.net “错误”;没有与给定地址匹配的协议绑定…”;,.net,wcf,.net,Wcf,我在IIS服务器上托管了2个WCF服务 这里是web.config <?xml version="1.0"?> <configuration> <system.web> <compilation debug="true" targetFramework="4.0" /> </system.web> <system.serviceModel> <bindings> <b
<?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>
当我试着运行它时,我得到了
没有协议绑定与给定的
地址
'http://localhost:9001/BubensService'.
协议绑定在以下位置配置:
IIS或中的站点级别为
配置
我在配置中遗漏了什么?当您在IIS中托管WCF服务时,服务端点中定义的地址不是您需要使用的地址
<endpoint
// this is **NOT** the address you can use to call your service!
address="http://localhost:9001/BubensService"
您可以定义相对地址,例如:
<service name="BShop.Services.BubensService">
<endpoint name=""
address="BubensService"
binding="basicHttpBinding" bindingConfiguration="HttpBinding"
contract="BShop.Services.IBubensService" />
</service>
只是为了方便人们搜索。我遇到了这个问题。为了修复它,我使用的答案查看了web.config,然后做了以下操作,因为我仍然有问题:
注意:如果任何人在使用VisualStudio开发期间在浏览器中查看WCF服务时遇到此问题,则此问题适用于他们 在为
Web.config
文件中的endpointaddress
属性赋值后,我试图从VS查看我的.svc
服务时遇到了这个问题,但是如果我没有为endpointaddress
属性赋值,那么它就可以正常工作。
在端点中定义地址与定义baseurl有什么区别?2个基本url,1个服务器定位其他本地主机定位是否解决了问题?
<service name="BShop.Services.BubensService">
<endpoint name=""
address="BubensService"
binding="basicHttpBinding" bindingConfiguration="HttpBinding"
contract="BShop.Services.IBubensService" />
</service>
http://YourServer/YourVirtualDirectory/YourServiceFile.svc/BubensService