basics of wcf

Upload: abhishek-tyagi

Post on 30-May-2018

216 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/9/2019 Basics of WCF

    1/11

    WCFWindows Communication Foundation

    -Abhishek Tyagi

    1Boot Camp- Abhishek Tyagi

  • 8/9/2019 Basics of WCF

    2/11

  • 8/9/2019 Basics of WCF

    3/11

    So what is a service?

    Service is a piece of code, we interact with a

    message.

    They are passive in itself. They wait for clientto initiate them by sending them a message.

    Services expose one or more end points

    where message can be sent.

    An end point is the access point to the

    functionality of the service.

    3Boot Camp- Abhishek Tyagi

  • 8/9/2019 Basics of WCF

    4/11

    Why WCF?

    WCF unifies the capabilities in ASMX, WSE,

    Remoting, COM+, and MSMQ.

    Therefore the developers has to learn only one

    programming model to build very effective and

    industry standard services.

    Write service once and expose it many end points.

    A lot more options like reliable sessions, lot moresecurity options built in.

    4Boot Camp- Abhishek Tyagi

  • 8/9/2019 Basics of WCF

    5/11

    ABC of WCF

    An end point to a service

    consists of three basic

    information:

    Address: Address of the endpoint. Where the end point can

    be found.

    Binding: How a client can

    communicate with the service.

    Contract: What operations are

    available.

    5Boot Camp- Abhishek Tyagi

  • 8/9/2019 Basics of WCF

    6/11

    Contracts in WCF

    There are four types of contracts in WCF:

    Service Contract: Describe which operations the client can

    perform on the service.

    Data Contract: Define which data types are passed to and

    from the service.

    Fault Contract: Define which errors are raised by the service,

    and how the service handles and propagates errors to its

    clients. Message Contract: Allow the service to interact directly with

    messages.

    6Boot Camp- Abhishek Tyagi

  • 8/9/2019 Basics of WCF

    7/11

    Creating a WCF Service

    To create a WCF web service. We need the following:

    An Interface containing service contracts.[IHello]

    A class implementing this interface.[HelloService]

    An SVC file containing assembly name and the

    service name.[Hello.svc]

    And a configuration file to configure this service so

    that it can communicate with client. [web.config ]

    7Boot Camp- Abhishek Tyagi

  • 8/9/2019 Basics of WCF

    8/11

    Testing a basic locally hosted WCF Service

    Right click on SVC file, select view in browser. The

    path in the address bar is where is service is hosted.

    Copy this path.

    Open the VSs command prompt type the following:

    testwcfclient

    In test window the methods in service will appear,

    click on invoke and test them.

    8Boot Camp- Abhishek Tyagi

  • 8/9/2019 Basics of WCF

    9/11

    Consume a WCF Service

    Host the WCF service either on IIS or locally.

    Add Service reference in the client project. In

    service URL give the path where service ishosted.

    Create an object of this reference and use the

    methods the usual way.

    9Boot Camp- Abhishek Tyagi

  • 8/9/2019 Basics of WCF

    10/11

    DEM

    O

    A demo project is added with this

    presentation.

    10Boot Camp- Abhishek Tyagi

  • 8/9/2019 Basics of WCF

    11/11

    References

    Codeproject.com

    Msdn.com

    Dotnetslackers.com

    Stackoverflow.com

    SAMSMicrosoft WCF

    Boot Camp- Abhishek Tyagi 11