WebService Example

In http://mono-project.com/Writing_a_WebService we are told how to implement a Web Service, but also the code used is a very illustrative example. Suppose the file NumberService.asmx is made initially by an author duly named and who publicly is displayed as First.

<%@ WebService Language="C#" Class="MathService.MathService" %>

using System;
using System.Web.Services;

namespace MathService
{
        [WebService (Namespace = "http://tempuri.org/NumberService")]
        public class MathService : WebService
        {
                [WebMethod]
                public int AddNumbers (int number1, int number2)
                {
                        return number1 + number2;
                }
        }
}

First will take all appropriate copyrights for making their contribution at the time, so it is essential to identify the date and time of each new entry. Suppose, for example, that five days later a new author identified as Second provides a new method to First‘s Class.

<%@ WebService Language="C#" Class="MathService.MathService" %>

using System;
using System.Web.Services;

namespace MathService
{
        [WebService (Namespace = "http://tempuri.org/NumberService")]
        public class MathService : WebService
        {
                [WebMethod]
                public int AddNumbers (int number1, int number2)
                {
                        return number1 + number2;
                }

                [WebMethod]
                public int SubtractNumbers (int number1, int number2)
                {
                        return number1 - number2;
                }
        }
}

So the service has to be able to identify any changes carefully, so not a big company needed to make a contribution. In this case, the database used by the service should store in addition to identifying areas and the date of the transfer, modification made, ie

[WebMethod]
public int SubtractNumbers (int number1, int number2)
{
        return number1 - number2;
}

and their position and how it integrates with previous contributions.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: