我在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>
Run Code Online (Sandbox Code Playgroud)
当我尝试运行它时,我得到了
没有协议绑定匹配给定地址'http:// localhost:9001/BubensService'.协议绑定在IIS或WAS配置中的站点级别配置.
我在配置中错过了什么?
mar*_*c_s 23
在IIS中托管WCF服务时,在服务端点中定义的地址不是您需要使用的地址.
<endpoint
// this is **NOT** the address you can use to call your service!
address="http://localhost:9001/BubensService"
Run Code Online (Sandbox Code Playgroud)
相反,Web服务器,其端口(通常为80)和虚拟目录以及SVC文件确定您的服务地址.所以你在这里的服务地址将是:
http://YourServer/YourVirtualDirectory/YourServiceFile.svc/
Run Code Online (Sandbox Code Playgroud)
您可以做的是定义相对地址,例如:
<service name="BShop.Services.BubensService">
<endpoint name=""
address="BubensService"
binding="basicHttpBinding" bindingConfiguration="HttpBinding"
contract="BShop.Services.IBubensService" />
</service>
Run Code Online (Sandbox Code Playgroud)
然后这个服务可以在以下位置调用:
http://YourServer/YourVirtualDirectory/YourServiceFile.svc/BubensService
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
30570 次 |
| 最近记录: |