Hi everyone. Pardon this post but I don't exactly know which post category this should belong to.
Anyway, I've just started working with Windows Communication Foundation (WCF) and I was able to create an IIS-hosted service and it works OK. My question is, when I generate a client using svcutil.exe or the one in VS 2005, it insists on creating declarations for the interfaces and classes I've used for the service. For example, if I have an IShopService interface that I mark with the [ServiceContract] attribute and I have a method in that interface like void AddToCart(Product product) that I mark with the [OperationContract] attribute, the output client code declares IShopService as well as the Product class again.
Is there a way to avoid this, so that the generated client code can simply make use of my existing IShopService and Product definitions? Normally this shouldn't be an issue for me but since my server (service) code and client code are located in a single VS solution I'm not keen on having duplication.
Thanks for any help
http://devpinoy.org/blogs/cruizer
The "redundant" declarations in WCF clients are required and important if you believe in Service-Orientation.
One of the four SOA Design Tenets is "Services share schema and contract, not class ".
(Ref: http://www.soainstitute.org/articles/article/article/the-four-tenets-of-service-orientation.html)
Assuming that the service (provider) and the client (consumer) belong to different organizations.
The service provider is not going to share its class implementation or even interface definitions with its consumer.
Consumers will just be given the contract (via wsdl or mex) for generating their own client-side proxy in their choice of language/platform.
That will make the service and the client loosely-coupled.