Adding a custom constructor to the WCF service and accessing it on the client (asp.net forms or windows)

I need to pass a string as a parameter to a WCF service through a custom constructor.

public partial class ServiceXX : IServiceXX { private string test; static ServiceXX() { } public ServiceXX() { this.test= null; } public ServiceXX(string test) { this.test= test; } } 

It is required to have access to this constructor with the parameter through the service (proxy) link in the client.

Asp.net example:

 using (ServiceXXClient proxy = new ServiceXXClient("Teste")) { } 

Any suggestion?

Thanks for the advanced.

+4
source share
1 answer

You just can't. Customer is not interested in you Service Code. It only cares about the endpoint (abc-address, binding, contract). Remember that you do not call the code, you send a message through the wire (or between processes), which will be received and translated to use your code.

 client - call service (via through code friendly proxy) - create message - serialise - send service - receive message - validate/verify - deserialise - authenticate/authorise - call friendly code with friendly content 
+5
source

Source: https://habr.com/ru/post/1487547/


All Articles