In accordance with the principle of separation of segments , you can think about how to separate these things.
One typical approach is to have one interface (for example, one “service”) for each type of object - for example. one interface for Contact with all necessary operations and useful for contacts, etc.
Of course, you can also have methods related to several different types of objects - it is somewhat difficult to place in a specific service contract.
In addition, with WCF, you can easily have one service implementation class, which then, in turn, implements several of these interfaces at once - for example. Use common code or common templates.
But I think it would be nice to rethink your service contract and convert it into smaller and more manageable fragments.
Update:
if your service implementation class implements four service contracts, you need to configure it as follows:
<services> <service name="YourNamespace.YourServiceImplementation"> <host> <baseAddresses> <add baseAddress="http://YourServer/MyServices/" /> </baseAddresses> </host> <endpoint name="Contact" address="Contact" binding="basicHttpBinding" contract="YourNamespace.IContactService" /> <endpoint name="Letter" address="Letter" binding="basicHttpBinding" contract="YourNamespace.ILetterService" /> <endpoint name="Organisation" address="Organisation" binding="basicHttpBinding" contract="YourNamespace.IOrganisationService" /> <endpoint name="Project" address="Project" binding="basicHttpBinding" contract="YourNamespace.IProjectService" /> <endpoint name="mex" address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> </service> </services>
Now each of your services is available at a specific endpoint:
- your
IContractService is available at http://YourServer/MyServices/Contact - your
ILetterService is available at http://YourServer/MyServices/Letter
etc....
For each of these addresses you can now add links to services from the client - add only those that you really need. One application may require only one of these services, the other may require two or three, etc.
source share