I am writing a Web service to which many clients will connect. At some point, from the Web services, I want to send an event with some arguments to the clients. Is this possible? Can I do this through delegates? If so, can you help me with a sample code in VB/C#?
Web services are like ASP.NET pages, and ultimately reflect the underlying protocol (HTTP) disconnected nature: once the request/response cycle has finished, any connection between both vanishes.
You could provide some sort of MarshalByRef object pointer to the Web service, and let it serialize it and persist it for later reconnection, as explained in this article, but the client must have a port open for receiving this callback. What's more, if two application domains are trying to pass a remoting reference to the Web service with the same port, there will be a runtime error, as only one of them will be able to listen on that port.
But if you get to this point, why use Web services in the first place? Why don't you go directly for full remoting?
Dig Deeper on C# programming language
Related Q&A from Daniel Cazzulino
Here Daniel Cazzulino explains how to load a DSL (domain specific language) domain model instance file programmatically. This requires the .NET type ... Continue Reading
Here we offer a glimpse at 12 of .NET development expert Danny Cazzulino's top ASP.NET questions and answers. Continue Reading
C# developers should NOT be modifying InitializeComponent method in the code-behind (or any of the variable definitions) by hand. Continue Reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.