wwf/wcfbillatnapier.com/wwf_wfc_ppt.pdf · n s t a t e f u l f i r e w a l l n e t w o r k s e c u...

Post on 07-Mar-2018

226 Views

Category:

Documents

5 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Author: Prof Bill Buchanan

.NE

T F

ram

ew

ork

Name: Prof Bill Buchanan, C63

Email: w.buchanan@napier.ac.uk

Leader: Centre for Dist. Comp. & Security

Aims: WWF/WCF

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Author: Prof Bill Buchanan

.NE

T F

ram

ew

ork

Windows Workflow Foundation

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WW

F.N

ET

Fra

me

wo

rk

What’s in it?

Common

workflow

technology

Process-

oriented view

of software

development

State machine

workflows

Sequential

workflows

Windows

Workflow

Foundations

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WW

F.N

ET

Fra

me

wo

rk

Workflow methodology

Traditional codingWorkflow creation

Trace for sequential and event-

driven code to make sure it is

working correctly

Define the flow of activities, either

for sequential flow or state-based

Activity 1

Activity 2

Activity n

Integrate activitiesCall methods

Create instances

Declare classes and methods

Write code

namespace WorkflowConsoleApplication4_state{

private void codeActivity5_ExecuteCode(object sender) { Console.WriteLine("Pass"); }

}}

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WW

F.N

ET

Fra

me

wo

rk

Sequential workflow

Pick-up phone

Dial number

Wait for answer

Answer?

Hungry?

Yes

End

Start

No

Order pizza

Yes

Take order

Order acceptedNo

Yes

End

Get ingredients

Handover pizza

End

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WW

F.N

ET

Fra

me

wo

rk

State-machine workflow

User is hungry

Start

Handover pizza

End

Order pizza

Take orderRe-order pizzaAccept

call

No answer

Make pizza

Pizza

ready

Order

successfu

l

Accept

call

EndNo

answer

Delivery pizza

Address found

Get rid of

pizza

Address

not found

End

Pizza

wanted

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WW

F.N

ET

Fra

me

wo

rk

Workflow types

Sequential

Workflow LibrarySharePoint State

Machine

SharePoint

Sequential

Workflow

State Machine

Workflow Library

Sequential Console

Application

State Machine

Workflow Console

Application

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WW

F.N

ET

Fra

me

wo

rk

Workflow layered architecture

· Workflows.

· Rules.

· Built-in activities.

· Custom activities.

· Workflow execution (Rules, tracking and scheduling).

· Workflow lifecycle (State, activation).

· Communication.

· Persistence.

· Tracking.

· Timer.

· Transactions.

· Threading.

Workflow Model

Layer

Runtime Layer

Hosting Layer

Host process

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WW

F.N

ET

Fra

me

wo

rk

Workflow layered architecture

· Workflows.

· Rules.

· Built-in activities.

· Custom activities.

· Workflow execution (Rules, tracking and scheduling).

· Workflow lifecycle (State, activation).

Workflow Model

Layer

Runtime Layer

WorkflowRuntime workflowRuntime = new WorkflowRuntime();

workflowRuntime.WorkflowCompleted += OnWorkflowCompleted;

workflowRuntime.StartRuntime();

WorkflowInstance workflowInstance =

workflowRuntime.CreateWorkflow(typeof(ActivityLibrary1.Activity1));

workflowInstance.Start();

Namespace Class

Event

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Author: Prof Bill Buchanan

.NE

T F

ram

ew

ork

Sequential WF

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WW

F.N

ET

Fra

me

wo

rk

When sequential?

Workflow has well-defined

stimulus's, which use well

structured methods to catch

them

When the sequence of

activities is well-known, and

follow a defined sequence

When the workflow does not

have any unexpected

changes in operation

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WW

F.N

ET

Fra

me

wo

rk

Sequential WF

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WW

F.N

ET

Fra

me

wo

rk

Sequential WF

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WW

F.N

ET

Fra

me

wo

rk

What’s required?

public sealed partial class Workflow1: SequentialWorkflowActivity

{

int i;

public Workflow1()

{

InitializeComponent();

}

private void codeActivity1_ExecuteCode(object sender, EventArgs e)

{

Console.WriteLine("Value less than 5");

Console.ReadLine();

}

private void codeActivity1_ExecuteCode_1(object sender, EventArgs e)

{

Console.WriteLine("Enter i>>");

i = Convert.ToInt32(Console.ReadLine());

}

private void codeActivity3_ExecuteCode(object sender, EventArgs e)

{

Console.WriteLine("Value greater than 5");

Console.ReadLine();

}

private void delayActivity1_InitializeTimeoutDuration(object sender, EventArgs

e)

{

}

}

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WW

F.N

ET

Fra

me

wo

rk

Workflow

public sealed partial class Workflow1: SequentialWorkflowActivity

{

ArrayList primes1 = new ArrayList(); bool flag1=false;

ArrayList primes2 = new ArrayList(); bool flag2 = false;

private void codeActivity1_ExecuteCode(object sender, EventArgs e)

{

for (ulong i = 3; i < 100; i++)

{

if (isprime(i)) primes1.Add(i);

}

this.flag1 = true;

}

public bool isprime(ulong val)

{

for (ulong i=2;i<val/2;i++)

{

if ((val % i)==0) return false;

}

return true;

}

private void codeActivity2_ExecuteCode(object sender, EventArgs e)

{

for (ulong i = 100; i < 200; i++)

{

if (isprime(i)) primes2.Add(i);

}

this.flag2 = true;

}

private void codeActivity3_ExecuteCode(object sender, EventArgs e)

{

Console.WriteLine("0-100, No of primes=" + Convert.ToString(primes1.Count));

Console.WriteLine(Convert.ToString(primes1[0]+"..."+Convert.ToString(primes1[primes1.Cou

nt-1])));

Console.WriteLine("100-200, No of primes=" + Convert.ToString(primes2.Count));

Console.WriteLine(Convert.ToString(primes2[0]+"..."+Convert.ToString(primes2[primes2.Cou

nt-1])));

Console.ReadLine();

flag1 = false;

}

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WW

F.N

ET

Fra

me

wo

rk

Calling Workflow from another application

namespace ActivityLibrary1

{

public partial class Activity1: SequenceActivity

{

public ulong max=100;

public ArrayList primes1 = new ArrayList();

public bool flag1 = false;

public int primes

{

get { return primes1.Count; }

}

public object setmax

{

set { this.max = (ulong)value; }

get { return this.max; }

}

public Activity1()

{

InitializeComponent();

}

private void codeActivity1_ExecuteCode(object sender, EventArgs e)

{

for (ulong i = 3; i < this.max; i++)

{

if (isprime(i)) primes1.Add(i);

}

this.flag1 = true;

}

public bool isprime(ulong val)

{

for (ulong i = 2; i < val / 2; i++)

{

if ((val % i) == 0) return false;

}

return true;

}

}

}

Dictionary <string,object> parameters =

new Dictionary<string,object>();

parameters.Add("setmax", (ulong)400);

WorkflowInstance workflowInstance =

workflowRuntime.CreateWorkflow(

typeof(ActivityLibrary1.Activity1), parameters);

workflowInstance.Start();

void OnWorkflowCompleted(object sender,

WorkflowCompletedEventArgs e)

{

primes = (int)e.OutputParameters["primes"];

max = (ulong)e.OutputParameters["setmax"];

flag1 = true;

}

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WW

F.N

ET

Fra

me

wo

rk

Calling Workflow from another application

namespace ActivityLibrary1

{

public partial class Activity1: SequenceActivity

{

public ulong max=100;

public ArrayList primes1 = new ArrayList();

public bool flag1 = false;

public int primes

{

get { return primes1.Count; }

}

public object setmax

{

set { this.max = (ulong)value; }

get { return this.max; }

}

public Activity1()

{

InitializeComponent();

}

private void codeActivity1_ExecuteCode(object sender, EventArgs e)

{

for (ulong i = 3; i < this.max; i++)

{

if (isprime(i)) primes1.Add(i);

}

this.flag1 = true;

}

public bool isprime(ulong val)

{

for (ulong i = 2; i < val / 2; i++)

{

if ((val % i) == 0) return false;

}

return true;

}

}

}

DLL

(Workflow)

Windows

Application

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WW

F.N

ET

Fra

me

wo

rk

Calling Workflow from another application

namespace ActivityLibrary1

{

public partial class Activity1: SequenceActivity

{

public ulong max=100;

public ArrayList primes1 = new ArrayList();

public bool flag1 = false;

public int primes

{

get { return primes1.Count; }

}

public object setmax

{

set { this.max = (ulong)value; }

get { return this.max; }

}

public Activity1()

{

InitializeComponent();

}

private void codeActivity1_ExecuteCode(object sender, EventArgs e)

{

for (ulong i = 3; i < this.max; i++)

{

if (isprime(i)) primes1.Add(i);

}

this.flag1 = true;

}

public bool isprime(ulong val)

{

for (ulong i = 2; i < val / 2; i++)

{

if ((val % i) == 0) return false;

}

return true;

}

}

}

DLL

(Workflow)

Windows

Application

Add reference to DLL

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WW

F.N

ET

Fra

me

wo

rk

Calling Workflow from another application

namespace ActivityLibrary1

{

public partial class Activity1: SequenceActivity

{

public ulong max=100;

public ArrayList primes1 = new ArrayList();

public bool flag1 = false;

public int primes

{

get { return primes1.Count; }

}

public object setmax

{

set { this.max = (ulong)value; }

get { return this.max; }

}

public Activity1()

{

InitializeComponent();

}

private void codeActivity1_ExecuteCode(object sender,

EventArgs e)

{

for (ulong i = 3; i < this.max; i++)

{

if (isprime(i)) primes1.Add(i);

}

this.flag1 = true;

}

public bool isprime(ulong val)

{

for (ulong i = 2; i < val / 2; i++)

{

if ((val % i) == 0) return false;

}

return true;

}

}

}

namespace WindowsFormsApplication1

{

public partial class Form1 : Form

{

int primes = 0;

bool flag1 = false;

ulong max = 0;

public Form1()

{

InitializeComponent();

}

private void button1_Click(object sender, EventArgs e)

{

WorkflowRuntime workflowRuntime = new WorkflowRuntime();

workflowRuntime.WorkflowCompleted += OnWorkflowCompleted;

workflowRuntime.StartRuntime();

Dictionary <string,object> parameters = new

Dictionary<string,object>();

parameters.Add("setmax", (ulong)400);

WorkflowInstance workflowInstance =

workflowRuntime.CreateWorkflow(typeof(ActivityLibrary1.Activity1),

parameters);

workflowInstance.Start();

while (flag1 == false)

{

Thread.Sleep(100);

}

this.textBox1.Text = "The number of primes is " +

Convert.ToString(primes)+" and "+Convert.ToString(this.max);

}

void OnWorkflowCompleted(object sender,

WorkflowCompletedEventArgs e)

{

primes = (int)e.OutputParameters["primes"];

max = (ulong)e.OutputParameters["setmax"];

flag1 = true;

}

}

Windows

Application

Start Workflow engine

Define parameters

Start workflow

End of workflow

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Author: Prof Bill Buchanan

.NE

T F

ram

ew

ork

Event-driven WF

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WW

F.N

ET

Fra

me

wo

rk

When event-driven?

The workflow is driven by

external events and/or

influencing entities

Used when there is some

human interaction with a

process involving a delay in

processing or in different

flow of activities

Possible ad-hoc transactions

as opposed to sequential

flows

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WW

F.N

ET

Fra

me

wo

rk

State-based workflow

SetState: Changes the state of the state

machine from one state to another. StateInitialization: Defines

activities that that are executed

when a new state is entered.

EventDriven: Used to define a

transition when a specific

event is received, when in a

given state.

State: Defines a particular state in the

state machine.

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WW

F.N

ET

Fra

me

wo

rk

State-based workflow

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WW

F.N

ET

Fra

me

wo

rk

State-based workflow

private void codeActivity1_ExecuteCode(object sender, EventArgs e)

{

Console.WriteLine("Started...");

}

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WW

F.N

ET

Fra

me

wo

rk

State-based workflow

private void codeActivity2_ExecuteCode(object sender, EventArgs e)

{

do

{

Console.WriteLine("What is the capital of Scotland?");

string input = Console.ReadLine();

if (input == "edinburgh") endexam = true;

else endexam = false;

} while (endexam==false);

}

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WW

F.N

ET

Fra

me

wo

rk

State-based workflow

private void codeActivity3_ExecuteCode(object sender, EventArgs e)

{

Console.WriteLine("You have passed the exam");

Console.ReadLine();

}

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Author: Prof Bill Buchanan

.NE

T F

ram

ew

ork

3.x

Windows Communications

Foundation

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WC

F.N

ET

Fra

me

wo

rk

What’s required?

Service-oriented

Architecture

(Services consumed

by consumers)

Consumer Consumer

Service

Service

Service

Application

Service

Service

Service

Service-oriented

Applications

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WC

F.N

ET

Fra

me

wo

rk

What’s required?

Web

services

.NET

RemotingDistributed

Transactions

Message

Queues

Windows

Communications

Foundations

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WC

F.N

ET

Fra

me

wo

rk

WCF

Distributed

Systems

Service-oriented

Applications (SoA)

Service-oriented

Architecture

A (Address)

B (Binding) – Protocol: SOAP over HTTP,

SOAP over TCP, SOAP over MQ

C (Contract) – Each service exposes a

Contract via an endpoint. URL defined for

endpoint.

Web Service

Web Client

End pointWSDL

Info sent

Message

Queue

Message

Queue

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WC

F.N

ET

Fra

me

wo

rk

Service-oriented

Distributed

Systems

Service-oriented

Applications (SoA)

Service-oriented

Architecture

Boundaries are explicit.

Service compatibility is

determined based on policy.

Services are autonomous

Services share schema and

contract, not class

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WC

F.N

ET

Fra

me

wo

rk

Service-oriented

Service

Service

Intermediate

Client

Client

Message

MessageMessage

Channels, Bindings, Contracts, Behaviours, Addresses and Endpoints.

Dealt with by WCF

Service

MessageMessage

Client

Service

A service becomes

a client

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WC

F.N

ET

Fra

me

wo

rk

5-layer WFC model

Application

Contracts

Runtime

Messaging

Hosting

This can be a range of hosts, such as

for Internet Information Services (IIS)

and starts and stops your services

automatically. Another is executable

files (.EXE) for the services are

started and stopped manually within

the code.

Supports difference channels and

encoders, and thus communication

for services.

This defines the behaviours within

services, which are loaded in this

layer.

In this layer services describe

themselves to clients. It defines data

and message contracts and bindings/

policies.

Applications are located at this layer.

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WC

F.N

ET

Fra

me

wo

rk

Practical Example

Service

Client

Capital(“scotland)

[ServiceContract]

public interface IService

{

[OperationContract]

public string GetCapital(string

Country);

}

ServiceHost svh = new

ServiceHost(typeof(ServiceImplementation));

svh.AddServiceEndpoint(

typeof(Tut1.Contract.IService),

new NetTcpBinding(),

"net.tcp://localhost:8080");

svh.Open();

System.Threading.Thread myCountryServer =

new

System.Threading.Thread(Tut1.Server.Program

.Main);

myCountryServer.IsBackground = true;

myCountryServer.Start();

ChannelFactory<Tut1.Contract.IService> scf;

scf = new

ChannelFactory<Tut1.Contract.IService>(

new NetTcpBinding(),

"net.tcp://localhost:8080");

Tut1.Contract.IService s;

s = scf.CreateChannel();

“edinburgh”

Net.tcp://localhost:8080

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WC

F.N

ET

Fra

me

wo

rk

Practical Example

System.Threading.Thread myCountryServer = new

System.Threading.Thread(Tut1.Server.Program.Main);

myCountryServer.IsBackground = true;

myCountryServer.Start();

System.Threading.Thread.Sleep(100);

ChannelFactory<Tut1.Contract.IService> scf;

scf = new ChannelFactory<Tut1.Contract.IService>(

new NetTcpBinding(),

"net.tcp://localhost:8080");

Tut1.Contract.IService s;

s = scf.CreateChannel();

while (true)

{

Console.Write("Enter a country: ");

string country = Console.ReadLine();

if (country == "") break;

string capital = s.Contact(country);

Console.WriteLine("The capital is " + capital);

}

[ServiceBehavior(InstanceContextMode =

InstanceContextMode.PerCall)]

class ServiceImplementation : Tut1.Contract.IService

{

public string Contact(string Country)

{

Console.WriteLine("Contacting server...");

if (Country == "scotland") return ("edinburgh");

else if (Country == "england") return ("london");

return "Not known";

}

}

public class Program

{

private static System.Threading.AutoResetEvent endServer =

new System.Threading.AutoResetEvent(false);

public static void Main()

{

ServiceHost svh = new

ServiceHost(typeof(ServiceImplementation));

svh.AddServiceEndpoint(

typeof(Tut1.Contract.IService),

new NetTcpBinding(), "net.tcp://localhost:8080");

svh.Open();

Console.WriteLine("Server running");

endServer.WaitOne();

Console.WriteLine("Server shutting down");

svh.Close();

Console.WriteLine("Server stopped");

}

}

using System.ServiceModel;

namespace Tut1.Contract

{

[ServiceContract]

public interface IService

{

[OperationContract]

string Contact(string message);

}

}DLL

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WC

F.N

ET

Fra

me

wo

rk

Practical Example

DLL

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WC

F.N

ET

Fra

me

wo

rk

Practical Example

System.Threading.Thread myCountryServer = new

System.Threading.Thread(Tut1.Server.Program.Main);

myCountryServer.IsBackground = true;

myCountryServer.Start();

System.Threading.Thread.Sleep(100);

ChannelFactory<Tut1.Contract.IService> scf;

scf = new ChannelFactory<Tut1.Contract.IService>(

new NetTcpBinding(),

"net.tcp://localhost:8080");

Tut1.Contract.IService s;

s = scf.CreateChannel();

while (true)

{

Console.Write("Enter a country: ");

string country = Console.ReadLine();

if (country == "") break;

string capital = s.Contact(country);

Console.WriteLine("The capital is " + capital);

}

[ServiceBehavior(InstanceContextMode =

InstanceContextMode.PerCall)]

class ServiceImplementation : Tut1.Contract.IService

{

public string Contact(string Country)

{

Console.WriteLine("Contacting server...");

if (Country == "scotland") return ("edinburgh");

else if (Country == "england") return ("london");

return "Not known";

}

}

public class Program

{

private static System.Threading.AutoResetEvent endServer =

new System.Threading.AutoResetEvent(false);

public static void Main()

{

ServiceHost svh = new

ServiceHost(typeof(ServiceImplementation));

svh.AddServiceEndpoint(

typeof(Tut1.Contract.IService),

new NetTcpBinding(), "net.tcp://localhost:8080");

svh.Open();

Console.WriteLine("Server running");

endServer.WaitOne();

Console.WriteLine("Server shutting down");

svh.Close();

Console.WriteLine("Server stopped");

}

}

using System.ServiceModel;

namespace Tut1.Contract

{

[ServiceContract]

public interface IService

{

[OperationContract]

string Contact(string message);

}

}DLL

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WC

F.N

ET

Fra

me

wo

rk

Practical Example

DLL

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Author: Prof Bill Buchanan

.NE

T F

ram

ew

ork

3.x

Windows Communications

Foundation

top related