spacer
Yehuda Shiran July 3, 2002
Extending a Class to a Web Service
Tips: July 2002

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
Google Chrome Playing Catch-Up on Extensions
Open Solutions Alliance Gets New Leadership
Red Hat Spacewalk Expands Linux Management
Here is what you need to do to convert a class to a Web service:

  • Import the System.Web.Service namespace
  • Add a directive line, specifying the class's language and namespace
  • Derive the class from the .NET Class Library's WebService class
  • Add the attribute WebMethodAttribute to each method you want to expose as a Web service method
  • Put your code in a file with the extension .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:

  http://localhost/Webreference/checkIsPrime.asmx
To learn more about JScript .NET, go to Column 112, JScript .NET, Part VI: Creating IE Web Services.


People who read this tip also read these tips:

Look for similar tips by subject:

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

webref The latest from WebReference.com Browse >
Administering MySQL Databases on the Web Using PHP · Popular JavaScript Framework Libraries: An Overview - Part 3 · Accessing Your MySQL Database from the Web with PHP
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
So what is an Oracle Nested Table? · E-Discovery Architectures 101 · eBay Embraces Big Sellers, Cyber Monday Trends