简体   繁体   中英

WCF Service Reference and Reference to same project

I have a server-client legacy system which uses Microsofts WCF. In a ServiceClient project there is a service reference to the Service project. But the ServiceClient also has a "normal" reference to the Service project. In my opionen this destroys the complete server-client architecture, because the client has a reference to the Service class, but me colleague means it must be done this way. Is there any reason for having a Service Reference and Reference to the same project?

You are right, there is no good reason for doing this. But I'm sure there are "reasons" for adding such reference (most likely due to poor solution structuring).

Classes which are really needed both on client side and server side should be extracted into a separate project (usually it contains data-transfer objects and service interface). Service class (which implements service interface) remains in special server-side project. Client shouldn't care about it's implementation or dependencies - it just needs interface.

So I would recommend refactoring your Service project to split it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM