Beware of reusing Class Library between Web Service and consumer

About a month ago I wrote about the ability to reuse a class library of data structures between Web Service and consumer. I've been thinking about this, and discussed this with colleges and my current customer's software architect.

The main reason is because we have to be careful when to reuse a Class Library. First of all, don't just share the data-structures between services belonging to different business processes. Why? Because this could help you forget about who's the owner of the data, and responsible for the data structure. And second, why should we reuse? Because we would help ourselves, by using Generic Lists vs standard Arrays. Or because we could use some local methods on a data structure?

We will have to deal with those very small problems, why take risks about bringing ourselves into big trouble for this. Web Services can be used with proxies, although some people advocate you should actually use xml-documents instead of serialized classes with Web Services. I think a book like "SOA Patterns" could help us in the future so we won't have to make almost mistakes.

Small note: There is a bug in the SchemaImporterExtension, which causes the extension not to be called for base classes. More about this here.

Reusing Class Library between Web Service and consumer

.NET and Visual Studio make it Web Service consumers very easy to generate a proxy for accessing the Web Service. It uses the WSDL to generate all the methods, even the asynchronous access methods. Also all data-structures are generated. Sadly all lists are generated like simple array's.

Wouldn't it be nice to use the same data-structures on the consumer as we can on the Web Service? I've been thinking about this for a long time, but as far as I knew it wasn't possible. Also a lot of people told me it just wasn't possible.

I've been thinking about a solution to do some of the deserialization on the generated proxy myself. But in my trial to create a solution and searching the Internet for possible solutions I found out about a feature called Schema Importer Extension. This can be used during proxy generation by wsdl.exe or from within Visual Studio 2005 (and maybe 2008).

Some time ago Jelle Druyts wrote an article: Customizing generated Web Service proxies in Visual Studio 2005. In this article he explains how the Schema Importer Extension works. Besides this he also writes an Schema Importer Extension that can be configured for all the data-structures that need to be reused. It's a very nice solution, only it's sad that I need to configure it. While it would be nice if discovering was automatically. But in this case you can see there is a solution to the problem where data-structures are shared between Web Service and consumer by using a class library.

Windows Communication Foundation already supports some kind of reusing. When adding a Service Reference instead of a Web Reference you can choose to reuse existing classes. I tried to use this with a plain ASP.NET Web Service without luck.

Documenting your SOA

I'm not sure if any reader has an idea about documenting your Service Oriented Architecture. But I thought about it, I can just ask. What are your ways to document a SOA?  I know the very useful tool called Word, but are there any industry standard tools to document your Services, their relations, versionin, functional and technical descriptions. I think it's also interesting to know what kind of things you are documenting about the SOA in general and the Services specifically. I'm waiting for your reply's.