WCFPresentation.ppt WCFPresentation.ppt WCFPresentation.ppt

yatakonakiran2 12 views 20 slides Aug 11, 2024
Slide 1
Slide 1 of 20
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20

About This Presentation

wcf


Slide Content

Agenda
•.NET Framework 3.5 Overview
•Web Services Overview
•Remoting Overview
•WCF Overview
•Elements of WCF & WCF Architecture
•Different Types of WCF Services
•Creating your first WCF Service
•Service Endpoint Configurations
•Service and Data contracts
•Consuming your WCF Service from Clients
•Tools used in creating Proxies

.NET Framework 3.5
Overview

Web Services Overview

Windows Communication
Foundation (WCF)
•WCF is Microsoft’s unified programming model that
combines the best of .NET distributed systems
technologies such as:
- ASP.NET Web Services (ASMX)
- .NET Remoting (Remoting)
- Enterprise Services (COM+)
- Web Services Enhancements (WSE)
- Microsoft Message Queuing (MSMQ)
- Representational State Transfer (REST)

What WCF Provides?
•Unification of Microsoft’s Distributed Computing
Technologies
•Interoperability with Applications Built on Other
Technologies
•Interoperability with Other Web Services Platforms
•Interoperability with Microsoft’s Pre-WCF Technologies
•Explicit Support for Service-Oriented Development
• Framework for building services that process XML
messages
•Allows to transmit messages using different transport
protocols (such as HTTP, TCP, and MSMQ) and using
different XML representations (such as text, binary, or
MTOM)

WCF - Unified
Programming Model

WCF - Unified Programming Model

ABCs of Programming
WCF

WCF End Points

The Structure of an
Endpoint
Address:
The address uniquely identifies the endpoint and
tells potential consumers of the service where it is
located.
EndPoint usingwsHttpBinding
•<add
baseAddress="http://localhost:8550/YourNameSpace.You
rServiceCV/" />
Endpoint using netNamedPipeBinding
•<add
baseAddress="net.pipe://localhost/YourNameSpace.YourS
erviceCV/" />

WCF Bindings
Binding Configuration Element Description
BasicHttpBinding

<basicHttpBinding> A binding that is suitable for communicating with WS-Basic
Profile conformant Web services, for example, ASP.NET Web
services (ASMX)-based services. This binding uses HTTP as
the transport and text/XML as the default message encoding.
WSHttpBinding


<wsHttpBinding>

A secure and interoperable binding that is suitable for non-
duplex service contracts.


WSDualHttpBinding

<wsDualHttpBinding>

A secure and interoperable binding that is suitable for duplex
service contracts or communication through SOAP
intermediaries.
WSFederationHttpBinding

<wsFederationHttpBinding>


A secure and interoperable binding that supports the WS-
Federation protocol that enables organizations that are in a
federation to efficiently authenticate and authorize users.


NetTcpBinding <netTcpBinding>

A secure and optimized binding suitable for cross-machine
communication between WCF applications.
Bindings are used to specify the transport, encoding, and protocol details
required for clients and services to communicate with each other.
To generate the underlying wire representation of the endpoint, most of the
binding details must be agreed upon by the parties that are communicating.

WCF Bindings
Binding Configuration Element Description
NetMsmqBinding


<netMsmqBinding>


A queued binding that is suitable for cross-machine
communication between WCF applications.


NetPeerTcpBinding

<netPeerTcpBinding> A binding that enables secure, multiple machine
communication.

MsmqIntegrationBinding

<msmqIntegrationBinding>


A binding that is suitable for cross-machine communication
between a WCF application and existing Message Queuing
applications.

BasicHttpContextBinding

<basicHttpContextBinding>

A binding that is suitable for communicating with WS-Basic
Profile conformant Web services that enables HTTP cookies
to be used to exchange context.
NetTcpContextBinding

<netTcpContextBinding>



A secure and optimized binding suitable for cross-machine
communication between WCF applications that enables SOAP
headers to be used to exchange context.


WebHttpBinding

<webHttpBinding> A binding used to configure endpoints for WCF Web services
that are exposed through HTTP requests instead of SOAP
messages.
WSHttpContextBinding

<wsHttpContextBinding>

A secure and interoperable binding that is suitable for non-
duplex service contracts that enables SOAP headers to be
used to exchange context.
CustomBinding Developer decides Developer decides

Steps for Creating WCF
Services
•Design and Implement WCF Services
- [ServiceContract] & [ServiceBehavior]
- [OperationContract] & [OperationBehavior]
- [DataContract] & [DataMember]
- [MessageContract] & [MessageHeader] &
[MessageBodyMember]
- [FaultContract]
•Configure WCF Services
- web.config or app.config
- Endpoint details: Address, Binding & Contract
(SvcConfigEditor.exe)

ServiceContract
 Use the ServiceContract attribute on an interface
(or class) to define a service contract.
 ServiceContract combined with an endpoint and
address exposes the service to the client
 Service class will implement a ServiceContract –
Implementing the interface marked with
ServiceContract attribute
Example:-
[ServiceContract]
public interface IMyFirstService
{
//TODO : Define your Operations here
}

OperationContract
 OperationContract attribute is used in the class
(or interface) methods to define the contract's
service operations
 OperationContract exposes the service operation
to the client
 All Service Operations (methods) to be exposed
to the clients should be marked with
OperationContract attribute
Example:-
[ServiceContract]
public interface IMyFirstService
{
[OperationContract]
string GetData(int value);
}

DataContract &
DataMember
 Agreement between the client and the service
that describes the data to be exchanged
 DataContract Serializer to serialize and de-
serialize data
Serialize and De-Serialize is nothing but
converting the data to and from xml
 In order to tell the serialization engine, we need
to use DataContract attribute as a prefix for the
class and DataMember attribute prefix for the
property(data member)

Demo:
Building WCF Service

•WCF Architecture:
http://msdn2.microsoft.com/en-us/library/aa4802
10.aspx
•Basic WCF Programming:
http://msdn2.microsoft.com/en-us/library/ms731
067.aspx
•WS-* Protocols: http://msdn2.microsoft.com/en-
us/library/ms951274.aspx
•WCF Bindings : http://msdn.microsoft.com/en-
us/magazine/cc163394.aspx
References

Questions
Tags