How to Create Web Service Class

How to Create Web Service Class thumbnail
Web services allow desktop applications to communicate with websites.

Web services classes are created using Microsoft VB.NET or C#. The classes allow you to call a website function from a desktop application or from another website. The classes define the functions available for your users. These classes are helpful for web developers who need to make high level applications that communicate with databases online. The web service class works as a "middle-man," only allowing defined functions and procedures to interact with the database.

Instructions

    • 1

      Include the web services namespace. The .NET framework are functions available in pre-defined namespaces for web services. Insert the following code as the first line of your code:
      using System.Web.Services;

    • 2

      Define the class shell. This is the main class call that defines your class. The class shell only defines the class with no statements included. The following illustrates how to create the web service class:
      public class Util: WebService
      {
      }

    • 3

      Add a description for the class. This is shown when users browse the available functions for your web service. Below is a sample description:
      public class Util: WebService
      {
      [ WebMethod(Description="Returns the server time", EnableSession=true)]
      }

    • 4

      Create a function for your class. The functions are the elements used to perform the additions, changes or deletions from your website database. The following function is used to return the time to the user application:
      public class Util: WebService
      {
      [ WebMethod(Description="Returns the server time", EnableSession=true)]
      public string Time()
      {
      return Context.Timestamp.TimeOfDay.ToString();
      }
      }

    • 5

      Save the class and press F5 to compile and run the service. When you test a web service, a template opens with a list of open functions (in this case the "Time()" function is displayed). Click the function name and the time function executes.

Related Searches:

References

  • Photo Credit sign image by Attila Toro from Fotolia.com

Comments

You May Also Like

  • How to Create a Proxy Class for a Web Service

    Web service proxies are a development platform that provides XML messages between the requesting application and the web server. It is a...

  • How to Create a Proxy for a Web Service

    A Web service proxy allows a client to communicate through SOAP messages. SOAP (Simple Object Access Protocol) is a protocol for exchanging...

  • How to Create Proxy Classes for XML Web Services

    A proxy class is created on a Visual Studio project to help the programmer interact with a remote Web service. A Web...

  • What Is a Proxy Class?

    Web services are complex programs, hosted on servers connected to the Internet which handle requests from client computers. Websites are on example...

  • How to Create a Database Web Page

    Although web designers usually use programming languages like HyperText Markup Language (HTML) to build webpages, businesses or individuals with large amounts of...

  • Define Customer Service Provider

    Customer service providers are companies and individuals who assist customers with problems concerning their accounts or services. Some customer service providers ...

  • How to Create a Class Website

    A well-developed class website can save teachers a lot of time in the long run, improving both student-teacher and parent-teacher communication while...

  • Classes for Training Service Dogs

    Service dogs are trained to be of assistance and companionship to people with disabilities. The dog is trained according to the need...

  • Create an Account in Celtx Web Services

    Learn how to create an online account for the Celtx screenwriting software in this free screenwriting software video.

Related Ads

Featured