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
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
相关文章推荐
- Flink Basic API Concepts 学习笔记&译文
- Android - some basic control & resource operations
- [LeetCode] Basic Calculator & Basic Calculator II
- Some Basic Concepts in Image Steganography
- Hardcoded string "下一步", should use @string resource警告
- 5.2 Android Basic QuickStart Widgets&Other View Date Picker
- 9.template -- basic concepts
- Android studio b Error: No resource found that matches the given name (at 'src' with value '@dra...
- Apache Hadoop YARN – Concepts & Applications
- No resource identifier found for attribute 'paddingEnd' in Package 'android'
- Pattern Discovery Basic Concepts
- flex&java通信错误之一:Server.resource.unavailable
- [resource-]Python 网页爬虫 & 文本处理 & 科学计算 & 机器学习 & 数据挖掘兵器谱
- 6 click Events&A Basic Lifecycle Method
- Error registering bean with name 'dataSource' defined in class path resource
- Windows - "Multiple connections to a server or shared resource by the same user..."
- Error retrieving parent for item: No resource found that matches the given name 'android:TextAppeara
- error: Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCo
- CRS-0215: Could not start resource 'ora.rac3.LISTENER_RAC3.lsnr'
- Hardcoded string "Button", should use @string resource