0

What is the difference between a Web Service file i.e. .asmx file and class file i.e. .cs file.

All the main logic is in the web service .asmx.cs file. Basically I needs to transferred that into a .cs class file so that it can be called from another web service.

Please tell me how to approach it. I followed this link but it does not say much about how to do it

Web service vs. class file - performance

Community
  • 1
  • 1
Mayank
  • 29
  • 2
  • 8
  • Have you tried creating a class library, adding its reference to the webservice project and calling its classes? – Andre Calil Jul 13 '12 at 18:17
  • Also, were you aware that ASMX is a legacy technology and should not be used for new development? – John Saunders Jul 13 '12 at 18:23
  • well i do not have options because the company i work in uses the legacy technology. – Mayank Jul 13 '12 at 18:26
  • @Andre Calil i had no idea how to approach it. Now you have hinted me i'll try creating class library. – Mayank Jul 13 '12 at 18:27
  • 1
    @Mayank Give a try. File > New Project > Class library. Create your classes there and move the logic from .ASMX.CS to them. Them reference this new project at the webservice project and you're done. – Andre Calil Jul 13 '12 at 18:29
  • @ Andre Calil nice!!! you just saved a lot time of mine. Thank you sir. – Mayank Jul 13 '12 at 18:31

2 Answers2

0

The difference is just that asmx files are registered to be handled as webservice (as you are mentioned all backend functionality anyway will be in cs file) routines, just like aspx files handle as pages. This can be configured in IIS console and you can easily add your own request handlers.

drbald
  • 56
  • 3
0

The asmx files are the entry points to your application.

You should keep the code there to a minimum, just call other classes. And you can put those classes in a class library to share between your two webservice projects.

Carra
  • 17,808
  • 7
  • 62
  • 75