overview of soa and wcf - jinal desai .net

34
OVERVIEW OF SOA AND WCF J i n a l d e s a i . n e t M y T h o u t h s A n d L e a r n i n g s

Upload: techdigest

Post on 12-Apr-2015

37 views

Category:

Documents


3 download

DESCRIPTION

The presentation contains overview of Service Oriented Architecture (SOA) and Microsoft’s Windows Communication Foundation (WCF). It covers basic things about SOA and WCF. What are the services? What is SOA? Why WCF? How WCF evolved? Such questions are nicely answered in the presentation. It also covers WCF Contracts. Hope you will enjoy it.

TRANSCRIPT

Page 1: Overview of SOA and WCF - Jinal Desai .NET

OVERVIEW OF SOA AND WCF

Jin

ald

es

ai.n

et –

My

Th

ou

ths

An

d L

ea

rnin

gs

Page 2: Overview of SOA and WCF - Jinal Desai .NET

Jin

ald

es

ai.n

et –

My

Th

ou

ths

An

d L

ea

rnin

gs

AGENDA

Overview of Service Oriented Architecture (SOA)

Overview of WCF

Introducing WCF Contracts

Page 3: Overview of SOA and WCF - Jinal Desai .NET

Jin

ald

es

ai.n

et –

My

Th

ou

ths

An

d L

ea

rnin

gs

WHAT IS SERVICES? Service is unit of logic(functionality).

Example of services are placing airline ticket order online or viewing an online bank statement.

Services are loosely coupled. Service interface is independent of

implementation.

Services are reusable.

Page 4: Overview of SOA and WCF - Jinal Desai .NET

Jin

ald

es

ai.n

et –

My

Th

ou

ths

An

d L

ea

rnin

gs

SERVICE CHARACTERISTICS Handles a business process like calculating

insurance quote; or handles relatively technical task like accessing a database; or provides business data and technical details like details needed for constructing GUI.

Service Can access another service for performing it’s task.

Service is relatively independent of other service or software.

Page 5: Overview of SOA and WCF - Jinal Desai .NET

Jin

ald

es

ai.n

et –

My

Th

ou

ths

An

d L

ea

rnin

gs

WHAT IS SOA? Service Oriented Architecture is an evolution

of distributed computing.

It comprises of one or more services.

SOA defines how two computing entities, such as program, interact in such a way as to enable one entity to perform a unit of work on behalf of another entity.

Each interaction is independent of any other interaction or it’s implementation.

Page 6: Overview of SOA and WCF - Jinal Desai .NET

Jin

ald

es

ai.n

et –

My

Th

ou

ths

An

d L

ea

rnin

gs

SOA KEY CHARACTERISTICS SOA services have self-describing interfaces in

platform-independent XML Document(WSDL).

SOA Services communicate with messages formally defined via XML schema(XSD).

SOA services are maintained in the enterprise by a registry that acts as a directory listing(UDDI)

Each SOA service has a quality of service(QoS). Key Qos elements are security requirements, reliable messaging and other policies regarding who can invoke services.

Page 7: Overview of SOA and WCF - Jinal Desai .NET

Jin

ald

es

ai.n

et –

My

Th

ou

ths

An

d L

ea

rnin

gs

STRUCTURE OF SOA

Page 8: Overview of SOA and WCF - Jinal Desai .NET

Jin

ald

es

ai.n

et –

My

Th

ou

ths

An

d L

ea

rnin

gs

STRUCTURE OF SOA The topmost level contains one or more

integration services, each of which controls a flow of activities such as processing an applicant's request. Each integration service invokes one or more business services.

The second level is composed of services that each fulfill a relatively low-level business task.

The third level data access services handles relatively technical task of reading from and writing to data-storage areas such as databases/message queues.

Page 9: Overview of SOA and WCF - Jinal Desai .NET

Jin

ald

es

ai.n

et –

My

Th

ou

ths

An

d L

ea

rnin

gs

DISTRIBUTED APPLICATIONS

Page 10: Overview of SOA and WCF - Jinal Desai .NET

Jin

ald

es

ai.n

et –

My

Th

ou

ths

An

d L

ea

rnin

gs

DISTRIBUTED APPLICATION ON WINDOWS Microsoft shipped many communication

frameworks to achieve connected system environment.

Disadvantages: Each framework comes up with a unique programming

model. Each of these framework can be used only in windows

platform.

Page 11: Overview of SOA and WCF - Jinal Desai .NET

Jin

ald

es

ai.n

et –

My

Th

ou

ths

An

d L

ea

rnin

gs

SERVICES COMMUNICATION Services were used to expose the units of �

functionality via messages.

Page 12: Overview of SOA and WCF - Jinal Desai .NET

Jin

ald

es

ai.n

et –

My

Th

ou

ths

An

d L

ea

rnin

gs

SOAP AND REST To make a service available over http can be �

done by exposing a SOAP based service or using a REST( non SOAP) based service.

SOAP� XML Messaging using SOAP as the format,

enhanced with the WS-* protocols(can be used with any transport protocol). Typically used in enterprise.

REST� Which operates on resources through a unified

interface(HTTP). Typically used in public facing web scenarios.

Page 13: Overview of SOA and WCF - Jinal Desai .NET

Jin

ald

es

ai.n

et –

My

Th

ou

ths

An

d L

ea

rnin

gs

WHAT IS WCF? WCF is the Microsoft next generation �

technology for developing distributed applications.

WCF has been built to facilitate the development of service-oriented applications.

It is a fusion of current distributed system technologies designed and developed with the goal of achieving SOA based development.

Page 14: Overview of SOA and WCF - Jinal Desai .NET

Jin

ald

es

ai.n

et –

My

Th

ou

ths

An

d L

ea

rnin

gs

WHAT IS WCF? WCF is a programming model that enables

developers to build service solutions that are reliable and secure, and even transacted.

It simplifies development of connected applications and offers a unified, simplified, and manageable distributed system development approach.

Page 15: Overview of SOA and WCF - Jinal Desai .NET

Jin

ald

es

ai.n

et –

My

Th

ou

ths

An

d L

ea

rnin

gs

WHAT DOES WCF SOLVE?

Page 16: Overview of SOA and WCF - Jinal Desai .NET

Jin

ald

es

ai.n

et –

My

Th

ou

ths

An

d L

ea

rnin

gs

WHY HANDLE UNIFICATION?

Page 17: Overview of SOA and WCF - Jinal Desai .NET

Jin

ald

es

ai.n

et –

My

Th

ou

ths

An

d L

ea

rnin

gs

UNIFICATION OF DISTRIBUTED TECHNOLOGIES

Page 18: Overview of SOA and WCF - Jinal Desai .NET

Jin

ald

es

ai.n

et –

My

Th

ou

ths

An

d L

ea

rnin

gs

WCF IN .NET FRAMEWORK STACK

Page 19: Overview of SOA and WCF - Jinal Desai .NET

Jin

ald

es

ai.n

et –

My

Th

ou

ths

An

d L

ea

rnin

gs

WCF ARCHITECTURE

At the heart of WCF is a layered architecture that supports a lot of the distributed application development styles. The Layers are:

Contracts Service Runtime Messaging Activation and Hosting

Page 20: Overview of SOA and WCF - Jinal Desai .NET

Jin

ald

es

ai.n

et –

My

Th

ou

ths

An

d L

ea

rnin

gs

WCF LAYERS - CONTRACTS WCF contracts define the functionality of WCF

services.

They are created in code by service developers, and are exposed to clients in the service metadata

The five types of contracts: Service Contracts Operation Contracts Data Contracts Message Contracts Fault Contracts

Page 21: Overview of SOA and WCF - Jinal Desai .NET

Jin

ald

es

ai.n

et –

My

Th

ou

ths

An

d L

ea

rnin

gs

WCF LAYERS - SERVICE RUNTIME The Service Runtime layer is the layer that

specifies and manages the behaviors of the service that occur during service operation, or service runtime.

Some of them are as follows: Metadata Behavior: Controls whether or not

metadata is exposed to the outside world. Instance Behavior: Drives how many instances of

the service will be available to process messages.

Transaction Behavior: Enables transacted operations.

Page 22: Overview of SOA and WCF - Jinal Desai .NET

Jin

ald

es

ai.n

et –

My

Th

ou

ths

An

d L

ea

rnin

gs

WCF LAYERS - MESSAGING The messaging layer defines what formats and

data exchange patterns can be used during service communication.

Client applications can be developed to access this layer and control messaging details and work directly with messages and channels.

Some of the Channels and components are as follows: HTTP Channel TCP Channel MSMQ Channel

Page 23: Overview of SOA and WCF - Jinal Desai .NET

Jin

ald

es

ai.n

et –

My

Th

ou

ths

An

d L

ea

rnin

gs

WCF LAYERS – ACTIVATION & HOSTING In its final form, a service is a program. Like other

programs, a service must be run in an executable. This is known as a self-hosted service.

Services can also be hosted, or run in an executable managed by an external agent, such as IIS or Windows Activation Service (WAS). WAS enables WCF applications to be activated automatically when deployed on a computer running WAS.

Services can also be manually run as executable (.exe files). A service can also be run automatically as a Windows service. COM+ components can also be hosted as WCF services.

Page 24: Overview of SOA and WCF - Jinal Desai .NET

Jin

ald

es

ai.n

et –

My

Th

ou

ths

An

d L

ea

rnin

gs

WCF SERVICE FROM THE OUTSIDE

A service is a collection of one or more endpoints.

A service must have at least one endpoint.

An endpoint is the component of the service that communicates with the client and provides the service operations.

Each endpoint has its very own address, which makes it distinguishable from the other endpoints on the service.

Page 25: Overview of SOA and WCF - Jinal Desai .NET

Jin

ald

es

ai.n

et –

My

Th

ou

ths

An

d L

ea

rnin

gs

WCF SERVICE FROM THE INSIDE

Page 26: Overview of SOA and WCF - Jinal Desai .NET

Jin

ald

es

ai.n

et –

My

Th

ou

ths

An

d L

ea

rnin

gs

WCF CONTRACTS – SERVICE CONTRACTS A service contract defines the operations that

a service supports, and maps to a portType in Web Service Description Language (WSDL).

Service contracts are implemented as .NET Framework interfaces that are annotated with the ServiceContract attribute.

[ServiceContract]public interface IBookOrder { … }

Page 27: Overview of SOA and WCF - Jinal Desai .NET

Jin

ald

es

ai.n

et –

My

Th

ou

ths

An

d L

ea

rnin

gs

WCF CONTRACTS – OPERATION CONTRACTS

Operation contracts define the individual operations that a service supports and map to operations in WSDL.

Operations are defined by adding methods to a Service Contract interface that is annotated with the OperationContract attribute.

[OperationContract]void SomeOperation();

Page 28: Overview of SOA and WCF - Jinal Desai .NET

Jin

ald

es

ai.n

et –

My

Th

ou

ths

An

d L

ea

rnin

gs

WCF CONTRACTS – DATA CONTRACTS A data contract is a formal agreement between a service

and a client that abstractly describes the data to be exchanged.

Data contract can be explicit or implicit. Simple type such as int, string etc has an implicit data contract. User defined object are explicit or Complex type, for which you

have to define a Data contract using [DataContract] and [DataMember] attribute.

[DataContract]Class Employee {

[DataMember]public string FirstName { get; set; }

[DataMember]public string LastName { get; set; }

}

Page 29: Overview of SOA and WCF - Jinal Desai .NET

Jin

ald

es

ai.n

et –

My

Th

ou

ths

An

d L

ea

rnin

gs

WCF CONTRACTS – MESSAGE CONTRACTS Message: Message is the packet of data which contains

important information. WCF uses these messages to transfer information from Source to destination.

Message Pattern: It describes how the programs will exchange message with each other. It can be Simplex – one way communication, Request/Reply – two way communication but at a time only one can send a message and Duplex – two way communication both source and destination can send message simultaneously.

In most of the cases WCF will automatically take care of message, but at some point developer will also require control over the SOAP message format. In that case WCF provides Message Contract to customize the message as per requirement.

Page 30: Overview of SOA and WCF - Jinal Desai .NET

Jin

ald

es

ai.n

et –

My

Th

ou

ths

An

d L

ea

rnin

gs

WCF CONTRACTS – MESSAGE CONTRACTS The most common scenario for this is inserting custom

SOAP headers. Another common scenario is to define security properties for the message’s headers and body, that is, to decide whether these elements are digitally signed and encrypted.

WCF supports either RPC(Remote Procedure Call) or Message style operation model.

In the RPC model, you can develop operation with Ref and out parameter. WCF will automatically create the message for operation at run time.

In Message style operation WCF allows to customize the message header and define the security for header and body of the message.

Page 31: Overview of SOA and WCF - Jinal Desai .NET

Jin

ald

es

ai.n

et –

My

Th

ou

ths

An

d L

ea

rnin

gs

WCF CONTRACTS – MESSAGE CONTRACTS Defining Message Contracts: Message contract can be

applied to type using MessageContract attribute. Custom header and body can be included to message using MessageHeader and MessageBodyMember attribute.

[MessageContract]public class EmployeeDetails {

[MessageHeader] public string EmpID; [MessageBodyMember] public string Name; [MessageBodyMember] public string Designation;

}

Page 32: Overview of SOA and WCF - Jinal Desai .NET

Jin

ald

es

ai.n

et –

My

Th

ou

ths

An

d L

ea

rnin

gs

WCF CONTRACTS – FAULT CONTRACTS By default when we throw any exception from

service, it will not reach the client side.

WCF provides the option to handle and convey the error message to client from service using SOAP Fault contract.

SOAP faults are message types that are included in the metadata for a service operation and, therefore, create a fault contract that clients can use to make their operation more interactive. In addition, because SOAP faults are expressed to clients in XML form, they are highly interoperable.

Page 33: Overview of SOA and WCF - Jinal Desai .NET

Jin

ald

es

ai.n

et –

My

Th

ou

ths

An

d L

ea

rnin

gs

WCF CONTRACTS – FAULT CONTRACTSFault Contract Example:

[ServiceContract()] public interface IService { [OperationContract] [FaultContract

(typeof(MyFaultException))] string GetMessage(); }

[DataContract] public class MyFaultException

{ private string _reason;  [DataMember] public string Reason { get { return _reason; } set { _reason = value; } } }

Page 34: Overview of SOA and WCF - Jinal Desai .NET

THANKS

Jin

ald

es

ai.n

et –

My

Th

ou

ths

An

d L

ea

rnin

gs