您的位置:首页 > 其它

WCF Notes1 (Basic Concept &Resource)

2011-11-05 23:59 363 查看
Windows Communication Foundation (WCF) enables applications to communicate whether they are on the same computer, across the Internet, or on different application platforms.The Windows Communication Foundation (WCF) application model is designed
to solve the greater part of the communication requirements of any
distributed application. Service-Oritented.

Basic Programming Lifecycle

1.Define the service contract

2.Implement the contract

3.Configure the service by specifying endpoints and other behavior information

4.Host the service

5.Build a client application

A service contract specifies the following:

The operations a contract exposes.

The signature of the operations in terms of messages exchanged.

The data types of these messages.

The location of the operations.

The specific protocols and serialization formats that are used to support successful communication with the service.

Configuring Services

This is where you define and customize how your service is exposed to clients, including specifying the address where it can be found, the transport and message encoding it uses to send and receive messages, and the type of security it requires.

Bindings are objects that are used to specify the communication details that are required to connect to the endpoint of a Windows Communication Foundation (WCF) service.

What a Binding Defines

Protocols:Determines the security mechanism being used: either reliable messaging capability ortransaction context flow settings.

Encoding:Determines the message encoding (for example, text or binary).

Transport:Determines the underlying transport protocol to use (for example, TCP or HTTP).

Code and Configuration

Note that bindings defined in code are created after bindings specified in configuration, allowing the code-defined bindings to overwrite any configuration-defined
bindings.

Endpoints provide clients access to the functionality that a WCF service offers.

Each endpoint contains:

An address that indicates where to find the endpoint.

A binding that specifies how a client can communicate with the endpoint.

A contract that identifies the methods available.

Securing Services

Security of a Windows Communication Foundation (WCF) service consists of two primary requirements: transfer security and authorization.

transfer security includes authentication (verifying the identity of both the service and the client), confidentiality (message encryption), and integrity (digital signing to detect tampering)

Authorization is the control of access to resources, for example, allowing only privileged users to read a file

ABC

Address=>where

Binding =>how

set characteristics of the transport

potential settings

session reliablility(retries+ordering)

NetTcpBinding

WsHttpBinding

message size

default 64KB

time out

default 45s

security

Transaction

Service contract sets flow on operations

Transaction flow

not allowed(default)

allowed

Mandatory

Service Operation

transactionScopeRequired=true(add into incoming transaction)

Contract=>what

Best Prsctices



set reliability to true
increase message size to 1 mb
set include exceptiom details during development
use per-call for for all service
use single-concurrency for all services
Remember synchronization locjing
use Reentrant for call back only
Avoid circular service calling

Service behaviors

characteristic setting for a service

Debugging

by default, service does not pass error details to client

includeExceptionDetailsInFaults

Instancing

per-call

most scalable and safest setting

every call gets a new instance of service

no concurrency issue

not state

per-session (default)

every proxy gets new instance of services

can save state in class-wide service members

singleton

once instance servers all proxiesfor all clients

state can shared among client

Concurrency:handle locking during multiple calls

Single(default)

service instance allows only one caller in at a time

safest mode

Multiple

multiple calls allow on same instance

WCF stays out of the way with locking

Reentrant

Resource

Getting Started Tutorial
http://msdn.microsoft.com/library/ms734712(VS.100).aspx
Basic WCF Programming
http://msdn.microsoft.com/en-us/library/ms731067.aspx
WCF Troubleshooting Quickstart
http://msdn.microsoft.com/en-us/library/aa702636.aspx
Introduction to Extensibility
http://msdn.microsoft.com/en-us/library/ms789051.aspx
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: