我有一个包含3个项目的解决方案:
当我运行这个项目时,使用WCF测试客户端一切似乎正常。现在,我在我的Web项目(MVC)中添加了一个"WcfDataServiceTest.svc"来托管我的WCF服务。
因此,我的问题是:
1. 我的Web项目(web.config)需要什么配置才能实际托管这个WCF服务? 2. 然后我想运行控制台应用程序来测试它?
注意:我已经使用控制台项目测试过我的服务,但那是从WCF测试客户端获取代理生成的。
顺便说一下,wcfDataServiceTest.svc文件看起来像这样:
- ConsoleClient(用于测试WCF服务)
- ServiceLibrary(用于WCF)
- Web(asp.net mvc项目)
<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项目(MVC)中添加了一个"WcfDataServiceTest.svc"来托管我的WCF服务。
因此,我的问题是:
1. 我的Web项目(web.config)需要什么配置才能实际托管这个WCF服务? 2. 然后我想运行控制台应用程序来测试它?
注意:我已经使用控制台项目测试过我的服务,但那是从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;
}
}