服务器端 WCF 服务:如何 reference/interact 与其他服务器组件
Server Side WCF Service : How to reference/interact with other server components
关于自托管 WCF 服务与其他业务之间的交互,我有一个相当简单的设计问题 classes。
这是 WCF 服务合同:
/// <summary>
/// Represent requests on hardware components made by a client to the controler service
/// </summary>
[ServiceContract(CallbackContract = typeof(IHardwareServiceCallback))]
public interface IHardwareService
{
[OperationContract(IsOneWay = true)]
void OpenLeftDrawer();
[OperationContract(IsOneWay = true)]
void OpenRightDrawer();
}
服务实现
public class HardwareService : IHardwareService
{
public void OpenLeftDrawer()
{
}
public void OpenRightDrawer()
{
}
}
A class 其目的是处理有关服务器上客户端调用的业务逻辑
class DrawerRequestManager
{
// Server side Business logic to handle OpenDrawer requests from client
}
托管场景
Uri adrbase = new Uri(srvConfig.Address);
var host = new ServiceHost(typeof(HardwareService), adrbase);
host.AddServiceEndpoint(typeof(IHardwareService), srvConfig.Binding, srvConfig.Address);
host.Open();
由于这是管理服务实例生命周期的主机,处理服务实例和业务逻辑之间link的正确方法是什么classes(例如DrawerRequestManager
)。
我正在使用 IOC 容器,但我也对不使用 IOC 容器时的响应感兴趣。
提前致谢!
关于自托管 WCF 服务与其他业务之间的交互,我有一个相当简单的设计问题 classes。
这是 WCF 服务合同:
/// <summary>
/// Represent requests on hardware components made by a client to the controler service
/// </summary>
[ServiceContract(CallbackContract = typeof(IHardwareServiceCallback))]
public interface IHardwareService
{
[OperationContract(IsOneWay = true)]
void OpenLeftDrawer();
[OperationContract(IsOneWay = true)]
void OpenRightDrawer();
}
服务实现
public class HardwareService : IHardwareService
{
public void OpenLeftDrawer()
{
}
public void OpenRightDrawer()
{
}
}
A class 其目的是处理有关服务器上客户端调用的业务逻辑
class DrawerRequestManager
{
// Server side Business logic to handle OpenDrawer requests from client
}
托管场景
Uri adrbase = new Uri(srvConfig.Address);
var host = new ServiceHost(typeof(HardwareService), adrbase);
host.AddServiceEndpoint(typeof(IHardwareService), srvConfig.Binding, srvConfig.Address);
host.Open();
由于这是管理服务实例生命周期的主机,处理服务实例和业务逻辑之间link的正确方法是什么classes(例如DrawerRequestManager
)。
我正在使用 IOC 容器,但我也对不使用 IOC 容器时的响应感兴趣。
提前致谢!