<p>How many ServiceContracts can a WCF service have?</p>

<p>Specifically, since a ServiceContract is an attribute to an interface, how many interfaces can I code into one WCF web service? Is it a one-to-one?</p>

<p>Does it make sense to separate the contracts across multiple web services?</p>

[{'answer_id': 31798, 'author': 'Sergio Acosta', 'author_id': 2954, 'author_profile': 'https://Stackoverflow.com/users/2954', 'pm_score': 2, 'selected': True, 'text': "<p>You can have a service implement all the service contracts you want. I mean, I don't know if there is a limit, but I don't think there is.</p>\n\n<p>That's a neat way to separate operations that will be implemented by the same service in several conceptually different service contract interfaces.</p>\n"}, {'answer_id': 31806, 'author': 'Sergio Acosta', 'author_id': 2954, 'author_profile': 'https://Stackoverflow.com/users/2954', 'pm_score': 1, 'selected': False, 'text': '<p>@jdiaz</p>\n\n<p>Of course you should strive to have very different business matters in different services, but consider the case in which you want that, for example, all your services implement a GetVersion() operation. You could have a service contract just for that operation and have every service implement it, instead of adding the GetVersion() operation to the contract of all your services.</p>\n'}, {'answer_id': 31808, 'author': 'Nathan', 'author_id': 541, 'author_profile': 'https://Stackoverflow.com/users/541', 'pm_score': 0, 'selected': False, 'text': "<p>A service can theoretically have any number of Endpoints, and each Endpoint is bound to a particular contract, or interface, so it is possible for a single conceptual (and configured) service to host multiple interfaces via multiple endpoints or alternatively for several endpoints to host the same interface.</p>\n\n<p>If you are using the ServiceHost class to host your service, though, instead of IIS, you can only associate a single interface per ServiceHost. I'm not sure why this is the case, but it is.</p>\n"}, {'answer_id': 31809, 'author': 'Ubiguchi', 'author_id': 2562, 'author_profile': 'https://Stackoverflow.com/users/2562', 'pm_score': 4, 'selected': False, 'text': '<p>WCF services can have multiple endpoints, each of which can implement a different service contract.</p>\n\n<p>For example, you could have a service declared as follows:</p>\n\n<pre><code>[ServiceBehavior(Namespace = "DemoService")]\npublic class DemoService : IDemoService, IDoNothingService\n</code></pre>\n\n<p>Which would have configuration along these lines:</p>\n\n<pre><code>&lt;service name="DemoService" behaviorConfiguration="Debugging"&gt;\n  &lt;host&gt;\n    &lt;baseAddresses&gt;\n      &lt;add baseAddress = "http://localhost/DemoService.svc" /&gt;\n    &lt;/baseAddresses&gt;\n  &lt;/host&gt;\n  &lt;endpoint \n    address =""\n    binding="customBinding"\n    bindingConfiguration="InsecureCustom"\n    bindingNamespace="http://schemas.com/Demo" contract="IDemoService"/&gt;\n  &lt;endpoint \n    address =""\n    binding="customBinding"\n    bindingConfiguration="InsecureCustom"\n    bindingNamespace="http://schemas.com/Demo" contract="IDoNothingService"/&gt;\n&lt;/service&gt;      \n</code></pre>\n\n<p>Hope that helps, but if you were after the theoretical maximum interfaces you can have for a service I suspect it\'s some crazily large multiple of 2.</p>\n'}]
['https://Stackoverflow.com/questions/31790', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/831/']