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

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

Embed Size (px)

Citation preview

Page 1: Microsoft Visual Studio 2010 Muhammad Zubair MS (FAST-NU) Experience: 5+ Years Contact:- Cell#: +923004446625 Email:- Muhammad.zubair82@yahoo.com

MicrosoftVisual Studio 2010

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

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

Page 2: Microsoft Visual Studio 2010 Muhammad Zubair MS (FAST-NU) Experience: 5+ Years Contact:- Cell#: +923004446625 Email:- Muhammad.zubair82@yahoo.com

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

Windows

Page 3: Microsoft Visual Studio 2010 Muhammad Zubair MS (FAST-NU) Experience: 5+ Years Contact:- Cell#: +923004446625 Email:- Muhammad.zubair82@yahoo.com

In this Lecture

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

Page 4: Microsoft Visual Studio 2010 Muhammad Zubair MS (FAST-NU) Experience: 5+ Years Contact:- Cell#: +923004446625 Email:- Muhammad.zubair82@yahoo.com

What is Connected Systems?

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

Interface

Interface

An Application that is distributed across multiple computer nodes

Page 5: Microsoft Visual Studio 2010 Muhammad Zubair MS (FAST-NU) Experience: 5+ Years Contact:- Cell#: +923004446625 Email:- Muhammad.zubair82@yahoo.com

WCF

Internet -HTTP

Intranet -TCP

How it works?

Page 6: Microsoft Visual Studio 2010 Muhammad Zubair MS (FAST-NU) Experience: 5+ Years Contact:- Cell#: +923004446625 Email:- Muhammad.zubair82@yahoo.com

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.

Page 7: Microsoft Visual Studio 2010 Muhammad Zubair MS (FAST-NU) Experience: 5+ Years Contact:- Cell#: +923004446625 Email:- Muhammad.zubair82@yahoo.com

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

Page 8: Microsoft Visual Studio 2010 Muhammad Zubair MS (FAST-NU) Experience: 5+ Years Contact:- Cell#: +923004446625 Email:- Muhammad.zubair82@yahoo.com

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

Page 9: Microsoft Visual Studio 2010 Muhammad Zubair MS (FAST-NU) Experience: 5+ Years Contact:- Cell#: +923004446625 Email:- Muhammad.zubair82@yahoo.com

Service Design Philosophies

Service Oriented Architecture Protocol

Representational State Transfer

Typically used in Enterprise

Applications

Typically used in Public Facing Web

Scenarios

Page 10: Microsoft Visual Studio 2010 Muhammad Zubair MS (FAST-NU) Experience: 5+ Years Contact:- Cell#: +923004446625 Email:- Muhammad.zubair82@yahoo.com

SOAP

Transaction

Page 11: Microsoft Visual Studio 2010 Muhammad Zubair MS (FAST-NU) Experience: 5+ Years Contact:- Cell#: +923004446625 Email:- Muhammad.zubair82@yahoo.com

SOAP Format

•Envelope•Header• Security• RM• Transactions

•Body• XML Format

Page 12: Microsoft Visual Studio 2010 Muhammad Zubair MS (FAST-NU) Experience: 5+ Years Contact:- Cell#: +923004446625 Email:- Muhammad.zubair82@yahoo.com

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

Page 13: Microsoft Visual Studio 2010 Muhammad Zubair MS (FAST-NU) Experience: 5+ Years Contact:- Cell#: +923004446625 Email:- Muhammad.zubair82@yahoo.com

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

Page 14: Microsoft Visual Studio 2010 Muhammad Zubair MS (FAST-NU) Experience: 5+ Years Contact:- Cell#: +923004446625 Email:- Muhammad.zubair82@yahoo.com

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

Page 15: Microsoft Visual Studio 2010 Muhammad Zubair MS (FAST-NU) Experience: 5+ Years Contact:- Cell#: +923004446625 Email:- Muhammad.zubair82@yahoo.com

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

Page 16: Microsoft Visual Studio 2010 Muhammad Zubair MS (FAST-NU) Experience: 5+ Years Contact:- Cell#: +923004446625 Email:- Muhammad.zubair82@yahoo.com

Just one way to write code•Interfaces•Services Contracts

Page 17: Microsoft Visual Studio 2010 Muhammad Zubair MS (FAST-NU) Experience: 5+ Years Contact:- Cell#: +923004446625 Email:- Muhammad.zubair82@yahoo.com

Many ways to connect with dots•Endpoints

▫Configure endpoints to different communication options.

Rest over HTTP

SOAP + WS-* over MSMQ

SOAP + WS-*over TCP

Page 18: Microsoft Visual Studio 2010 Muhammad Zubair MS (FAST-NU) Experience: 5+ Years Contact:- Cell#: +923004446625 Email:- Muhammad.zubair82@yahoo.com

Create WCF Service

Page 19: Microsoft Visual Studio 2010 Muhammad Zubair MS (FAST-NU) Experience: 5+ Years Contact:- Cell#: +923004446625 Email:- Muhammad.zubair82@yahoo.com

Create WCF Service•Auto Generated Code

▫Two Service Files Interface Service

▫Interface using namespace “System.ServiceModel”

Define “Service Contract” Define “Operation Contract”

Page 20: Microsoft Visual Studio 2010 Muhammad Zubair MS (FAST-NU) Experience: 5+ Years Contact:- Cell#: +923004446625 Email:- Muhammad.zubair82@yahoo.com

Create WCF Service▫Service

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

Page 21: Microsoft Visual Studio 2010 Muhammad Zubair MS (FAST-NU) Experience: 5+ Years Contact:- Cell#: +923004446625 Email:- Muhammad.zubair82@yahoo.com

Create WCF Service

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

contains types that you can use to build WCF services

Page 22: Microsoft Visual Studio 2010 Muhammad Zubair MS (FAST-NU) Experience: 5+ Years Contact:- Cell#: +923004446625 Email:- Muhammad.zubair82@yahoo.com

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)

Page 23: Microsoft Visual Studio 2010 Muhammad Zubair MS (FAST-NU) Experience: 5+ Years Contact:- Cell#: +923004446625 Email:- Muhammad.zubair82@yahoo.com

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

Page 24: Microsoft Visual Studio 2010 Muhammad Zubair MS (FAST-NU) Experience: 5+ Years Contact:- Cell#: +923004446625 Email:- Muhammad.zubair82@yahoo.com
Page 25: Microsoft Visual Studio 2010 Muhammad Zubair MS (FAST-NU) Experience: 5+ Years Contact:- Cell#: +923004446625 Email:- Muhammad.zubair82@yahoo.com

App.Config•Configure “EndPoints”

Page 26: Microsoft Visual Studio 2010 Muhammad Zubair MS (FAST-NU) Experience: 5+ Years Contact:- Cell#: +923004446625 Email:- Muhammad.zubair82@yahoo.com

Create WCF Service•Service Configuration

Page 27: Microsoft Visual Studio 2010 Muhammad Zubair MS (FAST-NU) Experience: 5+ Years Contact:- Cell#: +923004446625 Email:- Muhammad.zubair82@yahoo.com

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. 

Page 28: Microsoft Visual Studio 2010 Muhammad Zubair MS (FAST-NU) Experience: 5+ Years Contact:- Cell#: +923004446625 Email:- Muhammad.zubair82@yahoo.com

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

Page 29: Microsoft Visual Studio 2010 Muhammad Zubair MS (FAST-NU) Experience: 5+ Years Contact:- Cell#: +923004446625 Email:- Muhammad.zubair82@yahoo.com
Page 30: Microsoft Visual Studio 2010 Muhammad Zubair MS (FAST-NU) Experience: 5+ Years Contact:- Cell#: +923004446625 Email:- Muhammad.zubair82@yahoo.com
Page 31: Microsoft Visual Studio 2010 Muhammad Zubair MS (FAST-NU) Experience: 5+ Years Contact:- Cell#: +923004446625 Email:- Muhammad.zubair82@yahoo.com

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.

Page 32: Microsoft Visual Studio 2010 Muhammad Zubair MS (FAST-NU) Experience: 5+ Years Contact:- Cell#: +923004446625 Email:- Muhammad.zubair82@yahoo.com

WCF vs Web Api