views:

16

answers:

1

I have to wrap legacy .net assembly API (set of classes and interfaces) with WCF service. Service is visioned as proxy that delegates calls to existing classes with virtually no additional work.

So I addded [ServiceContract] interface that exposes methods that deals with existing structures and classes. But wcf-proxy-generator (svcutil) removed some fields (declared as read-only) and is not smart enough for aliases (for example: public bool Boolean1 { get { return Booleans[0] }} turned into bool Boolean1 { get; set; }).

I decided to duplicate such legacy classes in order to remove the confusion. Now there are contract-safe version for some of existing classes & WCF service has additional code that translate contract-safe classes into legacy ones & vise versa.

Would you suggest to duplicate all the legacy classes or is it ok to have conversion only for problem ones? May be there are some extra proxy generator parameters I missed.

Thank you in advance!

+1  A: 

The proxy doesn't like your read-only properties because it needs to serialize the object and can't do that without being able to call a setter and put the serialized value back into the object.

It would be easier to modify your legacy classes to be WCF-friendly, but typically that's not an option. The classes you created to convert from legacy class to WCF-safe class seem fine, but obviously not ideal as you introduce another layer just to use those classes with WCF.

Jacob Ewald
Finally I had to create all wcf-friendly classes and conversion-to-legacy-classes-layer.
Andrew Florko