What is best to use when creating a web service

I have a class library (C #) with many methods that invoke the same web service (asmx).

What is the best practice for building a web service.

  • Create the web service once and pass it as a parameter to each method.
  • Or create an instance and delete the web service in each method.
+4
source share
2 answers

What you create is a local proxy class that calls the service, so it is not as expensive as you think.

Since web services must be inactive, any of these methods will work. I doubt that you will see most of the performance difference.

+6
source

It’s seams, as a bad practice, to create a new instance of the service, to connect all the events every time you need to call the service method

I usually make an instance variable and then create a service instance in the constructor and hook up all the completed events there

and only calls if necessary this approach works well, except when you execute it in User-control, it breaks down Visual Studio Designer

0
source

Source: https://habr.com/ru/post/1303341/


All Articles