我是WCF的新手,我正在尝试理解如何正确地将我的BLL暴露给它。我创建了我的第一个Resource.svc和IResource.svc
Resource.svc
[ServiceBehavior]
public class Resources : IResources
{
#region IResources Members
public List<Model.Resource> GetAll()
{
return Repository.Inventory.Resource.GetAll(true);
}
public List<Model.Resource> GetAllEnabled()
{
return Repository.Inventory.Resource.GetAllEnabled(true);
}
#endregion
}
IResource.cs
[ServiceContract]
public interface IResources
{
[OperationContract]
List<Model.Resource> GetAll();
[OperationContract]
List<Model.Resource> GetAllEnabled();
}所以这一切都很好用,我的windows应用程序可以与服务进行对话,一切都很棒。所以我现在需要访问一些信息,我已经创建了另一个名为Project.svc和IProject.cs的.svc文件,其中包含与资源相同的信息(除了类型是项目),但这现在意味着我有另一个need服务,surley这是不对的!?
alt text http://img687.imageshack.us/img687/1588/capturepy.png
发布于 2010-04-23 03:50:02
这是正确的。您添加到WCF项目中的每个新服务都需要它自己的SVC文件。如果您公开许多不同的服务,这可能会变得错综复杂。有一些解决方案,比如将您的WCF服务架构为使用REST样式,并基于从URL调用的服务,这样一个SVC就可以确定调用哪个底层服务和方法。然而,要做到这一点,就意味着必须推出自己的ServiceHost。
https://stackoverflow.com/questions/2690964
复制相似问题