WCF Notes1 (Basic Concept &Resource)

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 or transaction 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
  1. set reliability to true 
  2. increase message size to 1 mb
  3. set include exceptiom details during development
  4. use per-call for for all service
  5. use single-concurrency for all services
  6. Remember synchronization locjing
  7. use Reentrant for call back only
  8. 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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值