Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Windows®
Communication
Foundation
Module 7: Improving WCF Service Quality
• Managing WCF Service Instances
Service
Host
[ServiceBehavior(InstanceContextMode=InstanceContextMode.PerCall)]
public class BankService : IBank
Creation, destruction,
Session timeout
data access cycle
Concurrency
[ServiceBehavior(InstanceContextMode=InstanceContextMode.PerSession)]
public class BankService : IBank
Creation, destruction,
Session timeout
data access cycle
Concurrency
[ServiceBehavior(InstanceContextMode=InstanceContextMode.Single)]
public class BankService : IBank
Creation, destruction,
Data security
data access cycle
Lots of concurrency
Allowed
NotAllowed
Required
[ServiceContract(Namespace="http://myuri.org/Simple",
SessionMode=SessionMode.Required)]
public interface IBank
{
...
}
Demonstration: Instance Management
In this demonstration, you will see how to change the
instance management strategy to change the behavior of
service-side objects and state
Notes Page Over-flow Slide. Do Not Print Slide.
See Notes pane.
Lesson: Managing Concurrency Issues
• Concurrency Issues
Intermittent
Difficult to Subtle
reproduce corruption
Two approaches
Multiple
Reentrant
Single
[ServiceBehavior(ConcurrencyMode=ConcurrencyMode.Single)]
public class BankService : IBank
Safest option
No potential for deadlock
Reentrant Threaded Mode
• Single request thread active at any one time
[ServiceBehavior(ConcurrencyMode=ConcurrencyMode.Reentrant)]
public class BankService : IBank
Semi-safe option
Some potential for deadlock
and corruption
Multiple Threaded Mode
• Multiple request threads active at any one time
[ServiceBehavior(ConcurrencyMode=ConcurrencyMode.Multiple)]
public class BankService : IBank
MaxConcurrentCalls
MaxConcurrentInstances
MaxConcurrentSessions
<serviceBehaviors>
<behavior name="bankServiceBehavior">
<serviceThrottling maxConcurrentCalls="1024"
maxConcurrentInstances="1024"
maxConcurrentSessions="10"/>
</behavior>
</serviceBehaviors>
Throttling, Instance Management, and Threading
Service
Threading
Throttling
Mode
Clustering
• Transport sessions
Ongoing connection between client and server
• Implementing Streaming
• Stream Handling
---------------------
MIME Part
SOAP
Envelope
Reference ---------------------
MIME Part
Binary Binary
Binary Data
Data
Data
Enabling MTOM Encoding
<basicHttpBinding>
<binding name="binaryOverHttp" messageEncoding="Mtom"/>
</basicHttpBinding>
Streamed
StreamedRequest
StreamedResponse
<basicHttpBinding>
<binding name="HttpStreaming"
maxReceivedMessageSize="67108864"
transferMode="Streamed"/>
</basicHttpBinding>
Stream Handling
MTOM Streaming
Restricted to 3 bindings
Any binding and security
and transport security
Demonstration: Passing Large Binary Data in WCF
In this demonstration, you will see how to:
• Pass large binary data between client and service by using
MTOM
• Pass large binary data between client and service by using
streaming
Notes Page Over-flow Slide. Do Not Print Slide.
See Notes pane.
Lab: Improving WCF Service Quality
• Exercise 1: Managing WCF Service Instances
Logon information
Password Pa$$w0rd
• Best Practices