开发者

WCF: wrapping legacy API question

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开发者_JS百科 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!


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜