Migrating Class Libraries to XML Web Services

Because XML Web services communicate differently than a class Library, you will not be able to add XML Web services or the <WebMethod()> tag to an existing class Library project. If you want to migrate an existing class Library project to an XML Web service, there are only a few simple steps you need to perform:

1. Create a new ASP.NET Web Service project using the same development language you used to create the class Library.

2. Copy the code from your class Library project and paste it into your XML Web service source code file ending in .asmx.

3. Add the <WebMethod()> tag to the beginning of every property and method declaration line that you want to make available via the Web.

If you do not add the <WebMethod()> tag to a property or method, that code will not be directly accessible via the XML Web services interface, but your code inside the XML Web service will still be able to enlist these nonpublic functions. Because XML Web services often have a wider audience than a class Library, you will probably want to limit the interfaces to your service more than you would a class Library. For example, if your class Library has an AddUser method that allows callers to add new user accounts to a database, you may not want to make this same method available to everyone on the Internet. By not adding a <WebMethod()> tag to this method, you prevent direct access to it via HTTP calls.

0 0

Post a comment