简体   繁体   中英

Baked Optional Parameters and WebService calls in C#?

AFAIK:

Adding an optional parameter to a public method that's called from another assembly requires recompilation of both assemblies— just as though the parameter were mandatory.

I was wondering about WebService in this context.

What about me - using an added optional param webservice method ?

for example :

lets say Google's webservice method was :

void DoWork(int a , int b)

and it was changed to

void DoWork(int a , int b  , isDefault=false)
  • must I , as a consumer need to recreate the proxy file ?

My understanding is that optional parameters are syntactic sugar.

You still end up with an overload that takes all parameters as mandatory, however the compiler will automatically insert the default for the optional parameter into the call site in the IL when it encounters a method call without the optional parameter specified.

How this affects Web Services depends on how the optional parameter is propagated through the proxy.

If it is a non-breaking change to the WSDL, then my guess is that it won't make a difference, where you won't need to regenerate the proxy, and the requests generated by the existing proxy will still be valid from a WSDL contract point of view.

However, if it is a breaking change to the WSDL, then you would obviously need to regenerate the proxy, and any call sites into proxy methods would need to be recompiled.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM