c# - Use multiple contracts but single proxy -


i've created few contracts:

[servicecontract] public interface iinterface1 {     [operationcontract]     void method1(); } 

and

[servicecontract] public interface iinterface2 {     [operationcontract]     void method2(); } 

created class implementation.cs inherits them both , implements interfaces. created few endpoints every contract, different operations worked on different protocols:

   <service name="implementation">     <endpoint binding="netnamedpipebinding" contract="iinterface1" />     <endpoint binding="nettcpbinding" contract="iinterface2" /> 

i want clients, discover service, use 1 proxy instead of two. possible them export single proxy somehow, expose both contracts?

as tim had said abc of endpoint -- address, binding , contract.

you can have 1 proxy per class, concept, design , implementation of wcf. otherwise, client programmers (users) confused, , might scratch heads.

technically can have multiple contracts single proxy, however, have build scratch @ client side, , not use wcf.

when using wcf @ client side, either generating proxy classes through svcutil.exe or handcrafting, use system.servicemodel.clientbase base class of proxy class. since clientbase takes 1 contract, have 1 proxy class per contract.

for 1 contract, may publish multiple endpoints.

in config above, have declared 2 endpoints 2 contracts in different bindings. client see 2 contracts generate 2 proxy classes.

if have following config

<service name="implementation">     <endpoint binding="netnamedpipebinding" contract="iinterface1" />     <endpoint binding="nettcpbinding" contract="iinterface2" />     <endpoint binding="simplehttpbinding" contract="iinterface1" />     <endpoint binding="simplehttpbinding" contract="iinterface2" /> </service> 

the client still generate 2 proxy classes, not 4, not 1. since clients care contracts, not implementation.

proxy classes have no knowledge of bindings. binding use determined in client codes or client config.

contracts, implementation, endpoints, binding, address , client proxy separated concerns of different parties, don't mix them.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -