Reusing types between service and client

Usually, we will use some custom types in our WCF service operations as parameters or return values. When generating a WCF client proxy through the Visual Studio Add Service Reference context menu item, it will help to generate some skeleton types (that have the same serialization format with the custom types used in the server-side service) at the client-side instead of directly using the server-side types. However, sometimes we will need to reuse the existing types used at the server side instead of using the auto-generated skeleton types.

How to do it...

  1. Centralize all the types that we need to reuse, in a separate class library/assembly.

    The first thing we need to do is gather all those custom types (used ...

Get Microsoft Windows Communication Foundation 4.0 Cookbook for Developing SOA Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.