SlideShare ist ein Scribd-Unternehmen logo
1 von 62
WCF
Maxime Lemaitre – 30/04/2013
• Introduction
• Basic Concepts
• Going deeper
• What's New in WCF 4/4.5
• Best Practices
• WCF Tools
• Use Cases
2
Agenda
yes, we can !
• I won’t explain you every concepts & components of WCF 
• I will try to educate you to common WCF features and give you some best
practices
• I have included as many links as possible
3
Introduction
Objectives
• WCF (CodeName Indigo) is a unified communication framework in.NET for
building connected, service-oriented applications
• Introduced in .Net 3.0
– Before WCF : ASMX, Remoting, TcpServer, COM, POX…
• Defines a common programming model and unified API for clients and
services to send messages between each other
• Key characteristics
– Service-oriented programming model (SOA):
• Services are offered on an endpoint.
• WCF completely separates service hosting, endpoints and services
– Interoperability with non-WCF web services due to use of SOAP messages
• WCF implements many of the WS-* standards
– Extensibility
• WCF client / server can be configured to interoperate with REST, ATOM-
feeds, plain XML or JSON messages
4
Introduction
Why WCF ?
• To expose our first WCF service, we need
– An Endpoint (WCF’s ABC)
– A Service Implementation
– Some Config
– An Hosting Environnment
5
How to build our first WCF Service
(a very basic service )
• Address : « Where is my service ? »
– The location of the service on the network where it can be reached
• Some examples
– http://localhost/calculatorservice.svc
– net.msmq://localhost/private/calculatorservice
– net.tcp://localhost:6000/calculatorservice
• Set via configuration/code or inherited from Hosting Environment
6
ABC’s of WCF
Give me the A !
• Binding : « How do I talk to this thing? »
– The protocol/policies/settings used to connect to the service at it’s address
• Some examples
– Http(BasicHttp, WsHttp, WsDualHttp, WsFederation)
– NetMsmq
– NetNamedPipe
– NetTcp
– CustomBinding
– …
• Contains
– Transport protocol (HTTP, TCP, MSMQ, …)
– Message encoding (MTOM, XML, JSON, Binary, …)
– Security / reliability settings (encryption & authentication)
– …
• All system provided binding are available here
7
ABC’s of WCF
Give me the B !
• A Binding is an aggregate of micro WCF features
– Security, Duplex, Session, Encoding, Streaming, …
8
ABC’s of WCF
Give me the B !
• Contract : « What’s it going to do for me? »
– Defines the operations, inputs, outputs, and mep of the service.
• In WCF, a Contract is defined by an interface
• A Contract defines
– Grouping of operations in a service => .Net attribute [ServiceContract]
– Signature of operations => .Net attribute [OperationContract]
– Data types of operations => .Net attribute [DataContract]
9
ABC’s of WCF
Give me the C !
10
Our first WCF Service
on the road to Carl …
• Services are designed to run in any Windows process that supports managed
code
– Hosting Options
• Self-Hosting Fast & Flexible but not an enterprise solution
• Windows Service Secure, Supported by all windows but lack of reliable features
• IIS/WAS Components required but all advantages of IIS
• IIS7 (Vista/WS2K8) introduced Windows Activation Service (WAS)
– Host non HTTP protocols in IIS like Net.Tcp, NamedPipe, MSMQ…
• Continue reading here
11
WCF Hosting
How & where do I host my new WCF service ?
IIS Hosting
12
WCF Hosting
examples
Self- Hosting
• A WCF client is used to invoke a WCF Service
– It’s not mandatory but will help you a lot (create SOAP manually ?)
– Translate .Net code to SOAP and vice-versa
– Logic-less implementation of Proxy Design Pattern
• To create a WCF client, you need
– An Address
– A Binding
– A Contract
– Some code
– (extra configuration & settings)
• Clients have to be stateless and disposed when required
13
How to call this Service ?
WCF Clients
• An Automatic WCF Client in 2 clics
• Generate all client code, contract & configuration.
• Best suite if you don’t know the contract
14
WCF Clients
example #1 : Service Reference
• A little more code
• Perfect if you already know the
contract
15
WCF Clients
example #2 : ChannelFactory<T>
• WCF allows use to expose Metadata using standardized protocols
– Metadata ?
• Operations a client perform
• The structure of the data types that the operations work with or return
• Definitions of all the endpoints implemented by the service and the various
options needed for each such as security
=> Basically, how to call the service
• Two ways to expose Metadata
– Mex Endpoint (for all services/bindings)
– Wsdl/Disco (only for http Services)
• Metadata is generally not exposed for production public service
• More info here
16
WCF Metadata
what is it ?
Http(s)GetEnabled
17
WCF Metadata
how to publish metadata
IMexdataExchange
• WCF Supports 3 MEPs
– OneWay
Client sends a message using a fire and forget exchange. Like
UDP, it does not guarantee that the remote endpoint has received
the message . Defined at operation level. Warning : it’s not async !
– Request-Reply (Default)
Client sends a message to a WCF Service and then waits for a reply
(no response = TimeOutException). Client stops processing until the
return message is received. Classic pairs of Request-Response like
in HTTP GET method.
– Duplex
Like a phone conversation, both sides can send and receive
messages. Defined at contract level.
• Continue reading here
18
WCF Messaging
Message Exchange Patterns (MEP)
• In Connected Systems, there is no magic translation and data needs to be
exchanged in a serialized form
• WCF provides 2 Serializer
– DataContractSerializer Opt-in Serialization
• DataContract or Message Contract
– XmlSerializer Opt-out Serialization
=> 2 Serializers to handle all scenarios
• There are also many ways to by-pass serialization
– Using Stream object (for Streaming and Large Data)
– Using Message class (Parsing Soap Message directly)
• More info here
19
WCF Serialization
hidden part
20
WCF Serialization
examples
DataContractSerializer
(DataContract)
DataContractSerializer
(MessageContract)
XmlSerializer
• Scope of WCF Security
– Transfer security
Responsible for providing message confidentiality, data integrity, and authentication of
communicating parties
– Authorization
Responsible for providing a framework for making authorization decisions
– Auditing
Responsible for logging security-related events to the audit log
• Basically WCF Security is managed by Security Configuration
– None
– Transport
– Message
– Both
– TransportWithMessageCredential or TransportCredentialOnly
• All bindings don’t provide the same security features !
• Continue reading here and here
21
WCF Security
do not fear …
Transport Security
User credentials and claims are
passed using the transport layer
 Interoperabable
 Performant & Hardware Accelerated
o Transport-dependant
o Limited set of credentials
o Point to Point com only
22
WCF Security
Message Vs Transport Security
Message Security
User credentials and claims are
encapsulated in every message using
the WS-Security specification
 end-to-end security
 Partial/selective encryption and signing
 Transport-independent
o Limited interoperability (WS-Security)
o Less performant
• Sessions
– A session is a correlation of all messages sent between two endpoints
– this requires a binding that supports sessions
• Instancing
– Refers to controlling the lifetime of user-defined service objects and their related
InstanceContext objects
– Can be
• Per Call : a new service object is created for each client request
• Per Session : a new service object is created and maintained for each client session
• Single : a service object handles all client requests
• Concurency
– Term given to the control of the number of threads executing in an InstanceContext at the
same time
– Can be
• Single : Maximum of one thread processing messages in the instance context at a time
• Multiple : Can have multiple threads processing messages concurrently
• Reentrant : The service instance is single-threaded and accepts reentrant calls (Duplex)
• Continue reading here 23
WCF Concepts
Sessions, Instancing & Concurrency
• WCF is designed to solve the greater part of the
communication requirements, but there are
sometimes scenarios where the default behavior
is not valid.
• WCF is extensible by nature
– You can add or modify system behavior at every
level as you want
– Many shared concepts with AOP
• More than 25 interfaces to implement !
• Must-read blog post and here
24
WCF Extensibility
really powerfull !
25
WCF Extensibility
caching for service operations using IOperationInvoker
• Transaction
• Reliable Messaging
• WCF REST
• Queue Messaging
• Streaming & Large Data
• WCF Tracing
• Async
• Duplex Services
• Workflow Services
• Peer to Peer Networking
• Syndication
• WebSockets
• …
26
Others Features
To be continued …
What’s New in WCF 4 / 4.5 ?
27
• WS-Discovery Support
– Discovery Service
– Announcement feature
• Single WSDL Document
• New Https Binding
• WCF REST Improvements (deprecated)
• Task-based Async/Await Support
• New Configuration Default Values
– Concurrent Calls/sessions/Instances, Net.Tcp settings, Timeouts
• WebSocket Support
– 2 new bindings : NetHttpBinding and NetHttpsBinding
• WCF Configuration Tooltips & Validation on Build
28
What’s new in WCF 4 /4.5 ?
All you need is here and here
WCF 3.0
29
What’s new in WCF 4 /4.5 ?
Simplified Configuration
WCF 4.5
Thanks to standard bindings and protocols mappings !
• Define and activate WCF services without having to maintain physical .svc
30
What’s new in WCF 4 /4.5 ?
File-less Activation
• A generic SOAP intermediary that acts
as a message router
• Features
– Content-based routing
• Header
• Body
– Priority Routing
– Protocol bridging
• Ex : HT¨TP to NetTcp
– Multicast
– Backup & Failover endpoints
– …
• Continue here
31
What’s new in WCF 4 /4.5 ?
Routing Service
WCF Best Practices
32
• When invoking a service, a client should catch 3 types of exceptions
– TimeoutException
thrown when the time allotted for a process or operation has expired (on client or on server)
– CommunicationException
communication error in either the service or client application
– FaultException/FaultException<TDetail>
Represents a SOAP fault
• SOAP-based applications use fault messages to notify processing error
– “Exception” is not an unknown concept and not fully serializable
– Do not throw ArgumentException/ArgumentNullException/… use Faults !
• Exception details are not returned to client unless it has been activated
– Can be a security risk because details expose internal service implementation
– Use only on Dev
• For global Exception handling, there is an IErrorHandler extensibility point
• Continue reading here
33
WCF Best Practices
Exception Management & Fault Contracts
FaultContract is defined on each
operation
Service throws a Fault when there
is an handled/unhandled error
34
WCF Best Practices
FaultContracts sample
Client knows Faults (defined in
Contract) and can have specific
error management
• Always Close the client proxy
– Undisposed proxies can lead to memory leaks and random exceptions
• Close = Dispose in WCF
• Close/Dispose well
– Close can throw exceptions
• More info here
– http://stackoverflow.com/questions/573872/
– http://msdn.microsoft.com/en-us/library/aa355056.aspx
35
WCF Best Practices
Dispose well, Padawan !
• Running a test against a running WCF service is not unit testing, but
integration testing.
– Note : Testing WCF aspects is required because of all features (configuration,
serialization, behaviors & extensitibility…)
• To unit test your service, you should ignore the WCF aspect
– Instantiate and invoke the service class directly
– DI/IoC is possible in WCF using IInstanceProvider (see extensibility section, here
or here)
– Some workarounds when your service is using static class
OperationContext/WebOperationcontext (see here)
• The best way to have unit tests is to design your service for testing
– If your service code is all in the top-level class, then you wrote it to be untestable
– The service class should be logic-less and be only a wrapper for your code
36
WCF Best Practices
Unit Testing
• In SOA, services and clients are autonomous
– Service developers cannot assume that they control all clients
– should be able to evolve service independent of its clients.
• Four Categories of Service Changes
– Contract changes
an operation might be added, or a data element in a message might be added or changed
=> breaking / non-breaking
– Address changes
a service moves to a different location where endpoints have new addresses
=> breaking
– Binding changes
a security mechanism changes or its settings change
=> breaking
– Implementation changes
when an internal method implementation changes
Non breaking
• Continue reading here
37
WCF Best Practices
Service Changes
• Contracts used by a client and by the service don’t require to be the
same
– they need only to be compatible
• Versionning depends on the inner serializer (Datacontract,,
XmlSerializer, ..), serialization attributes (mandatory, optional,
order…) and schema validation (on/off)
– 2 main approachs
• Strict Versionning
Treat existing data contracts as immutable and create new ones with
unique qualified names.
• Lax Versionning
adding a new method, an optional member to the data contract will
not break existing clients.
Supported by WCF, but not by all clients
• Read the 15 tips here 38
WCF Best Practices
Contract Versionning
• Large set of performance counters to help you gauge your application's
performance
• Examples
– Service / Calls Per Second
– Service / Calls Faulted (Since restart)
– Operation / Call Duration
– EndPoint / Calls Failed Per Second
– …
• Activated by Config
• List of counters here
39
WCF Best Practices
Service Monitoring : Performance counters
40
WCF Best Practices
Performance counters integration in Centreon
• Auto Capture data generated by the execution of WCF Service
– Call Duration, Errors, Faults, Exceptions, …
– Data store implementation is a SQL Server database by default
• Use Event Tracing for Windows (ETW)
– Very limited impact on service
– Async by nature
• Monitoring Architecture
41
WCF Best Practices
AppFabric Monitoring
Monitoring Database
Dashboard
Custom
Tool
SQL Agent Job
WCF Events
Batch
Staging Table
WCF Events Table
DB Views
Server A
Runtime
WCF
EventCollector
Service
WCF
Server B
Runtime
WCF
EventCollector
Service
WCF
42
WCF Best Practices
AppFabric Monitoring
WCF Tools
43
• Simple GUI tool that enables users to test a service
• Can be standalone (without VS install)
– For SysAdmins for example
• Supported Features
– Service Invocation: Request/Response and One-way message.
– Bindings: all bindings supported by Svcutil.exe
– Controlling Session.
– Message Contract
– XML serialization
• Unsupported features
– Duplex, Transaction, Streaming, Security/Authentication, Some bindings, …
• Located at C:Program FilesMicrosoft Visual Studio 9.0Common7IDE
• More info at http://msdn.microsoft.com/en-us/library/bb552364.aspx
44
WCF Tools
WCFTestClient.exe
45
WCF Tools
WCFTestClient.exe
• A Soap Client for Http Service
• Made in Java
– Test exposed services outside MS envrionnement
– Invoke other Soap Service
• Features
– Project Support
– Follow Common WS-* Standard
– Test Suite / Mock Service
• Download free version at http://www.soapui.org/
46
WCF Tools
Soap UI
47
WCF Tools
Soap UI
• Simple GUI Config tool that Operates exclusively on
<system.serviceModel> section
• All WCF features in a GUI !
• Output is guaranteed to comply with the WCF schema
• Part of Windows SDK
– Located in C:Program Files (x86)Microsoft SDKsWindowsv8.0AbinNETFX
4.0 Tools
• Integrated in Visual Studio
– Tools/WCF Service Configuration Editor
– Right Click on a WCF Service Project
• More Info here
48
WCF Tools
SvcConfigEditor.exe
49
WCF Tools
SvcConfigEditor.exe
• Simple GUI tool that helps us analyze diagnostic traces that are generated
by WCF service (when activated)
• Part of Windows SDK
– Located in C:Program Files (x86)Microsoft SDKsWindowsv8.0AbinNETFX
4.0 Tools
• Traces Files associated with .svclog (part of Windows SDK)
• More Info here
50
WCF Tools
SvcTraceViewer.exe
51
WCF Tools
SvcTraceViewer.exe
• Used to generate service model code from metadata documents and
metadata documents from service model
– Example : Generate C# from an external Wsdl
• Features
– Generates code from running services or static metadata documents
– Exports metadata documents from compiled code
– Validates compiled service code
– Downloads metadata documents from running services
– Generates serialization code
• More info here
52
WCF Tools
Svcutil.exe
53
WCF Tools
Svcutil.exe
• Toolset that facilitates the development of web
services using a schema first approach
• Features
– VS extension (Menu, Toolbars, …)
– A WSDL Wizard that allows to step through the
creation of a WSDL from one or more XSDs
– Data Contract Generator
– A Service/Endpoint Stub (SVC) Generator
– A Client Proxy Generator
– A Generate Data Contract Code feature that supports
the selection of multiple XSD/WSDL source files
– …
• See project here
54
WSCF Blue
Use Cases
55
• To Prevent Denial of service (DoS) attacks, WCF have limits
– ReaderQuotas constraints on the complexity of SOAP messages that can be processed
“The maximum message size quota for incoming messages has been exceeded for the remote channel.
See the server logs for more details.”
– Throttling Throttling allows you to "smooth" out the load on the server
"The open operation did not complete within the allotted timeout of 00:00:59.9989999. The time allotted
to this operation may have been a portion of a longer timeout."
56
Common Errors
Reader Quotas & Throttling
• Enums should always have a default value (=0)
– Code Analysis recomanded Rule
– Serialization : Enums are int, and default is 0
57
Common Errors
Enums
• In WCF, there is no way to determine if service is up or down 
– Service down vs all calls are failed ?
– WCF vs IIS ?
– Client Timeouts/CommunicationExcetions vs Network failure ?
• However, some questions :
– Is IIS started ?
– Is the application pool started ?
– Are NetTcp/NamedPipe Services started ?
– Is WAS Started ?
– Is My service Activated ?
• A ping/heartbeat method is sometimes a solution …
58
Use Cases
Is my service Up ?
• « I always have a error (404 or unreachable url) when I go to
http://yourservicedomain/myservice.svc. My service doesn’t work. »
• Browsing svc file is not required to call the service
– Sometimes Metadata is not published or accessible (because of Firewall)
• It’s not because metadata is unreachable that you can’t invoke the service
– Use WCF Test Client / Soap UI / Unit Test to call a Reag/Get Method
59
Use Cases
404 and unreachable service
• Event logging is enabled automatically by default, and there is no
mechanism to disable it in WCF
• The Application Event Log contains most of the events generated by WCF.
Most of the entries indicate that a particular feature failed to start up for an
application. Examples include:
– Shared Listener: The WCF TCP Port Sharing Service logs an event when it fails
to start.
– Critical and error events, such as startup failures or crashes
– Message logging/tracing turned on/off: Logs events when message logging is
turned on/off. …
60
Use Cases
Service Startup
61
Use Cases
Event Logs
Questions?
62

Weitere ähnliche Inhalte

Was ist angesagt?

Simple Object Access Protocol
Simple Object Access ProtocolSimple Object Access Protocol
Simple Object Access Protocol
Saatviga Sudhahar
 
Advanced java programming-contents
Advanced java programming-contentsAdvanced java programming-contents
Advanced java programming-contents
Self-Employed
 

Was ist angesagt? (20)

.Net Core 1.0 vs .NET Framework
.Net Core 1.0 vs .NET Framework.Net Core 1.0 vs .NET Framework
.Net Core 1.0 vs .NET Framework
 
Simple Object Access Protocol
Simple Object Access ProtocolSimple Object Access Protocol
Simple Object Access Protocol
 
Introduction To RabbitMQ
Introduction To RabbitMQIntroduction To RabbitMQ
Introduction To RabbitMQ
 
Angular 16 – the rise of Signals
Angular 16 – the rise of SignalsAngular 16 – the rise of Signals
Angular 16 – the rise of Signals
 
Asp.net MVC training session
Asp.net MVC training sessionAsp.net MVC training session
Asp.net MVC training session
 
.NET Core, ASP.NET Core Course, Session 1
.NET Core, ASP.NET Core Course, Session 1.NET Core, ASP.NET Core Course, Session 1
.NET Core, ASP.NET Core Course, Session 1
 
Basic Concept of Node.js & NPM
Basic Concept of Node.js & NPMBasic Concept of Node.js & NPM
Basic Concept of Node.js & NPM
 
Advanced java programming-contents
Advanced java programming-contentsAdvanced java programming-contents
Advanced java programming-contents
 
Express js
Express jsExpress js
Express js
 
Soap web service
Soap web serviceSoap web service
Soap web service
 
Node.Js: Basics Concepts and Introduction
Node.Js: Basics Concepts and Introduction Node.Js: Basics Concepts and Introduction
Node.Js: Basics Concepts and Introduction
 
Common language runtime clr
Common language runtime clrCommon language runtime clr
Common language runtime clr
 
Asynchronous Programming in C# - Part 1
Asynchronous Programming in C# - Part 1Asynchronous Programming in C# - Part 1
Asynchronous Programming in C# - Part 1
 
.Net Core
.Net Core.Net Core
.Net Core
 
React Development with the MERN Stack
React Development with the MERN StackReact Development with the MERN Stack
React Development with the MERN Stack
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Node js introduction
Node js introductionNode js introduction
Node js introduction
 
Why TypeScript?
Why TypeScript?Why TypeScript?
Why TypeScript?
 
Présentation Angular 2
Présentation Angular 2 Présentation Angular 2
Présentation Angular 2
 
Introduction To Dotnet
Introduction To DotnetIntroduction To Dotnet
Introduction To Dotnet
 

Andere mochten auch

WCF (Windows Communication Foundation)
WCF (Windows Communication Foundation)WCF (Windows Communication Foundation)
WCF (Windows Communication Foundation)
ipower softwares
 
WCF Security, FSec
WCF Security, FSecWCF Security, FSec
WCF Security, FSec
Ante Gulam
 
Lunch Learn - WCF Security
Lunch Learn - WCF SecurityLunch Learn - WCF Security
Lunch Learn - WCF Security
Paul Senatillaka
 
Mysql gdb-101022041146-phpapp01
Mysql gdb-101022041146-phpapp01Mysql gdb-101022041146-phpapp01
Mysql gdb-101022041146-phpapp01
Bob Huang
 
Wcf security session 2
Wcf security session 2Wcf security session 2
Wcf security session 2
Anil Kumar M
 

Andere mochten auch (20)

WCF tutorial
WCF tutorialWCF tutorial
WCF tutorial
 
Web API or WCF - An Architectural Comparison
Web API or WCF - An Architectural ComparisonWeb API or WCF - An Architectural Comparison
Web API or WCF - An Architectural Comparison
 
Wcf development
Wcf developmentWcf development
Wcf development
 
WCF (Windows Communication Foundation)
WCF (Windows Communication Foundation)WCF (Windows Communication Foundation)
WCF (Windows Communication Foundation)
 
Windows Communication Foundation (WCF) Best Practices
Windows Communication Foundation (WCF) Best PracticesWindows Communication Foundation (WCF) Best Practices
Windows Communication Foundation (WCF) Best Practices
 
Advanced WCF Workshop
Advanced WCF WorkshopAdvanced WCF Workshop
Advanced WCF Workshop
 
ASP.NET Mvc 4 web api
ASP.NET Mvc 4 web apiASP.NET Mvc 4 web api
ASP.NET Mvc 4 web api
 
Wcf
WcfWcf
Wcf
 
There is time for rest
There is time for rest There is time for rest
There is time for rest
 
WCF 4.0
WCF 4.0WCF 4.0
WCF 4.0
 
WCF Security, FSec
WCF Security, FSecWCF Security, FSec
WCF Security, FSec
 
Overview of Rest Service and ASP.NET WEB API
Overview of Rest Service and ASP.NET WEB APIOverview of Rest Service and ASP.NET WEB API
Overview of Rest Service and ASP.NET WEB API
 
C# ASP.NET WEB API APPLICATION DEVELOPMENT
C# ASP.NET WEB API APPLICATION DEVELOPMENTC# ASP.NET WEB API APPLICATION DEVELOPMENT
C# ASP.NET WEB API APPLICATION DEVELOPMENT
 
Lunch Learn - WCF Security
Lunch Learn - WCF SecurityLunch Learn - WCF Security
Lunch Learn - WCF Security
 
Architecture of .net framework
Architecture of .net frameworkArchitecture of .net framework
Architecture of .net framework
 
DATA WAREHOUSING AND DATA MINING
DATA WAREHOUSING AND DATA MININGDATA WAREHOUSING AND DATA MINING
DATA WAREHOUSING AND DATA MINING
 
Data mining
Data miningData mining
Data mining
 
Data Warehousing and Data Mining
Data Warehousing and Data MiningData Warehousing and Data Mining
Data Warehousing and Data Mining
 
Mysql gdb-101022041146-phpapp01
Mysql gdb-101022041146-phpapp01Mysql gdb-101022041146-phpapp01
Mysql gdb-101022041146-phpapp01
 
Wcf security session 2
Wcf security session 2Wcf security session 2
Wcf security session 2
 

Ähnlich wie Windows Communication Foundation (WCF)

D1-3-Signaling
D1-3-SignalingD1-3-Signaling
D1-3-Signaling
Oleg Levy
 
1. WCF Services - Exam 70-487
1. WCF Services - Exam 70-4871. WCF Services - Exam 70-487
1. WCF Services - Exam 70-487
Bat Programmer
 
complete web service1.ppt
complete web service1.pptcomplete web service1.ppt
complete web service1.ppt
Dr.Saranya K.G
 
A presentation on WCF & REST
A presentation on WCF & RESTA presentation on WCF & REST
A presentation on WCF & REST
Santhu Rao
 
Dot Net Training Wcf Dot Net35
Dot Net Training Wcf Dot Net35Dot Net Training Wcf Dot Net35
Dot Net Training Wcf Dot Net35
Subodh Pushpak
 

Ähnlich wie Windows Communication Foundation (WCF) (20)

Complete Architecture and Development Guide To Windows Communication Foundati...
Complete Architecture and Development Guide To Windows Communication Foundati...Complete Architecture and Development Guide To Windows Communication Foundati...
Complete Architecture and Development Guide To Windows Communication Foundati...
 
Windows Communication Foundation
Windows Communication FoundationWindows Communication Foundation
Windows Communication Foundation
 
web programming
web programmingweb programming
web programming
 
D1-3-Signaling
D1-3-SignalingD1-3-Signaling
D1-3-Signaling
 
Windows 8 Metro apps and the outside world
Windows 8 Metro apps and the outside worldWindows 8 Metro apps and the outside world
Windows 8 Metro apps and the outside world
 
1. WCF Services - Exam 70-487
1. WCF Services - Exam 70-4871. WCF Services - Exam 70-487
1. WCF Services - Exam 70-487
 
WCF
WCFWCF
WCF
 
web services-May 25.ppt
web services-May 25.pptweb services-May 25.ppt
web services-May 25.ppt
 
Advancio, Inc. Academy: Web Sevices, WCF & SOAPUI
Advancio, Inc. Academy: Web Sevices, WCF & SOAPUIAdvancio, Inc. Academy: Web Sevices, WCF & SOAPUI
Advancio, Inc. Academy: Web Sevices, WCF & SOAPUI
 
Developing and Hosting SOAP Based Services
Developing and Hosting SOAP Based ServicesDeveloping and Hosting SOAP Based Services
Developing and Hosting SOAP Based Services
 
Session 1 Shanon Richards-Exposing Data Using WCF
Session 1 Shanon Richards-Exposing Data Using WCFSession 1 Shanon Richards-Exposing Data Using WCF
Session 1 Shanon Richards-Exposing Data Using WCF
 
Windows communication foundation ii
Windows communication foundation iiWindows communication foundation ii
Windows communication foundation ii
 
complete web service1.ppt
complete web service1.pptcomplete web service1.ppt
complete web service1.ppt
 
A presentation on WCF & REST
A presentation on WCF & RESTA presentation on WCF & REST
A presentation on WCF & REST
 
Wcf v1-day1
Wcf v1-day1Wcf v1-day1
Wcf v1-day1
 
Dot Net Training Wcf Dot Net35
Dot Net Training Wcf Dot Net35Dot Net Training Wcf Dot Net35
Dot Net Training Wcf Dot Net35
 
Wcf Overview
Wcf OverviewWcf Overview
Wcf Overview
 
Exploring Twitter's Finagle technology stack for microservices
Exploring Twitter's Finagle technology stack for microservicesExploring Twitter's Finagle technology stack for microservices
Exploring Twitter's Finagle technology stack for microservices
 
HTTP/2 Comes to Java: Servlet 4.0 and what it means for the Java/Jakarta EE e...
HTTP/2 Comes to Java: Servlet 4.0 and what it means for the Java/Jakarta EE e...HTTP/2 Comes to Java: Servlet 4.0 and what it means for the Java/Jakarta EE e...
HTTP/2 Comes to Java: Servlet 4.0 and what it means for the Java/Jakarta EE e...
 
Managing Microservices With The Istio Service Mesh on Kubernetes
Managing Microservices With The Istio Service Mesh on KubernetesManaging Microservices With The Istio Service Mesh on Kubernetes
Managing Microservices With The Istio Service Mesh on Kubernetes
 

Mehr von Betclic Everest Group Tech Team

Mehr von Betclic Everest Group Tech Team (20)

Mini training - Reactive Extensions (Rx)
Mini training - Reactive Extensions (Rx)Mini training - Reactive Extensions (Rx)
Mini training - Reactive Extensions (Rx)
 
Mini training - Moving to xUnit.net
Mini training - Moving to xUnit.netMini training - Moving to xUnit.net
Mini training - Moving to xUnit.net
 
Mini training - Introduction to Microsoft Azure Storage
Mini training - Introduction to Microsoft Azure StorageMini training - Introduction to Microsoft Azure Storage
Mini training - Introduction to Microsoft Azure Storage
 
Akka.Net
Akka.NetAkka.Net
Akka.Net
 
Mini training- Scenario Driven Design
Mini training- Scenario Driven DesignMini training- Scenario Driven Design
Mini training- Scenario Driven Design
 
Email Management in Outlook
Email Management in OutlookEmail Management in Outlook
Email Management in Outlook
 
Mini-Training: SSO with Windows Identity Foundation
Mini-Training: SSO with Windows Identity FoundationMini-Training: SSO with Windows Identity Foundation
Mini-Training: SSO with Windows Identity Foundation
 
Training - What is Performance ?
Training  - What is Performance ?Training  - What is Performance ?
Training - What is Performance ?
 
Mini-Training: Docker
Mini-Training: DockerMini-Training: Docker
Mini-Training: Docker
 
Mini Training Flyway
Mini Training FlywayMini Training Flyway
Mini Training Flyway
 
Mini-Training: NDepend
Mini-Training: NDependMini-Training: NDepend
Mini-Training: NDepend
 
Management 3.0 Workout
Management 3.0 WorkoutManagement 3.0 Workout
Management 3.0 Workout
 
Lean for Business
Lean for BusinessLean for Business
Lean for Business
 
Short-Training asp.net vNext
Short-Training asp.net vNextShort-Training asp.net vNext
Short-Training asp.net vNext
 
Training – Going Async
Training – Going AsyncTraining – Going Async
Training – Going Async
 
Mini-Training: Mobile UX Trends
Mini-Training: Mobile UX TrendsMini-Training: Mobile UX Trends
Mini-Training: Mobile UX Trends
 
Training: MVVM Pattern
Training: MVVM PatternTraining: MVVM Pattern
Training: MVVM Pattern
 
Mini-training: Personalization & Recommendation Demystified
Mini-training: Personalization & Recommendation DemystifiedMini-training: Personalization & Recommendation Demystified
Mini-training: Personalization & Recommendation Demystified
 
Mini-training: Let’s Git It!
Mini-training: Let’s Git It!Mini-training: Let’s Git It!
Mini-training: Let’s Git It!
 
AngularJS Best Practices
AngularJS Best PracticesAngularJS Best Practices
AngularJS Best Practices
 

Kürzlich hochgeladen

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Kürzlich hochgeladen (20)

DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 

Windows Communication Foundation (WCF)

  • 2. • Introduction • Basic Concepts • Going deeper • What's New in WCF 4/4.5 • Best Practices • WCF Tools • Use Cases 2 Agenda yes, we can !
  • 3. • I won’t explain you every concepts & components of WCF  • I will try to educate you to common WCF features and give you some best practices • I have included as many links as possible 3 Introduction Objectives
  • 4. • WCF (CodeName Indigo) is a unified communication framework in.NET for building connected, service-oriented applications • Introduced in .Net 3.0 – Before WCF : ASMX, Remoting, TcpServer, COM, POX… • Defines a common programming model and unified API for clients and services to send messages between each other • Key characteristics – Service-oriented programming model (SOA): • Services are offered on an endpoint. • WCF completely separates service hosting, endpoints and services – Interoperability with non-WCF web services due to use of SOAP messages • WCF implements many of the WS-* standards – Extensibility • WCF client / server can be configured to interoperate with REST, ATOM- feeds, plain XML or JSON messages 4 Introduction Why WCF ?
  • 5. • To expose our first WCF service, we need – An Endpoint (WCF’s ABC) – A Service Implementation – Some Config – An Hosting Environnment 5 How to build our first WCF Service (a very basic service )
  • 6. • Address : « Where is my service ? » – The location of the service on the network where it can be reached • Some examples – http://localhost/calculatorservice.svc – net.msmq://localhost/private/calculatorservice – net.tcp://localhost:6000/calculatorservice • Set via configuration/code or inherited from Hosting Environment 6 ABC’s of WCF Give me the A !
  • 7. • Binding : « How do I talk to this thing? » – The protocol/policies/settings used to connect to the service at it’s address • Some examples – Http(BasicHttp, WsHttp, WsDualHttp, WsFederation) – NetMsmq – NetNamedPipe – NetTcp – CustomBinding – … • Contains – Transport protocol (HTTP, TCP, MSMQ, …) – Message encoding (MTOM, XML, JSON, Binary, …) – Security / reliability settings (encryption & authentication) – … • All system provided binding are available here 7 ABC’s of WCF Give me the B !
  • 8. • A Binding is an aggregate of micro WCF features – Security, Duplex, Session, Encoding, Streaming, … 8 ABC’s of WCF Give me the B !
  • 9. • Contract : « What’s it going to do for me? » – Defines the operations, inputs, outputs, and mep of the service. • In WCF, a Contract is defined by an interface • A Contract defines – Grouping of operations in a service => .Net attribute [ServiceContract] – Signature of operations => .Net attribute [OperationContract] – Data types of operations => .Net attribute [DataContract] 9 ABC’s of WCF Give me the C !
  • 10. 10 Our first WCF Service on the road to Carl …
  • 11. • Services are designed to run in any Windows process that supports managed code – Hosting Options • Self-Hosting Fast & Flexible but not an enterprise solution • Windows Service Secure, Supported by all windows but lack of reliable features • IIS/WAS Components required but all advantages of IIS • IIS7 (Vista/WS2K8) introduced Windows Activation Service (WAS) – Host non HTTP protocols in IIS like Net.Tcp, NamedPipe, MSMQ… • Continue reading here 11 WCF Hosting How & where do I host my new WCF service ?
  • 13. • A WCF client is used to invoke a WCF Service – It’s not mandatory but will help you a lot (create SOAP manually ?) – Translate .Net code to SOAP and vice-versa – Logic-less implementation of Proxy Design Pattern • To create a WCF client, you need – An Address – A Binding – A Contract – Some code – (extra configuration & settings) • Clients have to be stateless and disposed when required 13 How to call this Service ? WCF Clients
  • 14. • An Automatic WCF Client in 2 clics • Generate all client code, contract & configuration. • Best suite if you don’t know the contract 14 WCF Clients example #1 : Service Reference
  • 15. • A little more code • Perfect if you already know the contract 15 WCF Clients example #2 : ChannelFactory<T>
  • 16. • WCF allows use to expose Metadata using standardized protocols – Metadata ? • Operations a client perform • The structure of the data types that the operations work with or return • Definitions of all the endpoints implemented by the service and the various options needed for each such as security => Basically, how to call the service • Two ways to expose Metadata – Mex Endpoint (for all services/bindings) – Wsdl/Disco (only for http Services) • Metadata is generally not exposed for production public service • More info here 16 WCF Metadata what is it ?
  • 17. Http(s)GetEnabled 17 WCF Metadata how to publish metadata IMexdataExchange
  • 18. • WCF Supports 3 MEPs – OneWay Client sends a message using a fire and forget exchange. Like UDP, it does not guarantee that the remote endpoint has received the message . Defined at operation level. Warning : it’s not async ! – Request-Reply (Default) Client sends a message to a WCF Service and then waits for a reply (no response = TimeOutException). Client stops processing until the return message is received. Classic pairs of Request-Response like in HTTP GET method. – Duplex Like a phone conversation, both sides can send and receive messages. Defined at contract level. • Continue reading here 18 WCF Messaging Message Exchange Patterns (MEP)
  • 19. • In Connected Systems, there is no magic translation and data needs to be exchanged in a serialized form • WCF provides 2 Serializer – DataContractSerializer Opt-in Serialization • DataContract or Message Contract – XmlSerializer Opt-out Serialization => 2 Serializers to handle all scenarios • There are also many ways to by-pass serialization – Using Stream object (for Streaming and Large Data) – Using Message class (Parsing Soap Message directly) • More info here 19 WCF Serialization hidden part
  • 21. • Scope of WCF Security – Transfer security Responsible for providing message confidentiality, data integrity, and authentication of communicating parties – Authorization Responsible for providing a framework for making authorization decisions – Auditing Responsible for logging security-related events to the audit log • Basically WCF Security is managed by Security Configuration – None – Transport – Message – Both – TransportWithMessageCredential or TransportCredentialOnly • All bindings don’t provide the same security features ! • Continue reading here and here 21 WCF Security do not fear …
  • 22. Transport Security User credentials and claims are passed using the transport layer  Interoperabable  Performant & Hardware Accelerated o Transport-dependant o Limited set of credentials o Point to Point com only 22 WCF Security Message Vs Transport Security Message Security User credentials and claims are encapsulated in every message using the WS-Security specification  end-to-end security  Partial/selective encryption and signing  Transport-independent o Limited interoperability (WS-Security) o Less performant
  • 23. • Sessions – A session is a correlation of all messages sent between two endpoints – this requires a binding that supports sessions • Instancing – Refers to controlling the lifetime of user-defined service objects and their related InstanceContext objects – Can be • Per Call : a new service object is created for each client request • Per Session : a new service object is created and maintained for each client session • Single : a service object handles all client requests • Concurency – Term given to the control of the number of threads executing in an InstanceContext at the same time – Can be • Single : Maximum of one thread processing messages in the instance context at a time • Multiple : Can have multiple threads processing messages concurrently • Reentrant : The service instance is single-threaded and accepts reentrant calls (Duplex) • Continue reading here 23 WCF Concepts Sessions, Instancing & Concurrency
  • 24. • WCF is designed to solve the greater part of the communication requirements, but there are sometimes scenarios where the default behavior is not valid. • WCF is extensible by nature – You can add or modify system behavior at every level as you want – Many shared concepts with AOP • More than 25 interfaces to implement ! • Must-read blog post and here 24 WCF Extensibility really powerfull !
  • 25. 25 WCF Extensibility caching for service operations using IOperationInvoker
  • 26. • Transaction • Reliable Messaging • WCF REST • Queue Messaging • Streaming & Large Data • WCF Tracing • Async • Duplex Services • Workflow Services • Peer to Peer Networking • Syndication • WebSockets • … 26 Others Features To be continued …
  • 27. What’s New in WCF 4 / 4.5 ? 27
  • 28. • WS-Discovery Support – Discovery Service – Announcement feature • Single WSDL Document • New Https Binding • WCF REST Improvements (deprecated) • Task-based Async/Await Support • New Configuration Default Values – Concurrent Calls/sessions/Instances, Net.Tcp settings, Timeouts • WebSocket Support – 2 new bindings : NetHttpBinding and NetHttpsBinding • WCF Configuration Tooltips & Validation on Build 28 What’s new in WCF 4 /4.5 ? All you need is here and here
  • 29. WCF 3.0 29 What’s new in WCF 4 /4.5 ? Simplified Configuration WCF 4.5 Thanks to standard bindings and protocols mappings !
  • 30. • Define and activate WCF services without having to maintain physical .svc 30 What’s new in WCF 4 /4.5 ? File-less Activation
  • 31. • A generic SOAP intermediary that acts as a message router • Features – Content-based routing • Header • Body – Priority Routing – Protocol bridging • Ex : HT¨TP to NetTcp – Multicast – Backup & Failover endpoints – … • Continue here 31 What’s new in WCF 4 /4.5 ? Routing Service
  • 33. • When invoking a service, a client should catch 3 types of exceptions – TimeoutException thrown when the time allotted for a process or operation has expired (on client or on server) – CommunicationException communication error in either the service or client application – FaultException/FaultException<TDetail> Represents a SOAP fault • SOAP-based applications use fault messages to notify processing error – “Exception” is not an unknown concept and not fully serializable – Do not throw ArgumentException/ArgumentNullException/… use Faults ! • Exception details are not returned to client unless it has been activated – Can be a security risk because details expose internal service implementation – Use only on Dev • For global Exception handling, there is an IErrorHandler extensibility point • Continue reading here 33 WCF Best Practices Exception Management & Fault Contracts
  • 34. FaultContract is defined on each operation Service throws a Fault when there is an handled/unhandled error 34 WCF Best Practices FaultContracts sample Client knows Faults (defined in Contract) and can have specific error management
  • 35. • Always Close the client proxy – Undisposed proxies can lead to memory leaks and random exceptions • Close = Dispose in WCF • Close/Dispose well – Close can throw exceptions • More info here – http://stackoverflow.com/questions/573872/ – http://msdn.microsoft.com/en-us/library/aa355056.aspx 35 WCF Best Practices Dispose well, Padawan !
  • 36. • Running a test against a running WCF service is not unit testing, but integration testing. – Note : Testing WCF aspects is required because of all features (configuration, serialization, behaviors & extensitibility…) • To unit test your service, you should ignore the WCF aspect – Instantiate and invoke the service class directly – DI/IoC is possible in WCF using IInstanceProvider (see extensibility section, here or here) – Some workarounds when your service is using static class OperationContext/WebOperationcontext (see here) • The best way to have unit tests is to design your service for testing – If your service code is all in the top-level class, then you wrote it to be untestable – The service class should be logic-less and be only a wrapper for your code 36 WCF Best Practices Unit Testing
  • 37. • In SOA, services and clients are autonomous – Service developers cannot assume that they control all clients – should be able to evolve service independent of its clients. • Four Categories of Service Changes – Contract changes an operation might be added, or a data element in a message might be added or changed => breaking / non-breaking – Address changes a service moves to a different location where endpoints have new addresses => breaking – Binding changes a security mechanism changes or its settings change => breaking – Implementation changes when an internal method implementation changes Non breaking • Continue reading here 37 WCF Best Practices Service Changes
  • 38. • Contracts used by a client and by the service don’t require to be the same – they need only to be compatible • Versionning depends on the inner serializer (Datacontract,, XmlSerializer, ..), serialization attributes (mandatory, optional, order…) and schema validation (on/off) – 2 main approachs • Strict Versionning Treat existing data contracts as immutable and create new ones with unique qualified names. • Lax Versionning adding a new method, an optional member to the data contract will not break existing clients. Supported by WCF, but not by all clients • Read the 15 tips here 38 WCF Best Practices Contract Versionning
  • 39. • Large set of performance counters to help you gauge your application's performance • Examples – Service / Calls Per Second – Service / Calls Faulted (Since restart) – Operation / Call Duration – EndPoint / Calls Failed Per Second – … • Activated by Config • List of counters here 39 WCF Best Practices Service Monitoring : Performance counters
  • 40. 40 WCF Best Practices Performance counters integration in Centreon
  • 41. • Auto Capture data generated by the execution of WCF Service – Call Duration, Errors, Faults, Exceptions, … – Data store implementation is a SQL Server database by default • Use Event Tracing for Windows (ETW) – Very limited impact on service – Async by nature • Monitoring Architecture 41 WCF Best Practices AppFabric Monitoring Monitoring Database Dashboard Custom Tool SQL Agent Job WCF Events Batch Staging Table WCF Events Table DB Views Server A Runtime WCF EventCollector Service WCF Server B Runtime WCF EventCollector Service WCF
  • 44. • Simple GUI tool that enables users to test a service • Can be standalone (without VS install) – For SysAdmins for example • Supported Features – Service Invocation: Request/Response and One-way message. – Bindings: all bindings supported by Svcutil.exe – Controlling Session. – Message Contract – XML serialization • Unsupported features – Duplex, Transaction, Streaming, Security/Authentication, Some bindings, … • Located at C:Program FilesMicrosoft Visual Studio 9.0Common7IDE • More info at http://msdn.microsoft.com/en-us/library/bb552364.aspx 44 WCF Tools WCFTestClient.exe
  • 46. • A Soap Client for Http Service • Made in Java – Test exposed services outside MS envrionnement – Invoke other Soap Service • Features – Project Support – Follow Common WS-* Standard – Test Suite / Mock Service • Download free version at http://www.soapui.org/ 46 WCF Tools Soap UI
  • 48. • Simple GUI Config tool that Operates exclusively on <system.serviceModel> section • All WCF features in a GUI ! • Output is guaranteed to comply with the WCF schema • Part of Windows SDK – Located in C:Program Files (x86)Microsoft SDKsWindowsv8.0AbinNETFX 4.0 Tools • Integrated in Visual Studio – Tools/WCF Service Configuration Editor – Right Click on a WCF Service Project • More Info here 48 WCF Tools SvcConfigEditor.exe
  • 50. • Simple GUI tool that helps us analyze diagnostic traces that are generated by WCF service (when activated) • Part of Windows SDK – Located in C:Program Files (x86)Microsoft SDKsWindowsv8.0AbinNETFX 4.0 Tools • Traces Files associated with .svclog (part of Windows SDK) • More Info here 50 WCF Tools SvcTraceViewer.exe
  • 52. • Used to generate service model code from metadata documents and metadata documents from service model – Example : Generate C# from an external Wsdl • Features – Generates code from running services or static metadata documents – Exports metadata documents from compiled code – Validates compiled service code – Downloads metadata documents from running services – Generates serialization code • More info here 52 WCF Tools Svcutil.exe
  • 54. • Toolset that facilitates the development of web services using a schema first approach • Features – VS extension (Menu, Toolbars, …) – A WSDL Wizard that allows to step through the creation of a WSDL from one or more XSDs – Data Contract Generator – A Service/Endpoint Stub (SVC) Generator – A Client Proxy Generator – A Generate Data Contract Code feature that supports the selection of multiple XSD/WSDL source files – … • See project here 54 WSCF Blue
  • 56. • To Prevent Denial of service (DoS) attacks, WCF have limits – ReaderQuotas constraints on the complexity of SOAP messages that can be processed “The maximum message size quota for incoming messages has been exceeded for the remote channel. See the server logs for more details.” – Throttling Throttling allows you to "smooth" out the load on the server "The open operation did not complete within the allotted timeout of 00:00:59.9989999. The time allotted to this operation may have been a portion of a longer timeout." 56 Common Errors Reader Quotas & Throttling
  • 57. • Enums should always have a default value (=0) – Code Analysis recomanded Rule – Serialization : Enums are int, and default is 0 57 Common Errors Enums
  • 58. • In WCF, there is no way to determine if service is up or down  – Service down vs all calls are failed ? – WCF vs IIS ? – Client Timeouts/CommunicationExcetions vs Network failure ? • However, some questions : – Is IIS started ? – Is the application pool started ? – Are NetTcp/NamedPipe Services started ? – Is WAS Started ? – Is My service Activated ? • A ping/heartbeat method is sometimes a solution … 58 Use Cases Is my service Up ?
  • 59. • « I always have a error (404 or unreachable url) when I go to http://yourservicedomain/myservice.svc. My service doesn’t work. » • Browsing svc file is not required to call the service – Sometimes Metadata is not published or accessible (because of Firewall) • It’s not because metadata is unreachable that you can’t invoke the service – Use WCF Test Client / Soap UI / Unit Test to call a Reag/Get Method 59 Use Cases 404 and unreachable service
  • 60. • Event logging is enabled automatically by default, and there is no mechanism to disable it in WCF • The Application Event Log contains most of the events generated by WCF. Most of the entries indicate that a particular feature failed to start up for an application. Examples include: – Shared Listener: The WCF TCP Port Sharing Service logs an event when it fails to start. – Critical and error events, such as startup failures or crashes – Message logging/tracing turned on/off: Logs events when message logging is turned on/off. … 60 Use Cases Service Startup