Thursday, February 21, 2008

How much can you change your WSDL before you need to recompile your .Net consumer?

If you have a .Net application that is consuming a web service, via a web reference, how much does the WSDL have to change before your compiled application will break? I set up a simple .Net web service and tried the following:


  • Added a new method. OK

  • Removed a method (not the one we are calling). OK.

  • Modified the method by changing the argument name. Method call still worked but no data was passed in.

  • Modified the method by adding an additional parameter. Method call still worked but new parameter was not set (obviously). Original parameter was still passed through.

  • Modified the method by removing a parameter. Method call still worked!

  • Modified the method changing the parameter type from string to int. Method FAILED with format error.

  • Modified the method changing the return type from string to int. Method call still worked.



Then I tried nested objects as parameters (we use these a bit):

  • Modified the method by changing the argument name of one of the nested objects parameters. Method call still worked but no data was passed in that parameter; all other params still populated.

  • Modified the nested object by adding an additional parameter. Method call still worked but new parameter was not set (obviously). Original parameters still passed through.

  • Modified the method by removing a parameter. Method call still worked!



So a web service call is pretty forgiving. We can change most of it without a recompilation being required.

No comments: