c# - Call an operation that was dynamically added to the service contract -


i have wcf service contract (say iservice1) dynamically add operation described here. how call dynamically added operation client-side when have iservice1 transparent proxy , iclientchannel created via clientchannelfactory?

update

i can realproxy transparent proxy returned channelfactory using this method.

var realproxy = system.runtime.remoting.remotingservices.getrealproxy( transparentproxy ); 

would possible call realyproxy.invoke(imessage) fake message trick proxy calling dynamically added method?

replace generatepingmethod one:

private static void generatenewpingmethod(servicehost sh) {     foreach (var endpoint in sh.description.endpoints)     {          contractdescription contract = endpoint.contract;          operationdescription operdescr = new operationdescription("ping", contract);          messagedescription inputmsg = new messagedescription(contract.namespace + contract.name + "/ping", messagedirection.input);          messagedescription outputmsg = new messagedescription(contract.namespace + contract.name + "/pingresponse", messagedirection.output);          messagepartdescription retval = new messagepartdescription("pingresult", contract.namespace);          retval.type = typeof(datetime);          outputmsg.body.wrappername = "pingresponse";         outputmsg.body.wrappernamespace = contract.namespace;         outputmsg.body.returnvalue = retval;           operdescr.messages.add(inputmsg);         operdescr.messages.add(outputmsg);         operdescr.behaviors.add(new datacontractserializeroperationbehavior(operdescr));         operdescr.behaviors.add(new pingimplementationbehavior());         contract.operations.add(operdescr);     } } 

and create clients such:

// base interface [servicecontract] public interface iloginservice {     [operationcontract(action = "http://tempuri.org/loginservice/login", name = "login")]     bool login(string username, string password); }  [servicecontract] public interface iextendedinterface : iloginservice {     [operationcontract(action = "http://tempuri.org/loginservice/ping", name="ping")]     datetime ping(); }   class program {     static void main(string[] args)     {         iextendedinterface channel = null;         endpointaddress endpointaddr = new endpointaddress("http://localhost/loginservice");         basichttpbinding binding = new basichttpbinding();          channel = channelfactory<iextendedinterface>.createchannel(binding, endpointaddr);          if (channel.login("test", "test"))         {             console.writeline("ok");         }         datetime dt = channel.ping();          console.writeline(dt.tostring());      } } 

Comments

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -