July 3, 2002 - Extending a Class to a Web Service
July 3, 2002 Extending a Class to a Web Service Tips: July 2002
Yehuda Shiran, Ph.D.
|
System.Web.Service
namespace
WebService
class
WebMethodAttribute
to each method you want to expose as a Web service method
.asmx
and save in your Web server area.
Let's apply the main steps from above to our PrimeNumbers class. The directive line is the first line of the file and looks like this:
<%@ WebService Language="JScript" class="PrimeNumbers" %>
You derive the class from the WebService
class by extending it. The WebService class includes a lot of methods that are needed for deploying a Web service. Basing your class on the WebService
class provides you with these methods for free. You need focus only on your unique value-adding business logic. Here is how you extend WebService
to PrimeNumbers
:
public class PrimeNumbers extends WebService {
The location of your Web service is on your Web server. If your Web server is IIS and your file is checkIsPrime.asmx
for example, you can save it in a directory under c:\inetpub\wwwroot
. For example:
c:\inetpub\wwwroot\Webreference\checkIsPrime.asmx
From now on, you can refer to this Web service as:
https://localhost/Webreference/checkIsPrime.asmx
To learn more about JScript .NET, go to Column 112, JScript .NET, Part VI: Creating IE Web Services.