wcf - Service Contract Implements another Interface -


please tell me if possible. have client win form app , wcf app in c#. model.

common project

public interface iservicea {      string doworka(); } 

i not using servicecontract or operationcontract attributes here in common project.

now, clientproject references common project. serviceproject references common project.

in serviceproject, using service contract shown below:

[servicecontract] public interface igetdata : iservicea {    // implements iservicea method    [operationcontract]    string doworka(); }   public class myservice : igetdata {     string doworka()      {       } } 

in client side

public class myclass : iservicea {     // implements iservicea method     string doworka()      {         // inside call myservice using duplexchannel proxy      } } 

[please assume callback contract implemented in model]

why asked question that, in application, have lot of modules, each needs data service own method. planning use facade pattern. please tell me if correct or not ????

your code written generates warning because igetdata dowork() method hides iservicea dowork method.

to rid of warning need add new keyword:

[servicecontract] public interface igetdata : iservicea {    // implements iservicea method    [operationcontract]    new string doworka(); } 

but think want aggregate smaller interfaces 1 larger service. modules can interact easy understand interface (which subset of service interface).

for example:

public interface iwarehouse : ishipping, ireceiving, iinventory, imovement {} 

we implemented similar.

  • we defined of our service contracts in shared assembly , used interfaces on both client , server.
  • we created client proxies implemented interfaces.

the clients interact client proxies simpler subset of entire service interface.

first define interfaces:

[servicecontract] public interface iservicea {     [operationcontract]     string doworka();  }  [servicecontract] public interface iserviceb {     [operationcontract]     string doworkb(); }  [servicecontract] public interface igetdata : iservicea, iserviceb { } 

then create proxies (you use channelfactory here):

public class serviceclienta : clientbase<igetdata>, iservicea {     public string doworka()     {         return channel.doworka();     } }  public class serviceclientb : clientbase<igetdata>, iserviceb {     public string doworkb()     {         return channel.doworkb();     } } 

the above analagous myclass.

then client can use individual interface:

iservicea clienta = new serviceclienta(); string result = clienta.doworka();  iserviceb clientb = new serviceclientb(); result = clientb.doworkb(); 

you create service factory here if wanted.

i hope gives ideas.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -