【发布时间】:2009-02-12 15:20:15
【问题描述】:
我正在尝试通过在 Anthony Steele 的 this blog post 上重新创建项目来学习如何使用 WCF 构建 RESTful 服务。他在他的配置中使用以下 XML 来设置服务的端点。
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/greeter"/>
</baseAddresses>
</host>
但是,当我尝试在 ASP.NET 3.5 网站的 web.config 中执行相同操作时,我无法导航到我的服务。这是我正在使用的 XML:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="GreeterBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="GreeterBehavior" name="Greeter">
<host>
<baseAddresses>
<add baseAddress="http://localhost:49268/TestREST/webapi/services/greeter"/>
</baseAddresses>
</host>
<endpoint address="" binding="wsHttpBinding" contract="IGreeter">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
</system.serviceModel>
我想我的配置可以让我导航到http://localhost:49268/TestREST/webapi/services/greeter 并查看我的服务。我得到的只是资源未找到消息 - 我错过了什么吗?
编辑:我的部分问题是我的绑定是 wsHttpBinding。使用 webHttpBinding 可以让我正确使用服务 - 除了 baseAddress 配置部分仍然无效。
【问题讨论】:
标签: wcf rest asp.net-3.5 endpoint base-address