C# – Inheriting from a webservice (WSE), can I override the results


I have a WSE web service that returns a list of items in a collection.

I need to change certain items in the collection if they match a particular regex pattern.

I don't have the source code to the web service!

Would it be possible to inherit from the service and hook into the method marked with [webmethod] and then loop through the collection, filter it, then return it to the calling client?

Best Solution

I don't have WSE installed anymore on my machine, but from what I remember, you create proxies just as you did with regular ASMX web services.

The proxy implements its code as a partial class under the web service reference.

  • Add another file to the project as another part of the proxy's partial class and add the behavior you need in another method.
  • If you really need to use the original method, then you can inherit the auto-generated one and hide (new) the original method with your own implementation.