views:

15

answers:

1

I have a webservice that I want to Consume in my application. Too be able to test the other parts of the application I have built an Interface that allows me to test using mocks and stubs.

I can add the Interface to the generated code from the web service, however if at any point in time a regenerate the code I loose the Interface on the generated code.

What strategies or Patterns could I employ in this situation to minimize the disruption when the web service reference is regenerated.

+1  A: 

Build a wrapper around the generated proxy code, and that's where your code goes. Do not ever alter the generated proxy, as you should consider it "expendable". I'm coming from a Delphi background, but I expect that this is applicable here as well.

Update: The wrapper should control the lifetime of the underlying SOAP object (declare and create the instance of the proxy class), and expose useful properties and methods to your app, in such a way that any changes to the WSDL (and thus the proxy) will not impact the rest of the app (much). i.e. this is an abstaction layer, hiding the gory details. In mine, I also take care of serialization issues (the SOAP XML isn't always what my proxy thinks should be coming, probably because we're using an older version of Delphi), inject security certificates, manage endpoints, and log data in/out. The rest of the app is blissfully unaware, instead calling functions such as:

SendWidgets('select id from WidgetTable where status = NEW');
GetWidgets(path_to_WidgetTable);
ShowWidgetLog(Today-1);
Chris Thornton
What would this wrapper class look like? Should it create the instance of the proxy code. I guess now I just need some help defining what this wrapper pattern looks like.
Bluephlame