Saturday, August 24, 2013

WCF


WCF

Before learning wcf we need to know

Distributed Programing
Communication between multiple server apps or services in the network.
Must be capable to run behind Firewall.
Some share common protocol but not a common platform.

When communication between different platforms than
Heterogeneous Access-àUniversal Access
Performance->Low
Security->Low



When communication between same platform
Heterogeneous Access-àIt is access only through .Net to .Net
Performance->High
Security->High

.Net support for developing Distributed Program
All the distributed technologies speak about the same i.e. consuming of libraries present on remote machines.

We have three concepts
1 Remoting                   
2 Web Services
3 WCF

.NET Remoting
It provides proprietary type of communication.
.NET to .NET

Remoting offers distributed programming between two dot net applications
It is fixed architecture where different customization is provided for development.

In .Net libraries were implemented as Assemblies, where we can consume an assembly residing on local machine by adding its reference. We can now consume Assemblies residing on remote machines also using R emoting.

Architecture





P1 makes a request to a component called Proxy.


Now proxy will take the request with the help of formatter to convert this local call to remote calls. After converting the channel will take & transfer to the remote destination.






Developing a Remoting Application:

-To develop a Remoting Application first we need to understand various things regarding the process of communication, those are:

1. How does both the parties (client and server) exchange information between each other?
Ans: To exchange information between both the parties they make use of a process known as Serialization and Deserialization.

-As applications represent the data in High Level (Object Format) which are not free flow able, needs to be converted into Low Level (Binary or Text) and then transferred to the other system where on the target machine Low Level data has to be converted back into High Level.


-Serializationis a process of converting high level data to low level and De-Serialization is in opposite of serialization that converts low level data to high level.






-To perform serialization & deserialization remoting provides Formatter Classes, those are:

            -Binary Formatters
               -TCPServerChannel
               -TCPClientChannel
            -Soap Formatters
               -HttpServerChannel
               -HttpClientChannel

-Binary Formatters are used for binary serialization and deserialization & Soap Formatters are used for text serialization and deserialization.

Advantages
Any distributed programming developed with remoting libraries will get
Good Performance
Good Security

Drawbacks:
Heterogeneous Environment is not possible with remoting Marsh

2 Web Services
It follows open standards XML Web services.
Firewall Friendly.
.Net to Non .Net Distributed App can be developed.
It is an application which is design as collection of services and can take Http Request process it and gives response as Http Response.
Web Service will only have one formatter that is SOAP
Channel->Http


Architecture



WCF

Unified framework for rapidly building service oriented apps. It is the new way of easily exposing the components.


Architecture



===========================================================

Rules for Developing WCF Service

1       Creating a .Net Component which is compatible to WCF(WCF Runtime Enabled)
To do this WCF provides different classes in the form of attributes, so that we can attach them to our component content. All the libraries and WCF runtime is provided in
System.ServiceModel.dll
System.ServiceModel Namespace
Note: the above .dll is only for the WCF Framework which contains libraries and WCF Runtime.
WCF Recommends interface pattern of development for its service & highly recommended even for normal component development.
Eg:
      [Service Contract]
      Interface IDemo
{
                  //
}
Here [Service Contract] attributes tells us it is a WCF Enabled Component.
Here we are using [Service Contract] attribute because to make .Net Component Distributed.

 [Operation Contract]

To specify methods of service Contract in Service Consumption.
A good service should not have more than 12 [Operation Contract] attributes
We should have at least one [Operation Contract]

2       Every service requires hosting so that it can manage the operating system and other environment related issues.

WCF provides rich hosting options so that user can plan service where good management capabilities
WCF provides the following hosting options

Self-Hosting
Windows Service Hosting
IIS Hosting
Windows Activation Services Hosting [WAS]

3       Endpoints for accessing the service

In WCF Service is exposed to client using end points. Every Client understands as well as communicates with WCF service using Endpoints only

1 Address
 Here we specify the location where our service is available. WCF Follows industry standard addressing pattern, so while writing address instead of .Net style of addressing we have to write W3 style of addressing.

2 Binding
Binding defines how to communicate with service. It includes the Formatter, Channel and other information with just the binding name that we specify.
            For Eg:
Basic Http Binding means SOAP formatter of communication using http channel
            BasicTcpBinding means Binary formatter of communication using Tcp Channel.

3 Contract
This is .Net Type that we provide for client for Request and Response.
Contract -àInterface
WCF will take that interface and give to client.

What is End Point?
It is structure defined with Address+Binding+Contract so that user can communicate with service using this end point information.

Here we are telling that this service should be exposed to client by using those end points

                      

No comments:

Post a Comment

Thank you for visiting my blog

Kubernetes

Prerequisites We assume anyone who wants to understand Kubernetes should have an understating of how the Docker works, how the Docker images...