0 votes
in C Sharp by
What is a service contract in WCF?

1 Answer

0 votes
by

A service contract defines the operations which are exposed by the service to the outside world. A service contract is the interface of the WCF service and it tells the outside world what the service can do. It may have service-level settings, such as the name of the service and namespace for the service.

[ServiceContract]
interface IMyContract { 
    [OperationContract]
    string MyMethod();
}

class MyService: IMyContract {
    public string MyMethod() {
        return "Hello World";
    }
}

Related questions

0 votes
0 votes
asked Aug 12, 2020 in C Sharp by RShastri
0 votes
asked Aug 12, 2020 in C Sharp by RShastri
0 votes
asked Apr 14, 2020 in C Sharp by GeorgeBell
...