Webservice method overloading

2019-07-21 05:09发布

问题:

I am able to overload the method in webservice, though on access it categorize both methods (same method with diff params) as different operations.

What is the advantage? Is there any way I can achieve calling same method from the client side and based on parameters it calls the one I need?

回答1:

Operation Overloading is a concept available in Object Oriented programming languages. However, WebServices are not limited to OO platforms. They are message oriented, where the message can be constructed/deconstructed in any platform of your choice. Since all platforms do not provide operation overloading, and since web-services are meant for integration across platforms, it is illegal for web-services to support operation overloading.

Now, the reality is slightly different. I can see several articles online where developers have done such stuff. OASIS themselves had some confusion it seems, but they finally ruled against operation overloading (see section-3.6) .



回答2:

There is no way of doing it, by rule Web Services should have Unique name. But .NET just provides an option to use the MessageName attributes for the overloaded methods.