开发者

Extending web service proxy classes

I need to add functionality to my web service calls so object translation and automatic retries are done and abstracted away.

I would usually override the base class to add the extra functionality, but as the proxy methods aren't over-ridable I can't keep the method names the same. The only other option I can think of to do it this way is to use the 'Shadows' keyword to achieve what I want. Now I don't like the idea of shadows as it isn't particularly OOP, but in this case it seems to make a neat solution.

W开发者_Go百科hat other methods do people use to add functionality to their web service proxy classes without modifying the generated classes?


You can use the Composition over Inheritance principle to achieve this. E.g. write a wrapper around your Web Service to obtain the desired functionality.

Update: code sample

interface IWebService
{
    void DoStuff();
}

public class MyProxyClass
{
    IWebService service;

    public void DoStuff()
    {
        //do more stuff
        service.DoStuff();
    }
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜