.net - What method will get called when multiple classes implement 1 service contract interface -
this duplicate of this answer received there did not answer query , not able find on net.
taking example given in question mentioned above, when create endpoint on client side write endpoint contract interface. endpoint on client side similar following.
<client> <endpoint name="myclientendpoint" address="http://..." binding="basichttpbinding" contract="iuselessservice" /> </client>
also in code on client side create object of proxy , call method i.e. getdata
.
so question here method of class called? testservice
or realservice
? because on client side mentioning method of class should called.
i sure there setting somewhere in wcf make sure method of correct class gets called not able find it.
also little new wcf please correct me if wrong anywhere.
thanks in advance.
regards,
samar
to follow on comment, servicehost
host specific implementation of contract. it's servicehost
determines implementation of service contract - client has no knowledge of actual implementation, methods available service connecting via proxy.
so, example, if client connecting http://somedomain.com/myservice.svc
, , service host exposing endpoint using realservice
, implementation of iuselessservice
client using.
in self-hosted service, service might this:
servicehost myhost = new servicehost(typeof(realservice), new uri("http://somedomain.com/myservice"));
any client connecting http://somedomain.com/myservice
use realservice
's implementation of contract.
on other hand, you're hosting testservice
in iis, @ http://somedomain.com/myservice.svc
. in case, you'll have .svc file (and similar grzegorz posted):
<%@ servicehost language="c#" debug="true" service="testservice" %>
(i qualify service name when host in iis).
the corresponding web.config file might contain following endpoint:
<service name="testservice"> <endpoint address="" binding="basichttpbinding" contract="iuselessservice" /> </service>
in case, testservice
's implementation of contract accessed.
so, in nutshell, @ least understand it, service host determines implementation of contract (through class hosting), , given service host can have 1 implementation.
Comments
Post a Comment