SlideShare una empresa de Scribd logo
1 de 36
http://debugmode.net




Getting Started with
        WCF
           Dhananjay Kumar
           @debug_mode
What definition you get on web ?
Service Oriented programming model to
develop connected applications


SDK to develop and deploy services on windows

Unifies the existing suite of .Net distributed
technologies into a single programming model.

                Microsoft Innovation & Practice Team,
                                              MSCoE     2
Getting Started with WCF




Developer Evangelist Telerik

Microsoft MVP

Mindcracker MVP

@debug_mode

fb.com/debugmode.net

Delhi User Group

C-Sharp corner User Group
Services and Clients



     Service   Message   Client
Let us start
with a Demo
Endpoints


  Client                      Service

                          Endpoint

     Endpoint   Message   Endpoint
End Points




  A          B   C   E


                         7
End Points


                          Contracts
             Address



                       Binding




              End Point
                                      8
End Point

ADDRESS
           •Where
BINDING
           •How
CONTRACT
           •What
9
Address (A)
Every service is associated with a unique
  address.

         Location of
         the Service

                          Address
                           of the
          Transport
                          Service
           protocol
           used in
            service

                                            10
Address (A)

Address specifies where the service is residing.


This is an URL( Uniform Resource Locator).


Address URL identifies , location of the service

Address should follow the Web Service
Addressing(WS-Addressing) standard.
                                                   11
Address (A)


                 WS
              Addressing

Scheme   Machine       Port   Path



                                     12
Address (A)

              • This is top level portion of the address.
 Scheme         This is not as same as of protocols.

              • This identifies the machine name. This
Machine         can be a public URL or a local identifier

              • This is port number. This is an optional
   Port         part.

              • This is used to locate the path. This
   Path         gives path of the service.
                                                        13
Address (A)
               • http://localhost:8001/Dell
   HTTP        • http://localhost/Dell

               • net.tcp://localhost:800/Dell
    TCP        • net.tcp://localhost/Dell

               • net.msmq/private/MyService
  MSMQ         • Net.msmq/://localhost/Dell


               • net.pipe://localhost/MyPipe
    IPC




               • Net.pipe://localhost.MyService
Peer network



                                                  14
Binding (B)
Describes how a service communicates.


This specifies which Protocol to be used.


This specifies the encoding method to format the message content.


This specifies the Security requirements


This specifies the message exchange format.


This specifies message session mode.

Developer could create custom Binding also.
15
Binding (B)
Transport Protocol

Message Encoding

Communication Pattern

Security

Transaction Property

Inter Operability

16
Binding (B)
      Choosing Binding

                  No           WCF      Yes
                                To
                               WCF



                                                        No                        Yes
                                                                   Disconnected
                                                                       Calls



 No                Yes
         Legacy                        No                    Yes
                                              Cross
          ASMX                                Machine




WS                     Basic         IPC                       TCP                      MSMQ


 17
Binding (B)
Binding Classes
Binding Name as of class   Transport    Encoding    Interoperable

BasicHttpBinding           HTTP/HTTPS   Text,MTOM   Yes
NetTcpBinding              TCP          Binary      No
NetPeerBinding             P2P          Binary      No
NetNamedPipeBinding        IPC          Binary      No
WSHttpBinding              HTTP/HTTPS   Text,MTOM   Yes
WSFederationHttpBinding    HTTP/HTTPS   Text,MTOM   Yes
WSDualHttpBinding          HTTP         Text,MTOM   Yes
NetMsmqBinding             MSMQ         Binary      No
MsmqIntegrationBinding     MSMQ         Binary      Yes

18
Binding (B)
Configuring Binding

     <endpoint address="Calculator"
               bindingSectionName="basicProfileBinding"
               bindingConfiguration="Binding1"
               contractType="ICalculator" />
     <bindings>
       <basicProfileBinding>
         <binding configurationName="Binding1"
                  hostnameComparisonMode="StrongWildcard"
                  transferTimeout="00:10:00"
                  maxMessageSize="65536"
                  messageEncoding="Text"
                  textEncoding="utf-8"
         </binding>
       </basicProfileBinding>
     </bindings>
19
Service Contract (C)

A WCF Contract is a collection of Operations


All WCF services exposes contract.

This is a platform neutral and standard way to say , what
the service will do.

Defines , what a Service communicates.

20
Contract (C)
Types of Contracts
 Service • Describes which operation client can perform on the services.
Contract

           • Defines which Data Type are passed to and from the services. It provides built-
  Data       in contract for implicit type.
Contract

           • Which error raise by service and how service propagates and handles error to its
 Fault       client.
Contract

         • Allow the service to interact directly with the message . Message contract can
Message    be typed or un typed. This can be used for interoperability.
Contract


21                                                                                              21
Contract (C)
 Service Contract

A Service Contract reflects specific business


Describe which operations client can
perform

Maps CLR types to WSDL
 22
Contract (C)
 Service Contract

Interfaces are used to explicitly define a Contract


Classes may also be used to define a Contract.

[ServiceContract] attribute is being used by
interface/class to qualify them as a contract.

ServiceContract are implicitly public.
 23
Contract (C)
Service Contract
     // Define a service contract.
     [ServiceContract(Namespace="http://Microsoft.ServiceModel.Samples")]
     public interface IDataContractCalculator
     {
         [OperationContract]
         ComplexNumber Add(ComplexNumber n1, ComplexNumber n2);
         [OperationContract]
         ComplexNumber Subtract(ComplexNumber n1, ComplexNumber n2);
         [OperationContract]
         ComplexNumber Multiply(ComplexNumber n1, ComplexNumber n2);
         [OperationContract]
         ComplexNumber Divide(ComplexNumber n1, ComplexNumber n2);
     }




24
Contract (C)
Data Contract
These are the contractual agreement about the format
and structure of the payload data in message exchange
between a service and its consumer.

Defines which Data types are passed to and from the
service.


Its specifies CLR type to XML schema.
25
Contract (C)
 Data Contract
DataContract are preferred WCF way to enable
Serialization.

WCF defines implicit contract for built in types like int and
string.

Developer has to explicitly expose complex types as Data
Contract.

[DataContract] and [DataMember] attribute are used to
define a type as Data Contract.
 26
Contract (C)
Data Contract

     [DataContract]
     public class ComplexNumber
     {
         [DataMember]
         public double Real = 0.0D;
         [DataMember]
         public double Imaginary = 0.0D;
     }


27
Contract (C)
 Message Contract
It gives control over SOAP message structure on both header and body
content.

Developer can designate optional SOAP headers.


It provides additional control over the WSDL generation.


It is used to interoperate with another non- WCF service.


It is used to control security issue at level of message.
 28
Contract (C)
 Fault Contract

This translates .Net Exception to SOAP fault propagated to consumer


This can be applied to operation only.


This is not Inheritable.


This can be applied multiple times.

This enables developer to declare which faults a given service operation
might issue if things goes wrong.
 29
Creating End Point


Could be created declaratively in configuration file.


Could be created imperatively through code.

Any thing done through code can be done with configuration file and
vice versa.

It is considered good practice to use configuration file to specify End
points. This accommodates changes without recompiling the code.
 30
Defining Endpoints


<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
  <system.serviceModel>
    <services>
      <service serviceType="CalculatorService">
        <endpoint address="Calculator"
                  bindingSectionName="basicProfileBinding"
                  contractType="ICalculator" />
      </service>
    </services>
  </system.serviceModel>
</configuration>
Multiple End Point

For service exposed to multiple clients ; it makes sense to
specify more than one End point.

This enables client to use the endpoint that is most
applicable for them.

When creating multiple endpoints each client must have
unique address

If two client uses the same address , error will raise at
service load time.
  32
Multiple End Point
• <endpoint address="http://localhost:8890/a"
  binding="wsHttpBinding"
  contract="HotsingSamples.IService1"/>
• <endpoint address="http://localhost:8000/b"
  binding="basicHttpBinding"
  contract="HotsingSamples.IService1"/>
• <endpoint address="net.tcp://localhost:8001/c"
  binding="netTcpBinding"
  contract="HotsingSamples.IService1"/>


33
Hosting
WCF services can not exist in void.


It must be hosted.

WCF services are hosted in windows process called host
process.

A single host process can host multiple service.


A same service can be hosted in multiple host process.
 34
WCF basic task cycle

                             1.
                         Defining
                          Service
                         Contract
                                              2.
           5.                             Impleme
        Building                            nting
         Clients                           Service
                                          Contract



                                       3.
                 4.
                                    Configuri
              Hosting
                                       ng
              Services
                                    Services

                                                     35
DEBUG_MODE           http://debugmode.net




             Dhananjay Kumar

Más contenido relacionado

La actualidad más candente

Interoperability and Windows Communication Foundation (WCF) Overview
Interoperability and Windows Communication Foundation (WCF) OverviewInteroperability and Windows Communication Foundation (WCF) Overview
Interoperability and Windows Communication Foundation (WCF) OverviewJorgen Thelin
 
Building RESTful Services with WCF 4.0
Building RESTful Services with WCF 4.0Building RESTful Services with WCF 4.0
Building RESTful Services with WCF 4.0Saltmarch Media
 
WCF tutorial
WCF tutorialWCF tutorial
WCF tutorialAbhi Arya
 
WCF (Windows Communication Foundation)
WCF (Windows Communication Foundation)WCF (Windows Communication Foundation)
WCF (Windows Communication Foundation)ipower softwares
 
REST, JSON and RSS with WCF 3.5
REST, JSON and RSS with WCF 3.5REST, JSON and RSS with WCF 3.5
REST, JSON and RSS with WCF 3.5Rob Windsor
 
Windows Communication Foundation (WCF) Service
Windows Communication Foundation (WCF) ServiceWindows Communication Foundation (WCF) Service
Windows Communication Foundation (WCF) ServiceSj Lim
 
Advancio, Inc. Academy: Web Sevices, WCF & SOAPUI
Advancio, Inc. Academy: Web Sevices, WCF & SOAPUIAdvancio, Inc. Academy: Web Sevices, WCF & SOAPUI
Advancio, Inc. Academy: Web Sevices, WCF & SOAPUIAdvancio
 
Enjoying the Move from WCF to the Web API
Enjoying the Move from WCF to the Web APIEnjoying the Move from WCF to the Web API
Enjoying the Move from WCF to the Web APIKevin Hazzard
 
introduction to Windows Comunication Foundation
introduction to Windows Comunication Foundationintroduction to Windows Comunication Foundation
introduction to Windows Comunication Foundationredaxe12
 
Beginning with wcf service
Beginning with wcf serviceBeginning with wcf service
Beginning with wcf serviceBinu Bhasuran
 
1. WCF Services - Exam 70-487
1. WCF Services - Exam 70-4871. WCF Services - Exam 70-487
1. WCF Services - Exam 70-487Bat Programmer
 
Session 1: The SOAP Story
Session 1: The SOAP StorySession 1: The SOAP Story
Session 1: The SOAP Storyukdpe
 
Web services, WCF services and Multi Threading with Windows Forms
Web services, WCF services and Multi Threading with Windows FormsWeb services, WCF services and Multi Threading with Windows Forms
Web services, WCF services and Multi Threading with Windows FormsPeter Gfader
 

La actualidad más candente (20)

Interoperability and Windows Communication Foundation (WCF) Overview
Interoperability and Windows Communication Foundation (WCF) OverviewInteroperability and Windows Communication Foundation (WCF) Overview
Interoperability and Windows Communication Foundation (WCF) Overview
 
Building RESTful Services with WCF 4.0
Building RESTful Services with WCF 4.0Building RESTful Services with WCF 4.0
Building RESTful Services with WCF 4.0
 
Wcf
WcfWcf
Wcf
 
WCF tutorial
WCF tutorialWCF tutorial
WCF tutorial
 
WCF (Windows Communication Foundation)
WCF (Windows Communication Foundation)WCF (Windows Communication Foundation)
WCF (Windows Communication Foundation)
 
Wcf development
Wcf developmentWcf development
Wcf development
 
REST, JSON and RSS with WCF 3.5
REST, JSON and RSS with WCF 3.5REST, JSON and RSS with WCF 3.5
REST, JSON and RSS with WCF 3.5
 
WCF
WCFWCF
WCF
 
Windows Communication Foundation (WCF) Best Practices
Windows Communication Foundation (WCF) Best PracticesWindows Communication Foundation (WCF) Best Practices
Windows Communication Foundation (WCF) Best Practices
 
Windows Communication Foundation (WCF) Service
Windows Communication Foundation (WCF) ServiceWindows Communication Foundation (WCF) Service
Windows Communication Foundation (WCF) Service
 
WCF
WCFWCF
WCF
 
Advancio, Inc. Academy: Web Sevices, WCF & SOAPUI
Advancio, Inc. Academy: Web Sevices, WCF & SOAPUIAdvancio, Inc. Academy: Web Sevices, WCF & SOAPUI
Advancio, Inc. Academy: Web Sevices, WCF & SOAPUI
 
Enjoying the Move from WCF to the Web API
Enjoying the Move from WCF to the Web APIEnjoying the Move from WCF to the Web API
Enjoying the Move from WCF to the Web API
 
introduction to Windows Comunication Foundation
introduction to Windows Comunication Foundationintroduction to Windows Comunication Foundation
introduction to Windows Comunication Foundation
 
Beginning with wcf service
Beginning with wcf serviceBeginning with wcf service
Beginning with wcf service
 
1. WCF Services - Exam 70-487
1. WCF Services - Exam 70-4871. WCF Services - Exam 70-487
1. WCF Services - Exam 70-487
 
Session 1: The SOAP Story
Session 1: The SOAP StorySession 1: The SOAP Story
Session 1: The SOAP Story
 
Web services, WCF services and Multi Threading with Windows Forms
Web services, WCF services and Multi Threading with Windows FormsWeb services, WCF services and Multi Threading with Windows Forms
Web services, WCF services and Multi Threading with Windows Forms
 
Windows Communication Foundation
Windows Communication FoundationWindows Communication Foundation
Windows Communication Foundation
 
Simple object access protocol(soap )
Simple object access protocol(soap )Simple object access protocol(soap )
Simple object access protocol(soap )
 

Similar a WCF for begineers

Dot Net Training Wcf Dot Net35
Dot Net Training Wcf Dot Net35Dot Net Training Wcf Dot Net35
Dot Net Training Wcf Dot Net35Subodh Pushpak
 
A presentation on WCF & REST
A presentation on WCF & RESTA presentation on WCF & REST
A presentation on WCF & RESTSanthu Rao
 
Wcf best practice
Wcf best practiceWcf best practice
Wcf best practiceYu GUAN
 
WCF (Windows Communication Foundation_Unit_01)
WCF (Windows Communication Foundation_Unit_01)WCF (Windows Communication Foundation_Unit_01)
WCF (Windows Communication Foundation_Unit_01)Prashanth Shivakumar
 
Top wcf interview questions
Top wcf interview questionsTop wcf interview questions
Top wcf interview questionstongdang
 
Basics of WCF and its Security
Basics of WCF and its SecurityBasics of WCF and its Security
Basics of WCF and its SecurityMindfire Solutions
 
Understanding Web Services by software outsourcing company india
Understanding Web Services by software outsourcing company indiaUnderstanding Web Services by software outsourcing company india
Understanding Web Services by software outsourcing company indiaJignesh Aakoliya
 
Cloud Presentation.pdf
Cloud Presentation.pdfCloud Presentation.pdf
Cloud Presentation.pdfMandanaHazeri
 
Client server chat application
Client server chat applicationClient server chat application
Client server chat applicationSamsil Arefin
 
Complete Architecture and Development Guide To Windows Communication Foundati...
Complete Architecture and Development Guide To Windows Communication Foundati...Complete Architecture and Development Guide To Windows Communication Foundati...
Complete Architecture and Development Guide To Windows Communication Foundati...Abdul Khan
 
Consul: Service Mesh for Microservices
Consul: Service Mesh for MicroservicesConsul: Service Mesh for Microservices
Consul: Service Mesh for MicroservicesArmonDadgar
 
Web services
Web servicesWeb services
Web servicesaspnet123
 
Java Network Programming.pptx
Java Network Programming.pptxJava Network Programming.pptx
Java Network Programming.pptxRoshniSundrani
 

Similar a WCF for begineers (20)

Dot Net Training Wcf Dot Net35
Dot Net Training Wcf Dot Net35Dot Net Training Wcf Dot Net35
Dot Net Training Wcf Dot Net35
 
Wcf faq
Wcf faqWcf faq
Wcf faq
 
A presentation on WCF & REST
A presentation on WCF & RESTA presentation on WCF & REST
A presentation on WCF & REST
 
Wcf best practice
Wcf best practiceWcf best practice
Wcf best practice
 
WCF (Windows Communication Foundation_Unit_01)
WCF (Windows Communication Foundation_Unit_01)WCF (Windows Communication Foundation_Unit_01)
WCF (Windows Communication Foundation_Unit_01)
 
Top wcf interview questions
Top wcf interview questionsTop wcf interview questions
Top wcf interview questions
 
Basics of WCF and its Security
Basics of WCF and its SecurityBasics of WCF and its Security
Basics of WCF and its Security
 
web programming
web programmingweb programming
web programming
 
Understanding Web Services by software outsourcing company india
Understanding Web Services by software outsourcing company indiaUnderstanding Web Services by software outsourcing company india
Understanding Web Services by software outsourcing company india
 
Cloud Presentation.pdf
Cloud Presentation.pdfCloud Presentation.pdf
Cloud Presentation.pdf
 
Client server chat application
Client server chat applicationClient server chat application
Client server chat application
 
Presentation1.pptx
Presentation1.pptxPresentation1.pptx
Presentation1.pptx
 
Complete Architecture and Development Guide To Windows Communication Foundati...
Complete Architecture and Development Guide To Windows Communication Foundati...Complete Architecture and Development Guide To Windows Communication Foundati...
Complete Architecture and Development Guide To Windows Communication Foundati...
 
Consul: Service Mesh for Microservices
Consul: Service Mesh for MicroservicesConsul: Service Mesh for Microservices
Consul: Service Mesh for Microservices
 
6. The grid-COMPUTING OGSA and WSRF
6. The grid-COMPUTING OGSA and WSRF6. The grid-COMPUTING OGSA and WSRF
6. The grid-COMPUTING OGSA and WSRF
 
07 advanced topics
07 advanced topics07 advanced topics
07 advanced topics
 
Web services
Web servicesWeb services
Web services
 
Java Network Programming.pptx
Java Network Programming.pptxJava Network Programming.pptx
Java Network Programming.pptx
 
Wcf
Wcf Wcf
Wcf
 
WCF 4 Overview
WCF 4 OverviewWCF 4 Overview
WCF 4 Overview
 

Más de Dhananjay Kumar

Slides of webinar Kendo UI and Knockout.js
Slides of webinar Kendo UI and Knockout.jsSlides of webinar Kendo UI and Knockout.js
Slides of webinar Kendo UI and Knockout.jsDhananjay Kumar
 
Presenter deck icenium hol
Presenter deck   icenium holPresenter deck   icenium hol
Presenter deck icenium holDhananjay Kumar
 
Windows azure mobile service
Windows azure mobile serviceWindows azure mobile service
Windows azure mobile serviceDhananjay Kumar
 
Test studiowebinaraugcodedstep
Test studiowebinaraugcodedstepTest studiowebinaraugcodedstep
Test studiowebinaraugcodedstepDhananjay Kumar
 
Functions and Objects in JavaScript
Functions and Objects in JavaScript Functions and Objects in JavaScript
Functions and Objects in JavaScript Dhananjay Kumar
 
Create Hybrid Mobile Application with Icenium and Kendo UI Mobile
Create Hybrid Mobile Application with Icenium and Kendo UI Mobile Create Hybrid Mobile Application with Icenium and Kendo UI Mobile
Create Hybrid Mobile Application with Icenium and Kendo UI Mobile Dhananjay Kumar
 
Cloud Based Enterprise Apps using Everlive
Cloud Based Enterprise Apps using EverliveCloud Based Enterprise Apps using Everlive
Cloud Based Enterprise Apps using EverliveDhananjay Kumar
 
A Look into Automated Web UI Test
A Look into Automated Web UI TestA Look into Automated Web UI Test
A Look into Automated Web UI TestDhananjay Kumar
 
Windows phone 8 app using Kendo UI
Windows phone 8 app using Kendo UI Windows phone 8 app using Kendo UI
Windows phone 8 app using Kendo UI Dhananjay Kumar
 
Windows aazuremobileservices
Windows aazuremobileservicesWindows aazuremobileservices
Windows aazuremobileservicesDhananjay Kumar
 
Rad controlforwindows25thapril
Rad controlforwindows25thaprilRad controlforwindows25thapril
Rad controlforwindows25thaprilDhananjay Kumar
 
Windows storemindcrcaker23rdmarch
Windows storemindcrcaker23rdmarchWindows storemindcrcaker23rdmarch
Windows storemindcrcaker23rdmarchDhananjay Kumar
 

Más de Dhananjay Kumar (20)

Slides of webinar Kendo UI and Knockout.js
Slides of webinar Kendo UI and Knockout.jsSlides of webinar Kendo UI and Knockout.js
Slides of webinar Kendo UI and Knockout.js
 
Nodejsvs
NodejsvsNodejsvs
Nodejsvs
 
Node.js
Node.jsNode.js
Node.js
 
No SQL with Kendo UI
No SQL with Kendo UI No SQL with Kendo UI
No SQL with Kendo UI
 
Patterns in JavaScript
Patterns in JavaScriptPatterns in JavaScript
Patterns in JavaScript
 
Presenter deck icenium hol
Presenter deck   icenium holPresenter deck   icenium hol
Presenter deck icenium hol
 
Bringbestoinyou
BringbestoinyouBringbestoinyou
Bringbestoinyou
 
Java script
Java scriptJava script
Java script
 
Windows azure mobile service
Windows azure mobile serviceWindows azure mobile service
Windows azure mobile service
 
Test studiowebinaraugcodedstep
Test studiowebinaraugcodedstepTest studiowebinaraugcodedstep
Test studiowebinaraugcodedstep
 
Functions and Objects in JavaScript
Functions and Objects in JavaScript Functions and Objects in JavaScript
Functions and Objects in JavaScript
 
Create Hybrid Mobile Application with Icenium and Kendo UI Mobile
Create Hybrid Mobile Application with Icenium and Kendo UI Mobile Create Hybrid Mobile Application with Icenium and Kendo UI Mobile
Create Hybrid Mobile Application with Icenium and Kendo UI Mobile
 
Cloud Based Enterprise Apps using Everlive
Cloud Based Enterprise Apps using EverliveCloud Based Enterprise Apps using Everlive
Cloud Based Enterprise Apps using Everlive
 
A Look into Automated Web UI Test
A Look into Automated Web UI TestA Look into Automated Web UI Test
A Look into Automated Web UI Test
 
Windows phone 8 app using Kendo UI
Windows phone 8 app using Kendo UI Windows phone 8 app using Kendo UI
Windows phone 8 app using Kendo UI
 
Cross platformmobileapp
Cross platformmobileappCross platformmobileapp
Cross platformmobileapp
 
Windows aazuremobileservices
Windows aazuremobileservicesWindows aazuremobileservices
Windows aazuremobileservices
 
Rad controlforwindows25thapril
Rad controlforwindows25thaprilRad controlforwindows25thapril
Rad controlforwindows25thapril
 
Data asservice
Data asserviceData asservice
Data asservice
 
Windows storemindcrcaker23rdmarch
Windows storemindcrcaker23rdmarchWindows storemindcrcaker23rdmarch
Windows storemindcrcaker23rdmarch
 

Último

Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfSanaAli374401
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...KokoStevan
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterMateoGardella
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Shubhangi Sonawane
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 

Último (20)

Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 

WCF for begineers

  • 1. http://debugmode.net Getting Started with WCF Dhananjay Kumar @debug_mode
  • 2. What definition you get on web ? Service Oriented programming model to develop connected applications SDK to develop and deploy services on windows Unifies the existing suite of .Net distributed technologies into a single programming model. Microsoft Innovation & Practice Team, MSCoE 2
  • 3. Getting Started with WCF Developer Evangelist Telerik Microsoft MVP Mindcracker MVP @debug_mode fb.com/debugmode.net Delhi User Group C-Sharp corner User Group
  • 4. Services and Clients Service Message Client
  • 6. Endpoints Client Service Endpoint Endpoint Message Endpoint
  • 7. End Points A B C E 7
  • 8. End Points Contracts Address Binding End Point 8
  • 9. End Point ADDRESS •Where BINDING •How CONTRACT •What 9
  • 10. Address (A) Every service is associated with a unique address. Location of the Service Address of the Transport Service protocol used in service 10
  • 11. Address (A) Address specifies where the service is residing. This is an URL( Uniform Resource Locator). Address URL identifies , location of the service Address should follow the Web Service Addressing(WS-Addressing) standard. 11
  • 12. Address (A) WS Addressing Scheme Machine Port Path 12
  • 13. Address (A) • This is top level portion of the address. Scheme This is not as same as of protocols. • This identifies the machine name. This Machine can be a public URL or a local identifier • This is port number. This is an optional Port part. • This is used to locate the path. This Path gives path of the service. 13
  • 14. Address (A) • http://localhost:8001/Dell HTTP • http://localhost/Dell • net.tcp://localhost:800/Dell TCP • net.tcp://localhost/Dell • net.msmq/private/MyService MSMQ • Net.msmq/://localhost/Dell • net.pipe://localhost/MyPipe IPC • Net.pipe://localhost.MyService Peer network 14
  • 15. Binding (B) Describes how a service communicates. This specifies which Protocol to be used. This specifies the encoding method to format the message content. This specifies the Security requirements This specifies the message exchange format. This specifies message session mode. Developer could create custom Binding also. 15
  • 16. Binding (B) Transport Protocol Message Encoding Communication Pattern Security Transaction Property Inter Operability 16
  • 17. Binding (B) Choosing Binding No WCF Yes To WCF No Yes Disconnected Calls No Yes Legacy No Yes Cross ASMX Machine WS Basic IPC TCP MSMQ 17
  • 18. Binding (B) Binding Classes Binding Name as of class Transport Encoding Interoperable BasicHttpBinding HTTP/HTTPS Text,MTOM Yes NetTcpBinding TCP Binary No NetPeerBinding P2P Binary No NetNamedPipeBinding IPC Binary No WSHttpBinding HTTP/HTTPS Text,MTOM Yes WSFederationHttpBinding HTTP/HTTPS Text,MTOM Yes WSDualHttpBinding HTTP Text,MTOM Yes NetMsmqBinding MSMQ Binary No MsmqIntegrationBinding MSMQ Binary Yes 18
  • 19. Binding (B) Configuring Binding <endpoint address="Calculator" bindingSectionName="basicProfileBinding" bindingConfiguration="Binding1" contractType="ICalculator" /> <bindings> <basicProfileBinding> <binding configurationName="Binding1" hostnameComparisonMode="StrongWildcard" transferTimeout="00:10:00" maxMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" </binding> </basicProfileBinding> </bindings> 19
  • 20. Service Contract (C) A WCF Contract is a collection of Operations All WCF services exposes contract. This is a platform neutral and standard way to say , what the service will do. Defines , what a Service communicates. 20
  • 21. Contract (C) Types of Contracts Service • Describes which operation client can perform on the services. Contract • Defines which Data Type are passed to and from the services. It provides built- Data in contract for implicit type. Contract • Which error raise by service and how service propagates and handles error to its Fault client. Contract • Allow the service to interact directly with the message . Message contract can Message be typed or un typed. This can be used for interoperability. Contract 21 21
  • 22. Contract (C) Service Contract A Service Contract reflects specific business Describe which operations client can perform Maps CLR types to WSDL 22
  • 23. Contract (C) Service Contract Interfaces are used to explicitly define a Contract Classes may also be used to define a Contract. [ServiceContract] attribute is being used by interface/class to qualify them as a contract. ServiceContract are implicitly public. 23
  • 24. Contract (C) Service Contract // Define a service contract. [ServiceContract(Namespace="http://Microsoft.ServiceModel.Samples")] public interface IDataContractCalculator { [OperationContract] ComplexNumber Add(ComplexNumber n1, ComplexNumber n2); [OperationContract] ComplexNumber Subtract(ComplexNumber n1, ComplexNumber n2); [OperationContract] ComplexNumber Multiply(ComplexNumber n1, ComplexNumber n2); [OperationContract] ComplexNumber Divide(ComplexNumber n1, ComplexNumber n2); } 24
  • 25. Contract (C) Data Contract These are the contractual agreement about the format and structure of the payload data in message exchange between a service and its consumer. Defines which Data types are passed to and from the service. Its specifies CLR type to XML schema. 25
  • 26. Contract (C) Data Contract DataContract are preferred WCF way to enable Serialization. WCF defines implicit contract for built in types like int and string. Developer has to explicitly expose complex types as Data Contract. [DataContract] and [DataMember] attribute are used to define a type as Data Contract. 26
  • 27. Contract (C) Data Contract [DataContract] public class ComplexNumber { [DataMember] public double Real = 0.0D; [DataMember] public double Imaginary = 0.0D; } 27
  • 28. Contract (C) Message Contract It gives control over SOAP message structure on both header and body content. Developer can designate optional SOAP headers. It provides additional control over the WSDL generation. It is used to interoperate with another non- WCF service. It is used to control security issue at level of message. 28
  • 29. Contract (C) Fault Contract This translates .Net Exception to SOAP fault propagated to consumer This can be applied to operation only. This is not Inheritable. This can be applied multiple times. This enables developer to declare which faults a given service operation might issue if things goes wrong. 29
  • 30. Creating End Point Could be created declaratively in configuration file. Could be created imperatively through code. Any thing done through code can be done with configuration file and vice versa. It is considered good practice to use configuration file to specify End points. This accommodates changes without recompiling the code. 30
  • 31. Defining Endpoints <?xml version="1.0" encoding="utf-8" ?> <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"> <system.serviceModel> <services> <service serviceType="CalculatorService"> <endpoint address="Calculator" bindingSectionName="basicProfileBinding" contractType="ICalculator" /> </service> </services> </system.serviceModel> </configuration>
  • 32. Multiple End Point For service exposed to multiple clients ; it makes sense to specify more than one End point. This enables client to use the endpoint that is most applicable for them. When creating multiple endpoints each client must have unique address If two client uses the same address , error will raise at service load time. 32
  • 33. Multiple End Point • <endpoint address="http://localhost:8890/a" binding="wsHttpBinding" contract="HotsingSamples.IService1"/> • <endpoint address="http://localhost:8000/b" binding="basicHttpBinding" contract="HotsingSamples.IService1"/> • <endpoint address="net.tcp://localhost:8001/c" binding="netTcpBinding" contract="HotsingSamples.IService1"/> 33
  • 34. Hosting WCF services can not exist in void. It must be hosted. WCF services are hosted in windows process called host process. A single host process can host multiple service. A same service can be hosted in multiple host process. 34
  • 35. WCF basic task cycle 1. Defining Service Contract 2. 5. Impleme Building nting Clients Service Contract 3. 4. Configuri Hosting ng Services Services 35
  • 36. DEBUG_MODE http://debugmode.net Dhananjay Kumar