Cru Dy
Cru Dy

Reputation: 51

C# WCF Methods OperationContract

In WCF, methods or functions that aren't marked as OperationContract won't be read or presented as service methods.

But what if I used for example:

[ServiceContract]
public interface IService1
{
    void Connect();

    [OperationContract]
    DataTable SelectData(string Proc, SqlParameter[] param);
}

Then I used the Connect method in the SelectData function that it needs a connection provided by the Connect method, will it still work?

I'm using the WCF services in a Windows Phone application.

The main question is: should I work only on the classes IService1/Service1 and put all my functions and methods on, or can I add classes for example Ip1/p1 ?

Upvotes: 1

Views: 324

Answers (1)

marc_s
marc_s

Reputation: 754220

The IService1 interface is your contract with the outside world - what the outside world (other code) can see and call.

How you implement that internally is totally up to you and doesn't matter to the outside world. So if you need helper methods and classes, just go ahead and create and use them!! No harm in doing so!

But that's just the "inside" world of your service implementation - the outside world doesn't know nor care about how this is implemented in detail - the outside world (the code calling your service) only knows (and cares) about the contract defined by the interface.

Upvotes: 1

Related Questions