wcf
DESCRIPTION
TRANSCRIPT
![Page 1: Wcf](https://reader035.vdocument.in/reader035/viewer/2022070303/54b44b314a7959132e8b45b9/html5/thumbnails/1.jpg)
ARIANA
![Page 2: Wcf](https://reader035.vdocument.in/reader035/viewer/2022070303/54b44b314a7959132e8b45b9/html5/thumbnails/2.jpg)
Introduction to WCF What is it? Why use it? Architecture Fundamentals and the ABCs of WCF Hosting
Tooling Support Handling faults
![Page 3: Wcf](https://reader035.vdocument.in/reader035/viewer/2022070303/54b44b314a7959132e8b45b9/html5/thumbnails/3.jpg)
![Page 4: Wcf](https://reader035.vdocument.in/reader035/viewer/2022070303/54b44b314a7959132e8b45b9/html5/thumbnails/4.jpg)
Stands for Windows Communication Foundation One of the 4 pillars of .NET 3.0 Microsoft’s unified programming model (the service model) for building Service-Oriented Applications
![Page 5: Wcf](https://reader035.vdocument.in/reader035/viewer/2022070303/54b44b314a7959132e8b45b9/html5/thumbnails/5.jpg)
![Page 6: Wcf](https://reader035.vdocument.in/reader035/viewer/2022070303/54b44b314a7959132e8b45b9/html5/thumbnails/6.jpg)
![Page 7: Wcf](https://reader035.vdocument.in/reader035/viewer/2022070303/54b44b314a7959132e8b45b9/html5/thumbnails/7.jpg)
ServiceSmall program interacted by well defines
message exchangesAgile, Reliable, Stable, Interoperable, Secure
Four TenetsBoundaries are ExplicitServices are AutonomousServices share schema and contract, not classService compatibility is based upon policy
![Page 8: Wcf](https://reader035.vdocument.in/reader035/viewer/2022070303/54b44b314a7959132e8b45b9/html5/thumbnails/8.jpg)
![Page 9: Wcf](https://reader035.vdocument.in/reader035/viewer/2022070303/54b44b314a7959132e8b45b9/html5/thumbnails/9.jpg)
![Page 10: Wcf](https://reader035.vdocument.in/reader035/viewer/2022070303/54b44b314a7959132e8b45b9/html5/thumbnails/10.jpg)
WCF provides:an SDK for creating SOAa runtime for running Services on
Windows Services send and receive messages All messages are SOAP messages WCF takes care of all the plumbing
![Page 11: Wcf](https://reader035.vdocument.in/reader035/viewer/2022070303/54b44b314a7959132e8b45b9/html5/thumbnails/11.jpg)
Interoperable and Standards based Supports WS-* protocols
Unified Programming Model Unifies previous models like .NET
Remoting, ASMX web services, COM+ etc Productive Programming Model
Declarative Imperative Configuration based
![Page 12: Wcf](https://reader035.vdocument.in/reader035/viewer/2022070303/54b44b314a7959132e8b45b9/html5/thumbnails/12.jpg)
Simplicity Flexibility Maintainability Power
![Page 13: Wcf](https://reader035.vdocument.in/reader035/viewer/2022070303/54b44b314a7959132e8b45b9/html5/thumbnails/13.jpg)
![Page 14: Wcf](https://reader035.vdocument.in/reader035/viewer/2022070303/54b44b314a7959132e8b45b9/html5/thumbnails/14.jpg)
![Page 15: Wcf](https://reader035.vdocument.in/reader035/viewer/2022070303/54b44b314a7959132e8b45b9/html5/thumbnails/15.jpg)
Every service has Address
Where the service is Binding
How to talk to the service Contract
What the service can do
![Page 16: Wcf](https://reader035.vdocument.in/reader035/viewer/2022070303/54b44b314a7959132e8b45b9/html5/thumbnails/16.jpg)
Combination of transport, server name, port & path
Transport is determined by the binding Examples
http://localhost:8001net.tcp://localhost:8002/MyServicenet.pipe://localhost/MyPipenet.msmq://localhost/private/MyServicenet.msmq://localhost/MyService
![Page 17: Wcf](https://reader035.vdocument.in/reader035/viewer/2022070303/54b44b314a7959132e8b45b9/html5/thumbnails/17.jpg)
Transport HTTP TCP MSMQ
Message formats and encoding Plain text Binary Message Transmission Optimization Mechanism
(MTOM) Communication security
No security Transport security Message security Authenticating and authorizing callers
![Page 18: Wcf](https://reader035.vdocument.in/reader035/viewer/2022070303/54b44b314a7959132e8b45b9/html5/thumbnails/18.jpg)
BasicHttpBinding WSHttpBinding WS2007HttpBinding WSDualHttpBinding WSFederationHttp
Binding WS2007FederationHttp
Binding
NetTcpBinding NetNamedPipeBinding NetMsmqBinding NetPeerTcpBinding WebHttpBinding MsmqIntegrationBinding
![Page 19: Wcf](https://reader035.vdocument.in/reader035/viewer/2022070303/54b44b314a7959132e8b45b9/html5/thumbnails/19.jpg)
Service contracts Defines operations, communications
and behaviours. Data contracts
Defines data entities and parameter types.
Fault contracts Defines error types
Message contracts Defines message formats
![Page 20: Wcf](https://reader035.vdocument.in/reader035/viewer/2022070303/54b44b314a7959132e8b45b9/html5/thumbnails/20.jpg)
[ServiceContract] – Defines a ‘set’ of operations [OperationContract] – Defines a single method
[ServiceContract]public interface IService{ [OperationContract] string GetData(int value);}
public class ConcreteService : IService{ public string GetData(int value) { ... }
public string OtherMethod() { ... }}
[ServiceContract]public interface IService{ [OperationContract] string GetData(int value);}
public class ConcreteService : IService{ public string GetData(int value) { ... }
public string OtherMethod() { ... }}
![Page 21: Wcf](https://reader035.vdocument.in/reader035/viewer/2022070303/54b44b314a7959132e8b45b9/html5/thumbnails/21.jpg)
[DataContract] – Specifies type as a data contract [DataMember] – Members that are part of
contract
[DataContract]public class CustomType{ [DataMember] public bool MyFlag { get; set; }
[DataMember] public string MyString { get; set; }
}
[DataContract]public class CustomType{ [DataMember] public bool MyFlag { get; set; }
[DataMember] public string MyString { get; set; }
}
![Page 22: Wcf](https://reader035.vdocument.in/reader035/viewer/2022070303/54b44b314a7959132e8b45b9/html5/thumbnails/22.jpg)
DataContract: created specifically for WCF to serialize types Attribute contains Name and Namespace
properties DataMember is needed to specify which
properties/fields will form part of the contract Contains EmitDefaultValue, IsRequired,
Name, Order properties
![Page 23: Wcf](https://reader035.vdocument.in/reader035/viewer/2022070303/54b44b314a7959132e8b45b9/html5/thumbnails/23.jpg)
Service can also expose endpoint for Metadata Exchange (MEX)
It provides a mechanism for clients to find out about: Address of other end points Bindings that are used Contracts used – Service, Operation, Data,
etc
![Page 24: Wcf](https://reader035.vdocument.in/reader035/viewer/2022070303/54b44b314a7959132e8b45b9/html5/thumbnails/24.jpg)
IIS HTTP only
WAS (Windows Activation Service) Can use any transport Vista and Windows Server 2008 only
Self hosting Can use any transport Can be hosted within Console, WinForms,
etc Applications
![Page 25: Wcf](https://reader035.vdocument.in/reader035/viewer/2022070303/54b44b314a7959132e8b45b9/html5/thumbnails/25.jpg)
![Page 26: Wcf](https://reader035.vdocument.in/reader035/viewer/2022070303/54b44b314a7959132e8b45b9/html5/thumbnails/26.jpg)
Visual Studio Separate projects for WCF “Add Service reference” menu WCF Configuration Editor WCF Service Host WCF Test Tool
SvcUtil – To generate proxies SvcTraceViewer – To view logs
![Page 27: Wcf](https://reader035.vdocument.in/reader035/viewer/2022070303/54b44b314a7959132e8b45b9/html5/thumbnails/27.jpg)
![Page 28: Wcf](https://reader035.vdocument.in/reader035/viewer/2022070303/54b44b314a7959132e8b45b9/html5/thumbnails/28.jpg)
Three main kinds of Exceptions can occur: Communication errors Unexpected error on the service Errors thrown by the service on purpose
.NET Exceptions are technology specific All Exceptions come across the wire as SOAP
Faults
![Page 29: Wcf](https://reader035.vdocument.in/reader035/viewer/2022070303/54b44b314a7959132e8b45b9/html5/thumbnails/29.jpg)
In WCF, SOAP faults are passed in as FaultException objects
Rather than throwing Exceptions, services should throw FaultExceptions
Or better still FaultException<T> Throwing FaultExceptions will not fault the
proxy and the channel
![Page 30: Wcf](https://reader035.vdocument.in/reader035/viewer/2022070303/54b44b314a7959132e8b45b9/html5/thumbnails/30.jpg)
Specifies what kind of Exceptions, an operation can throw
[ServiceContract] public interface IEmployeeService { [OperationContract] [FaultContract(typeof(ValidationException))] public void AddEmployee(Employee e); }
[ServiceContract] public interface IEmployeeService { [OperationContract] [FaultContract(typeof(ValidationException))] public void AddEmployee(Employee e); }
![Page 31: Wcf](https://reader035.vdocument.in/reader035/viewer/2022070303/54b44b314a7959132e8b45b9/html5/thumbnails/31.jpg)
Its made of a lot of different components, so you can create new components for security, transport, authentication.
In WCF, there is no need to make much change in code for implementing the security model and changing the binding. Small changes in the configuration will make your requirements.
Its faster than ASMX Its Interoperability, for java, and more. WCF is interoperable with other services when
compared to .Net Remoting, where the client and service have to be .Net
WCF services provide better reliability and security in compared to ASMX web services.
![Page 32: Wcf](https://reader035.vdocument.in/reader035/viewer/2022070303/54b44b314a7959132e8b45b9/html5/thumbnails/32.jpg)
WCF is Microsoft's implementation of SOA and hence its APIs are solely controlled by MS which makes interoperability a bit difficult.
To deploy WCF apps, need more underlying hardware resources on the platform on which the WCF applications will be running, since there is an additional layer of abstraction to deal with.
![Page 33: Wcf](https://reader035.vdocument.in/reader035/viewer/2022070303/54b44b314a7959132e8b45b9/html5/thumbnails/33.jpg)
WCF provides a runtime for creating Service Oriented Apps Provides a productive programming model. Takes care of:
Messaging and Exchange formats All Plumbing: Transaction, Reliability, Security, etc
Supports Declarative (via attributes), Imperative (via code) and Configuration based (via config files) programming model
ABCs of Endpoints Address: Where to go? Binding: How to get there? Contract: What to do?
Hosting IIS, WAS, Self-hosting