2. INTRODUCTION
⢠The latest Service Oriented Technology.
⢠Interoperability is the fundamental characteristic.
⢠Provides common platform for all .NET communication.
⢠Successor to all message distribution technologies.
⢠Used by developers to build Service Oriented Applications.
3. WCF vs. WEBSERVICE
Features Web Service WCF
It can be hosted in IIS, windows activation
Hosting It can be hosted in IIS
service, Self-hosting, Windows service
One-way, Request- Response are the One-Way, Request-Response, Duplex are
Operation different operations supported in web different type of operations supported in
service WCF
XML 1.0, MTOM(Message Transmission
Encoding XML 1.0, MTOM, Binary, Custom
Optimization Mechanism), DIME, Custom
Can be accessed through HTTP, TCP,
Transports Can be accessed through HTTP, TCP, Custom
Named pipes, MSMQ,P2P, Custom
Protocols Security Security, Reliable messaging, Transactions
4. END POINT
⢠WCF exposes collection of end points.
⢠End point is a portal for communicating with the world.
⢠End point consists of three components (ABC â Address(where?)-Binding(how?)-Contract(what?)).
ď§ Address â It is a unique URL identifies the location of the service.
http://localhost:8080/ServiceSamples/MyService
[Transport]:// [Machine or Domain]: [Port number]/ [Path]
ď§ Binding â It specifies the protocol to access the service and also an encoding method used to format
the message contents.
E.g. basicHttpBinding, wsHttpBinding . . etc.
ď§ Contract - Collection of operation that specifies what the endpoint will communicate with outside
world.
7. BINDING
⢠Binding will describe how client will communicate with service.
⢠There are 9 standard bindings in WCF
Name Transport Encoding Interoperable
BasicHttpBinding HTTP/HTTPS Text, MTOM Yes
NetTcpBinding TCP Binary No
NetPeerTcpBinding 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
8. CHOOSING A BINDING:
⢠Have to know about client(WCF or NON-WCF) and service(WCF or NON-WCF) to choose binding.
9. BINDING CONFIGURATION USING CONFIG FILE:
⢠We have to add bindingConfiguration tag to
the end point section.
⢠We have to name a customized section in the
binding section of the config file.
11. CONTRACTS
⢠Defines the Structure and Behavior of WCF Service.
⢠The 3 core contracts are:
1. Service Contract - Describe the operation that service can provide.
2. Data Contract - Describes the custom data type which is exposed to the client.
3. Message Contract â Describes the message format for communication during
runtime.
12. SERVICE CONTRACT
⢠Services are group of operations, both classes and interfaces are used for grouping operations.
⢠Operations are defined by creating a method and marking it with OperationContractAttribute attribute.
⢠Service contract is defined by marking a class or interface that group operations(methods) with
ServiceContractAttribute attribute.
DATA CONTRACT
⢠It defines the data types that are passed to and from the WCF service.
⢠It defines how data is serialized and deserialized.
⢠By using Data Contracts we can make client to aware of custom created data types.
13. MESSAGE CONTRACT
⢠Message is the packet data which contains information.
⢠Message Contract is used to customize the message as per the requirement.
⢠WCF uses SOAP(Simple Object Access Protocol) Message format for communication.
⢠Message contract can be applied to type using MessageContract attribute.
⢠Custom Header and Body can be included to message using 'MessageHeader' and 'MessageBodyMemberâ
attribute.
FAULT CONTRACT
⢠WCF provides the option to handle and convey the error message to client from service using SOAP Fault
contract.
⢠Fault Contract provides documented view for error accorded in the service to client.
⢠service defines its fault contracts using the FaultContractAttribute.
14. HOSTING A WCF
SERVICE
⢠WCF service cannot exist on its own, it has to be hosted using a host process.
⢠There are mainly four different ways of hosting the WCF service.
1. IIS Hosting
2. Self Hosting
3. Windows Activation Service
4. Windows Service
15. IIS HOSTING SELF HOSTING WAS WINDOWS SERVICE
IIS automatically launches WCF provides the user to Windows Activation WCF Service starts when
the host process when it host the service in any service is a system the system starts. All
gets the first client application. service available with versions of windows
request. Windows vista and support WCF hosting.
windows server 2008, It
is also available with IIS
7.0
It uses the IIS features Developer is responsible Hosting WCF in Process life time of the
such as process recycling, for providing and Activation service takes service can be controlled
idle shutdown, process managing the life cycle of many advantages such by Service Control
health monitoring and the host process. as process recycling, Manager for windows
message based activation. isolation, idle time service
management and
common configuration
system.
It will only support HTTP It will support almost all It supports Http, TCP It will support almost all
protocol. types of protocols. and named pipes. types of protocols.