36
Microsoft Visual Studio 2010 Muhammad Zubair MS (FAST-NU) Experience: 5+ Years Contact:- Cell#: +923004446625 Email:- [email protected]

Microsoft Visual Studio 2010

Embed Size (px)

DESCRIPTION

Microsoft Visual Studio 2010. Muhammad Zubair MS (FAST-NU) Experience: 5+ Years Contact:- Cell#: +923004446625 Email:- [email protected]. Introducing Windows Communication Foundation (WCF). Next Generation Connected System on Windows. In this Lecture. - PowerPoint PPT Presentation

Citation preview

MicrosoftVisual Studio 2010

Muhammad ZubairMS (FAST-NU)Experience: 5+ Years

Contact:-Cell#: +923004446625Email:- [email protected]

Introducing Windows Communication Foundation (WCF)•Next Generation Connected System on

Windows

In this Lecture

•Connected Systems Overview•The move towards “Services”•Service-Orientation•Introduction to WCF•WCF Programming model basics•Common WCF Questions

What is Connected Systems?

Development of distributed applications under service-oriented architecture (SOA).

Interface

Interface

An Application that is distributed across multiple computer nodes

WCF

Internet -HTTP

Intranet -TCP

How it works?

What Is Windows Communication Foundation?• .NET Framework provided WCF to build

distributed Applications and services.▫ In older days COM, COM+, DCOM, Web Services

using XML, SOAP, JSON etc

• WCF provides a model with which you can implement services that conform to many commonly-accepted styles and standards, including SOAP, XML, and JSON. Additionally, WCF supports many Microsoft-specific technologies for building components, such as Enterprise Services and Microsoft Message Queue (MSMQ), and supports a unified programming model for many of these technologies.

Windows Communication Foundation

Technologies work within the same network environment , specific to Microsoft family OSsuch as COM, DCOM, COM+, Enterprise Services, and .NET Framework Remoting

Technologies work within the same network environment and over WWWsuch as web services

Windows Communication FoundationMoving towards Services• Market Demand for technology freedom and interoperability is

common now• Services exposes units of functionality via messaging• Interop achived via Standard Protocols and message formats

Application

Windows“I do .NET!”

Service

Linux“I do Java!”

Service

Mainframe“I do Cobol!”

Service

HTTP

HTTP

HTTP

XML

SOAP

RSS

Service Design Philosophies

Service Oriented Architecture Protocol

Representational State Transfer

Typically used in Enterprise

Applications

Typically used in Public Facing Web

Scenarios

SOAP

Transaction

SOAP Format

•Envelope•Header• Security• RM• Transactions

•Body• XML Format

RESTful Services

• RESTful services typically embrace HTTP, the “Web” transport.▫ HTTP methods GET, PUT, POST, or DELETE etc

• Services are modeled as “Resources” as with Unique Identifiers (URI’s)▫ www.myWebsite.com/POST /invoice/123▫ www.myWebsite.com/PUT/invoice/123▫ www.myWebsite.com/GET/invoice/123▫ www.myWebsite.com/DELETE/invoice/123

• Resources can be presented as XML, RSS, JSON etc

SOA (Service Oriented Architecture)

•SOA is a design paradigm for separation of concerns.▫Focused on autonomy, explicit boundaries,

contracts & policies.▫Design principles help achieve a Service

Oriented Architecture.▫SOA says nothing about technology – room

for both SOAP & REST

Windows Communication Foundation

Technologies work within the same network environment , specific to Microsoft family OSsuch as COM, DCOM, COM+, Enterprise Services, and .NET Framework Remoting

Technologies work within the same network environment and over WWWsuch as web services

The Ideal Communication framework

Introducing WCF•WCF namespace

▫System.ServiceModel.dll•Just one way to write the code

Application

Computer 1WCF ServiceWCF Service

Computer 3WCF Service

Computer 2WCF Service

MSMQ

Binary

HTTP

RSS

TCP

SOAP

Distributed Object Style

SOAP based

RESTful Style

Just one way to write code•Interfaces•Services Contracts

Many ways to connect with dots•Endpoints

▫Configure endpoints to different communication options.

Rest over HTTP

SOAP + WS-* over MSMQ

SOAP + WS-*over TCP

Create WCF Service

Create WCF Service•Auto Generated Code

▫Two Service Files Interface Service

▫Interface using namespace “System.ServiceModel”

Define “Service Contract” Define “Operation Contract”

Create WCF Service▫Service

Implement “Interface” in the Service class Write “Operation Contracts” in Service class

Create WCF Service

•System.ServiceModel.Web▫The System.ServiceModel.Web namespace

contains types that you can use to build WCF services

Create WCF Service

•System.Runtime.Serialization ▫WCF uses the classes in the

System.Runtime.Serialization namespace to convert objects into a stream of data suitable for transmitting over the network (a process known as serialization). It also uses them to convert a stream of data received from the network back into objects (deserialization)

Create WCF Service

•Contracts▫Data Contracts

Namespace:- System.Runtime.Serialization Data Member (Expose Members)

▫Service Contracts Namespace:- System.ServiceModel Used in Interface Operation Contract (Expose Operation

Members)▫Operation Contract ▫Method Contract

App.Config•Configure “EndPoints”

Create WCF Service•Service Configuration

Service Configuration

• EndPoints▫ All communication with a Windows Communication

Foundation (WCF) service occurs through the endpoints of the service

▫ Each endpoint consists of four properties: Address

An address that indicates where the endpoint can be found. 

Binding A binding that specifies how a client can communicate

with the endpoint.  Contract

A contract that identifies the operations available.  Behavior

A set of behaviors that specify local implementation details of the endpoint. 

Service Configuration

• Structure of EndPoints▫ Address

The address uniquely identifies the endpoint and tells potential consumers of the service where it is located. It is represented in the WCF object model by the EndpointAddress class. An EndpointAddress class contains: URI Property

http://msdn.microsoft.com/en-us/library/ms733107.aspx

Bindings

Server Side Services

WCF Soap Services

WCF Soap Service Design Style

•Fire and Forget▫One way messaging▫No response.▫No Error response

•Remote Procedure Calls▫Request / Response

•Out of process interactions

WCF vs Web Api• WCF is Microsoft’s unified programming model for

building service-oriented applications. It enables developers to build secure, reliable, transacted solutions that integrate across platforms and interoperate with existing investments.

• ASP.NET Web APIis a framework that makes it easy to build HTTP services that reach a broad range of clients, including browsers and mobile devices. ASP.NET Web API is an ideal platform for building RESTful applications on the .NET Framework. This topic presents some guidance to help you decide which technology will best meet your needs.

WCF vs Web Api