Creating a SOA Service

A service is an interface that includes the ServiceContract attribute. The interface must expose at least one member that includes the OperationContract attribute.

The following example shows a simple service implementation. For information on creating a client that sends requests to the service, see Creating a SOA Client.

using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.ServiceModel;

namespace EchoService
    // Interface that defines the service.

    public interface IEchoService
        string Echo(string input);

    // Class that implements the service interface.

    [ServiceBehavior(IncludeExceptionDetailInFaults = true)]
    public class EchoService : IEchoService
        public string Echo(string input)
            return Environment.MachineName + ": " + input;