我在现有项目(B)中添加了WCF库项目(A)。项目B启动WCF服务(A),也可以停止它。
restSvc = new ServiceHost(typeof(RestServiceSvc.RestEndPoint));
restSvc.Open();
WCF服务(A)有一个POST,我想将此信息传递给项目(B)。 项目B可以是表单应用程序,但不一定。我不知道从哪里开始。谢谢。
答案 0 :(得分:0)
您选择的构造函数将始终创建新的服务实例。你不能影响那个。相反,创建自己的实例,以便在创建时传递内容。这取决于你通过的内容。回调,您的表单实例,其他数据,您想要的任何内容:
var service = new RestServiceSvc.RestEndPoint();
// obviously, you need to implement anything you may want to pass
// you could also pass this in the constructor of your service class
// You can access these properties in your service methods.
service.YourCustomProperty = someDataYouNeed;
service.YourCallBack = () => YourForm.FunctionCall();
restSvc = new ServiceHost(service);
restSvc.Open();