none
WCF Service Contract RRS feed

  • Question

  • Is there any way to use WCF service without using Service contract?

    What is the Need of the Service contract in WCF if I will Remove it then What should be happen?

    This question asked by an interviwer in Wipro. please let me know

    I m new in WCF, just learning by myself so please help....


    Monday, August 4, 2014 12:51 PM

Answers

  • No. The service contract is mandatory as it specifies what operations that the service supports:

    http://msdn.microsoft.com/en-us/library/ms731835(v=vs.110).aspx

    There is no need to expose a service at all if the callers of the service don't know what operations the service supports. And, as already mentioned, it is the contract that specifies what operations the service supports.

    Every WCF endpoint must contain an address, a binding and a contract so you cannot create a WCF service without defining a contract.

    The ServiceContractAttribute is used to indicate that an interface defines a service contract and makes sure that it is exposed for use by clients. If you remove the this attribute, the contract will not be exposed as expected.

    Monday, August 4, 2014 1:01 PM

All replies

  • No. The service contract is mandatory as it specifies what operations that the service supports:

    http://msdn.microsoft.com/en-us/library/ms731835(v=vs.110).aspx

    There is no need to expose a service at all if the callers of the service don't know what operations the service supports. And, as already mentioned, it is the contract that specifies what operations the service supports.

    Every WCF endpoint must contain an address, a binding and a contract so you cannot create a WCF service without defining a contract.

    The ServiceContractAttribute is used to indicate that an interface defines a service contract and makes sure that it is exposed for use by clients. If you remove the this attribute, the contract will not be exposed as expected.

    Monday, August 4, 2014 1:01 PM
  • thanx for the reply...

    it will help me..

    Monday, August 4, 2014 1:10 PM