Search code examples
c#.netwcfwcf-client

Need WCF Clarification on client/server operations


I need to have a C# NET Server application and C# NET Client application. Using an ASP web interface for the server, I will need to be able to tell a specific client application to do functions such as DownloadFile(string url), CreateWindowsService(), etc.

Would I do something like the following on the server and expose them to the client applications?

[ServiceContract]
public interface IFunctions
{
  [OperationContract]
  void DownloadFile(string url);
  void CreateWindowsService();
  void OtherFunctions();
}

From what I have read, it sounds like I define/code functions on the server, then the client applications actually run the functions as if it was coded into them?

On another note, after reading over the descriptions of the bindings, it sounds like I should use Tcp for this project? Each client application will be on a seperate machine.


Solution

  • No, the operations are run on the server, the result of the operation (if not void) is sent to the client in a serialized format.

    Edit
    When you add a WCF reference to the client a proxy is generated with methods that has the same signature as the server contract. Each proxy method encodes its input parameters in a serialized form and sends them over to the server. The server decodes the request, executes the method on the server and returns the answer. The client decodes the answer into regular c# types and finally returns from the proxy method.