U2u Wcf - Introduction

  • June 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View U2u Wcf - Introduction as PDF for free.

More details

  • Words: 665
  • Pages: 43
1

WCF Overview Peter Himschoot [email protected] Blog:http://www.u2u.info/Blogs/Peter

Agenda • Shed some light on the many .NET versions • Understand WCF – Why? – Concepts – Code

• Some features – Client Callbacks – Messaging – JSON

2

A History of .NET Framework

Runtime

Visual Studio

C#

VB.NET

1.0

1.0

2002

1.0

7.0

1.1

1.0

2003

1.0

7.0

2.0

2.0

2005

2.0 (generics)

8.0 (generics)

3.0

2.0

2005

2.0

8.0

2.0

2008

3.0 (LINQ)

9.0 (LINQ)

(WCF,WPF,WF)

3.5

5

Why?

Questions We Hear a Lot… 6

“How should I build service-oriented systems?”

“How can I develop interoperable applications?”

“How can I send messages securely & reliably?”

“What API should I use?”

MS Distributed Technologies .NET 1.0/2.0

• System.Web.Services (ASMX) – XML, HTTP, SOAP/WSDL/XSD – Focused on interop

• System.EnterpriseServices (COM+) – DCOM RPC, TCP – Focused on high-performance transaction processing

• System.Messaging (MSMQ) – Focused on durable transacted messaging

• System.Runtime.Remoting (.NET Remoting) – HTTP or TCP, SOAP or Binary – Tightly coupled to .NET type system

WCF’s goals • Unify the developer experience for building distributed apps – Consistent conceptual model across varying scenarios – Common set of idioms + metaphors that work everywhere

• Scenario parity with the existing stacks – Critical for adoption

• Architectural foundation for the future – – – – – –

WS-* (.NET 3.0) Web-style services (.NET 3.5) Workflow Services (.NET 3.5) Distributed durable workflows Large-scale pub/sub

WCF Fundamentals • Windows Communication Foundation (WCF) – is a runtime for message based communication – development API • for creating systems that send messages between services and clients • unified API across different transport mechanisms

• For applications that communicate with other applications – on the same computer system – on external computer system – in another company accessible over the Internet.

9

10

Concepts

Clients and Services

Client

Service Message

11

Endpoints

Client

Service Message

Endpoint

Endpoint

Endpoint Endpoint

12

Address, Binding, Contract

Client

Service Message

C

B

A

A

B

C

A

B

C

A

B

C

Address

Binding

Contract

Where?

How?

What?

Endpoint 13

Some Standard Bindings

BasicHttpBinding

BP 1.1 TM

WsHttpBinding

WS

TM

WsDualHttpBinding

WS

TM

NetTcpBinding

.NET

TM

NetNamedPipesBinding

.NET

TM

NetMsmqBinding NetPeerTcpBinding

MSMQ TM Peer

TM

T = Transport Security | M = Message Security | O = One-Way Only

15

Coding with VS2008

Create Service Contracts 16

WCF References 17

[ServiceContract] • Defines what the service can do

18

Operation • Operation =

Response =

19

f

(Request)

[DataContract] • Define the message

20

Deeper Example 21

[FaultContract] • Operations can return errors (Fault msg)

• Operations should say so

22

Implement the Service • Add another WCF Service Library – Implementation should be loosely coupled

23

Throwing Errors • FaultException

24

Host the Service • Hosting should be loosely coupled

25

WeatherService.svc <%@ ServiceHost Service="WCF_ServiceImpl.WeatherServiceImpl" %>

26

Web.config • Add service endpoints – Contract – Binding – Address

27

Web.config with endpoint 28

View in Browser… 29

Add Meta Data • Added through behavior

30

Hosting Options • IIS – Or Cassini for development

• Console • Windows application • WAS – Windows Activation Service

• …

31

The WCF Client • Client can be any kind of project – Console, Windows – ASP.NET, Silverlight –…

32

Create the Client • Create client • Then Add Service Reference

33

Add Service Reference 34

App.config • Service reference also add .config

35

Create Proxy 36

From .config

37

Client Callbacks

WCF Message Patterns 38

One Way

Client

Service Request-Reply Duplex (Dual)

• One Way: – Datagram-style delivery

• Request-Reply – Immediate Reply on same logical thread

• Duplex – Reply “later” and on backchannel (callback-style)

Contract: Callback • Client can pass callback interface

• Client becomes server

• Only possible on some bindings – netTcpBinding, wsDualHttpBinding, …

39

Client Proxy Instantiation • Client needs to pass itself to proxy • Typically implemented by a class

40

Server-side Callback • Callback is passed in OperationContext

41

42

Messaging

43

ASP.NET, JSON, Silverlight

Related Documents

Wcf Introduction Lab
October 2019 8
Wcf
November 2019 12
Wcf
May 2020 4
Wcf Presentation
October 2019 7
Wcf Overview
November 2019 6