Tôi có một giải pháp với 3 dự án:Hosting Dịch vụ WCF trong Asp.Net MVC Project
- ConsoleClient (để thử nghiệm dịch vụ WCF)
- ServiceLibrary (cho WCF)
- web (asp.net MVC dự án)
tôi đã làm một số cài đặt trong dự án ServiceLibrary tôi trong 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>
Khi tôi chạy dự án này, mọi thứ có vẻ bình thường khi sử dụng trình kiểm tra khách hàng wcf.
Bây giờ, tôi cũng đã thêm WcfDataServiceTest.svc
vào số Web project(mvc)
để lưu trữ dịch vụ wcf của mình.
Vì vậy, câu hỏi của tôi là:
- những gì cấu hình sao tôi cần cho dự án web của tôi (web.config) để thực sự tổ chức dịch vụ WCF này?
- Và sau đó tôi muốn chạy ứng dụng bảng điều khiển để kiểm tra nó?
Lưu ý: Tôi đã thử nghiệm dịch vụ của mình bằng cách sử dụng dự án bảng điều khiển nhưng đã nhận được proxy từ khách hàng thử nghiệm WCF.
Bằng cách này, các tập tin wcfDataServiceTest.svc trông như thế này:
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;
}
}
tôi không thể tìm ServiceRoute. Bất cứ ai biết không gian tên? – Rap
Rap, không gian tên (và dll) cho ServiceRoute là System.ServiceModel.Activation. Bạn cũng sẽ cần tệp System.ServiceModel.Web cho WebServiceHostFactory. –