Operation Overloading in WCF

Objective:

This article will explain,

  1. What is Service Contract?
  2. How to achieve Operation overloading in Service.
  3. How to achieve operation overloading at client side.
  4. It explained the entire concept with supporting code as well.
  5. This will explain in detail of all the aspect of method overloading and manually configuration at client side.

    What is Service Contract?

    image1.gif

    ServiceContractAttribute class is defined as

    image2.gif
    1. It is defined under namespace System.ServiceModel.
    2. It got 6 properties.
    3. It could be applied either on service contract interface or service contract class.
    Could we achieve Operation overloading in Service Contract?

    image3.gif

    How to achieve operation overloading?

    By using Name property of OperationContractAttribute class.

    image4.gif

    image5.gif

    OperationContractAttribute class

    Code Sample
    1. Service is having 3 overloaded operations.
    2. Add operation is taking different parameters.
    3. Name properties are being used to achieve overload operation.
    4. We will give aliased name to achieve overload using Name properties of OperationContractAttribute class.

      image6.gif
    Service Contract (IAddCalculator.cs)

    image7.gif

    Service Implementation (AddCalculator.cs)

    image8.gif

    When the client imports the contract and generates the proxy, the imported operations will have the aliased name.

    At client side, the below methods will be imported.

See full detail: http://www.c-sharpcorner.com/UploadFile/dhananjaycoder/operationoverloadinginwcf06282009220933PM/operationoverloadinginwcf.aspx

Comments

Popular posts from this blog

Asynchronous Socket Programming in C#

Url Routing MVC TUTORIAL

WCF Chat Sample