I added a WCF Library Project(A) to an existing project(B). Project B initiates the WCF service(A), and can also stop it.
restSvc = new ServiceHost(typeof(RestServiceSvc.RestEndPoint));
restSvc.Open();
WCF service (A) has one POST, and I want to pass this information to project (B). project B can be Form Application, but not necessarily. I have no clue on where to start. Thank you.
The constructor you chose will always create a new service instance. You cannot influence that. Instead, create your own instance, so you can pass something in when you create it. It's up to you what you pass. A callback, your Form instance, additional data, anything you want:
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();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.