wcf - windows communication foundation - cvut.cz · pdf filewcf - windows communication...

31
WCF - Windows Communication Foundation MARTIN MUDRA

Upload: lamkhuong

Post on 16-Mar-2018

225 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: WCF - Windows Communication Foundation - cvut.cz · PDF fileWCF - Windows Communication Foundation ... Oracle WebLogic Server (SE / EE) Oracle Database ... Transaction support No Yes

WCF - Windows Communication FoundationMARTIN MUDRA

Page 2: WCF - Windows Communication Foundation - cvut.cz · PDF fileWCF - Windows Communication Foundation ... Oracle WebLogic Server (SE / EE) Oracle Database ... Transaction support No Yes

WCFFramework for web services and communication

Part of .NET framework

Service contract

Other contracts

Attributes

[ServiceContract]public interface ISampleService{

[OperationContract]string SayHello(string name);

[OperationContract]List<Car> GetAllCars();

//this method will not be visiblestring OtherMethod();

}

Page 3: WCF - Windows Communication Foundation - cvut.cz · PDF fileWCF - Windows Communication Foundation ... Oracle WebLogic Server (SE / EE) Oracle Database ... Transaction support No Yes

WCF Data serializationJson

Xml

DataContract◦ XML

MessageContract◦ SOAP message structure

Binary serialization [MessageContract]public class UserContract{

[MessageHeader]public string FileName { get; set; }

[MessageBodyMember]public Stream FileData { get; set; }

}

[DataContract]public class UserContract{

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

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

}

Page 4: WCF - Windows Communication Foundation - cvut.cz · PDF fileWCF - Windows Communication Foundation ... Oracle WebLogic Server (SE / EE) Oracle Database ... Transaction support No Yes

WCF IIEndpoint

Binding◦ basicHttpBinding◦ webHttpBinding

◦ Attributes WebInvoke | WebGet

◦ mexHttpBinding◦ WSDL

◦ netTcpBinding◦ Duplex contracts

◦ Many others…

Behavior

◦ Service behavior◦ Exceptions, metadata…

◦ Endpoint behavior

Web Service(.NET)

Android

Endpoint

Endpoint

Endpoint

Windows(.NET)

Windows(.NET)

Linux (java)

XML + HTTP + SSL

Page 5: WCF - Windows Communication Foundation - cvut.cz · PDF fileWCF - Windows Communication Foundation ... Oracle WebLogic Server (SE / EE) Oracle Database ... Transaction support No Yes

WCF ConfigurationApp / web config

◦ system.serviceModel

◦ Different port numbers◦ Endpoint settings

◦ IIS settings

In code

<service name="MyService"behaviorConfiguration="MyServiceBehavior">

<endpoint address=""binding="basicHttpBinding"contract="WA2.IServiceContract"/>

<endpoint address="secure"binding="wsHttpBinding"contract="WA2.IServiceContract" />

<endpoint address="mex"binding="mexHttpBinding"contract="IMetadataExchange" />

... </service>

Page 6: WCF - Windows Communication Foundation - cvut.cz · PDF fileWCF - Windows Communication Foundation ... Oracle WebLogic Server (SE / EE) Oracle Database ... Transaction support No Yes

WCF clientsConfiguration in App / Web .config

ClientBase<T> / ChannelFactory

WSDL

Service reference

SVCUtil.exe

public class MyServiceClient :ClientBase<IServiceContract>, IServiceContract

{public void SayHello(string name){

try{Channel.SayHello(name)

}catch EXCEPTIONS ???{

}}

Page 7: WCF - Windows Communication Foundation - cvut.cz · PDF fileWCF - Windows Communication Foundation ... Oracle WebLogic Server (SE / EE) Oracle Database ... Transaction support No Yes

Stream basicsGeneric view of sequence of bytes

Basic Operations◦ Read

◦ Write

◦ Seek

◦ Length

◦ Position

byte[] buffer = new byte[4 * 1024]; int bytesRead; while ((bytesRead = input.Read(buffer, 0, buffer.Length)) > 0) {

output.Write(buffer, 0, bytesRead); }

Page 8: WCF - Windows Communication Foundation - cvut.cz · PDF fileWCF - Windows Communication Foundation ... Oracle WebLogic Server (SE / EE) Oracle Database ... Transaction support No Yes

Microsoft AzureMARTIN MUDRA

Page 9: WCF - Windows Communication Foundation - cvut.cz · PDF fileWCF - Windows Communication Foundation ... Oracle WebLogic Server (SE / EE) Oracle Database ... Transaction support No Yes

Business OverviewServer room

IT administrators

Networking

Storage / RAID

Many services & sites hosted on Windows Server / Linux

SQL Server

NoSQL databases

Page 10: WCF - Windows Communication Foundation - cvut.cz · PDF fileWCF - Windows Communication Foundation ... Oracle WebLogic Server (SE / EE) Oracle Database ... Transaction support No Yes

IAAS / PAAS / SAASOn-premise

Applications

Data

Runtime

Middleware

O/S

Virtualization

Servers

Storage

Networking

Property

IAAS

Applications

Data

Runtime

Middleware

O/S

Virtualization

Servers

Storage

Networking

Property

PAAS

Applications

Data

Runtime

Middleware

O/S

Virtualization

Servers

Storage

Networking

Property

SAAS

Applications

Data

Runtime

Middleware

O/S

Virtualization

Servers

Storage

Networking

Property

Page 11: WCF - Windows Communication Foundation - cvut.cz · PDF fileWCF - Windows Communication Foundation ... Oracle WebLogic Server (SE / EE) Oracle Database ... Transaction support No Yes

Azure as IAASWindows

Linux

SQL Server

SharePoint

Oracle Software

Networking◦ Inbound free

◦ Outbound by regions◦ ~21 GB US / EU

◦ ~15 GB Asia / Japan

◦ ~13 GB Brazil

Instance sizes

Page 12: WCF - Windows Communication Foundation - cvut.cz · PDF fileWCF - Windows Communication Foundation ... Oracle WebLogic Server (SE / EE) Oracle Database ... Transaction support No Yes

Azure Virtual machines with softwareOracle Software

◦ Java (SE)

◦ Oracle WebLogic Server (SE / EE)

◦ Oracle Database (SE/EE)

Microsoft Software◦ SQL Server

◦ BizTalk Server (Software integration & automation of business processes)

Linux

Page 13: WCF - Windows Communication Foundation - cvut.cz · PDF fileWCF - Windows Communication Foundation ... Oracle WebLogic Server (SE / EE) Oracle Database ... Transaction support No Yes

Azure as PAASCompute

◦ Web roles

◦ Web Sites

◦ Worker roles

◦ Batch

◦ Scheduler

◦ HDInsight

Messaging◦ Microsoft Azure Service bus

◦ Queues

Integration◦ Backup

◦ Site recovery

Storage & persistence◦ Azure SQL

◦ Storage service

◦ Redis cache

Others◦ Notification hubs

◦ Event hubs

◦ Azure Multi-Factor Authentication

◦ Active Directory

◦ Monitoring

◦ Virtual network

◦ Synchronization

Page 14: WCF - Windows Communication Foundation - cvut.cz · PDF fileWCF - Windows Communication Foundation ... Oracle WebLogic Server (SE / EE) Oracle Database ... Transaction support No Yes

Web sitesPlatform for enterprise web sites

Automatic backup + rollback

Auto scaling

Continuous integration (VSO, GitHub, BitBucket…)

No direct access to instance

Faster deployment

Web jobs – periodically running scripts (cmd, ps1, sh, py, js, jar…)

Preconfigured sites and CMS frameworks

Page 15: WCF - Windows Communication Foundation - cvut.cz · PDF fileWCF - Windows Communication Foundation ... Oracle WebLogic Server (SE / EE) Oracle Database ... Transaction support No Yes

Web rolesVirtual server instance

◦ Install own software

Preconfigured Windows Server with IIS

Direct access to instance

Health monitoring & alerts

Autoscale

Disk space

ASP.NET

WCF

Client

Client

Client

LoadBalacer

Web role

Web role

Web role

Web role

Page 16: WCF - Windows Communication Foundation - cvut.cz · PDF fileWCF - Windows Communication Foundation ... Oracle WebLogic Server (SE / EE) Oracle Database ... Transaction support No Yes

Worker rolesVirtual server instance

Background processing

Preconfigured Windows Server

Autoscale

Avoids a single point of hardware failure

Automatic recycling

“Windows service” in the cloud

Starting

RunUnhealthy

Recycling

Page 17: WCF - Windows Communication Foundation - cvut.cz · PDF fileWCF - Windows Communication Foundation ... Oracle WebLogic Server (SE / EE) Oracle Database ... Transaction support No Yes

Worker roles IIpublic class ImageConvertorEntryPoint: RoleEntryPoint{

public override bool OnStart(){

//DO SOME STARTUP TASKS}public override void Run(){

//DO SOME HARD WORK}

public override void OnStop(){

//ON STOP WORK}

}

Page 18: WCF - Windows Communication Foundation - cvut.cz · PDF fileWCF - Windows Communication Foundation ... Oracle WebLogic Server (SE / EE) Oracle Database ... Transaction support No Yes

Typical Architecture

Client

Client

PERSISTENT STORAGE

QUEUES

StatelessWebservice(web role)

Client

Processing(Worker

role)

Horizontaly scalable Horizontaly scalable

Page 19: WCF - Windows Communication Foundation - cvut.cz · PDF fileWCF - Windows Communication Foundation ... Oracle WebLogic Server (SE / EE) Oracle Database ... Transaction support No Yes

Interservice communication

Client

Client

Instance1

Client Instance2

Instance N

Rest of the system

Page 20: WCF - Windows Communication Foundation - cvut.cz · PDF fileWCF - Windows Communication Foundation ... Oracle WebLogic Server (SE / EE) Oracle Database ... Transaction support No Yes

Interservice communication

Client

Client

Instance1

Client Instance2Instance

N

Rest of the system

Message system

Page 21: WCF - Windows Communication Foundation - cvut.cz · PDF fileWCF - Windows Communication Foundation ... Oracle WebLogic Server (SE / EE) Oracle Database ... Transaction support No Yes

MessagingCriteria Azure QUEUES Service Bus Queues

Ordering guarantee No Yes – FIFO

Delivery guarantee At-Least-Once At-Least-Once & At-Most-Once

Transaction support No Yes

Receive behavior Non-blocking Blocking with/without timeout (offers long polling, or the “Comet technique”)Non-blocking (through the use of .NET managed API only)

Push-style API No Yes

Receive mode Peek & Lease Peek & LockReceive & Delete

Batched send No Yes

Page 22: WCF - Windows Communication Foundation - cvut.cz · PDF fileWCF - Windows Communication Foundation ... Oracle WebLogic Server (SE / EE) Oracle Database ... Transaction support No Yes

Messaging IIStorage Queues

◦ Zone redundancy

◦ Horizontally scalable

Service bus◦ Deduplication

◦ Scheduled messages

◦ Relays

◦ Topics

◦ Forward To / Send Via

◦ Limited scalability

Page 23: WCF - Windows Communication Foundation - cvut.cz · PDF fileWCF - Windows Communication Foundation ... Oracle WebLogic Server (SE / EE) Oracle Database ... Transaction support No Yes

Message system pricingQueues

◦ Storage space◦ Zone Redundancy

◦ Storage transactions

Service Bus◦ Base charge

◦ Basic operations

◦ Standard operations

◦ Connections

◦ Messages

◦ Relay hours

Page 24: WCF - Windows Communication Foundation - cvut.cz · PDF fileWCF - Windows Communication Foundation ... Oracle WebLogic Server (SE / EE) Oracle Database ... Transaction support No Yes

Queue monitoringLong polling

Comet technique

Push

QUEUES

5 sec

--

-- -- --

Page 25: WCF - Windows Communication Foundation - cvut.cz · PDF fileWCF - Windows Communication Foundation ... Oracle WebLogic Server (SE / EE) Oracle Database ... Transaction support No Yes

Queue monitoring IIPoison queue

Exponential backoff / truncated exponential backoff◦ Expected backoff

QUEUES

QUEUES

StorageService

Page 26: WCF - Windows Communication Foundation - cvut.cz · PDF fileWCF - Windows Communication Foundation ... Oracle WebLogic Server (SE / EE) Oracle Database ... Transaction support No Yes

Scheduler“Windows scheduler”

Periodic tasks◦ Cleanup

◦ Backup

◦ Maintenance

Scalable◦ Free for 3600 job executions / month

◦ Standard◦ Unlimited Jobs

◦ Up to 10 units

◦ Premium◦ Unlimited

Page 27: WCF - Windows Communication Foundation - cvut.cz · PDF fileWCF - Windows Communication Foundation ... Oracle WebLogic Server (SE / EE) Oracle Database ... Transaction support No Yes

Redis CacheLow Latency

High Performance

Secure

Up to 53 GB

Basic◦ Single cache node

◦ Development / test

Standard◦ Replicated two-node

◦ High-availability SLA

Page 28: WCF - Windows Communication Foundation - cvut.cz · PDF fileWCF - Windows Communication Foundation ... Oracle WebLogic Server (SE / EE) Oracle Database ... Transaction support No Yes

Event hubsInternet of things

WCF / REST endpoint

Event types◦ Ingress events

◦ Pricing per million

◦ Egress events◦ Pricing per transfer capacity

Page 29: WCF - Windows Communication Foundation - cvut.cz · PDF fileWCF - Windows Communication Foundation ... Oracle WebLogic Server (SE / EE) Oracle Database ... Transaction support No Yes

Batch - previewLarge-scale parallel and HPC workloads

Automatic task management

Queues

Example scenarios◦ Rendering / analysis

◦ Media transcoding

◦ Image processing

Page 30: WCF - Windows Communication Foundation - cvut.cz · PDF fileWCF - Windows Communication Foundation ... Oracle WebLogic Server (SE / EE) Oracle Database ... Transaction support No Yes

Multi-Factor AuthenticationAuthentication methods

◦ Mobile app notifications◦ Mobile app codes◦ Phone call◦ Text messages

Fraud alert & block/ unblock users

One-time bypass

Cloud & on-premise applications

Pricing◦ Per month / user◦ Per 10 authentications

Page 31: WCF - Windows Communication Foundation - cvut.cz · PDF fileWCF - Windows Communication Foundation ... Oracle WebLogic Server (SE / EE) Oracle Database ... Transaction support No Yes

Key vault - PreviewSecrets

Software keys

HSM Protected keys

Price per operations / per HSM key