【发布时间】:2013-02-16 07:10:25
【问题描述】:
我有 3 个项目的解决方案:
- ConsoleClient(用于测试 WCF 服务)
- ServiceLibrary(用于 WCF)
- Web(asp.net mvc 项目)
我在我的 ServiceLibrary 项目的 app.config 中做了一些设置
<system.serviceModel>
<services>
<service name="MrDAStoreJobs.ServiceLibrary.AdvertisementService">
<clear />
<endpoint address="http://localhost:8050/ServiceLibrary/basic" binding="basicHttpBinding" bindingConfiguration="" contract="MrDAStoreJobs.ServiceLibrary.Interface.IAdvertisementService" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8050/Design_Time_Addresses/MrDAStoreJobs/ServiceLibrary/AdvertisementService/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information,
set the value below to false before deployment -->
<serviceMetadata httpGetEnabled="True" />
<!-- To receive exception details in faults for debugging purposes,
set the value below to true. Set to false before deployment
to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
当我运行这个项目时,一切似乎都正常使用 wcf 测试客户端。
现在,我还在我的 Web project(mvc) 中添加了一个 WcfDataServiceTest.svc 来托管我的 wcf 服务。
所以,我的问题是:
- 我的 Web 项目 (web.config) 需要什么配置才能实际托管此 wcf 服务?
- 然后我想运行控制台应用来测试它?
注意:我已经使用控制台项目测试了我的服务,但那是从 WCF 测试客户端获取代理生成。
顺便说一下,wcfDataServiceTest.svc 文件如下所示:
public class WcfDataServiceTest : DataService<AdvertisementService>
{
// This method is called only once to initialize service-wide policies.
public static void InitializeService(DataServiceConfiguration config)
{
// TODO: set rules to indicate which entity sets and service operations are visible, updatable, etc.
// Examples:
config.SetEntitySetAccessRule("Advertisements", EntitySetRights.AllRead);
// config.SetServiceOperationAccessRule("MyServiceOperation", ServiceOperationRights.All);
config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V3;
}
}
【问题讨论】:
标签: c# asp.net asp.net-mvc wcf