330 likes | 444 Vues
Join Barry Dorrans, a Senior Technologist at Charteris plc, as he delves into Windows Communication Foundation (WCF) and its role in Service-Oriented Architecture (SOA). This session covers the pivotal differences between WCF and traditional remoting, addressing concepts like message contracts, bidirectional communication, and service configurations. Learn how WCF enhances security and simplifies versioning. Discover practical insights on configuring services for various hosting environments and best practices for ensuring robust communication. Enhance your understanding of service-oriented design with hands-on examples.
E N D
Web Services?We don’t need no stinking web server Barry Dorrans Charteris plc http://idunno.org
About the Speaker(the ego slide) MVP – Visual Tools, Security Senior Technologist @ Charteris plc barryd@idunno.org
Agenda What is WCF? WCF versus Remoting SOA, services, interfaces, oh my! Prove it smarty pants
What is WCF? Indigo Remoting, Web Services, WSE Interoperability
WCF versus RemotingWCF Plus Points Services require less permissions Binary messages are smaller/faster Versioning is easier
WCF versus RemotingRemoting Plus Points Sharing code between client and server is easier
WCF versus RemotingTwo Way Communication Callback Contract;Publish & Subscribe
SOA, services, interfaces, oh my! WCF is an SOA approach Contract first, service and data SOAP or binary messages
The ABCs of WCF Address Binding Contract
Client Server Messaging Layer Endpoint Service Model Address Binding Channel Behaviour Behaviour Contract Binding Binding Channel Behaviour Behaviour Factory Listener Channel Address Address Channel *
Address scheme:// <machineName>[:port]/path http://localhost:8080/Account/ net.tcp://localhost:8080/Account
Binding Defines how you communicate with a service A service may have multiple bindings Defines the shape; security, transactions etc.
Contract The external interface Contracts for service, data and message Message Exchange Patterns
Message Exchange Patterns Request-Reply One-Way Duplex
Service Contracts [ServiceContract()] public interface IMyService { [OperationContract] string MyOperation1(string myValue); [OperationContract] string MyOperation2(MyDataContract value); }
Data Contracts [DataContract] public class MyDataContract { string _stuff; [DataMember] public string Stuff { get { return _stuff; } set { stuff = value; } } }
Why data contracts? Message body or Message Header Control over the order of members Required versus optional parameters
Creating our first service library Cross your fingers.
So what have we learned? Services hosted inside apps Service behaviour in config Barry can’t type under pressure.
So what have we learned? We need data contracts Why? WCF exposes nothing by default
What if we want to host in IIS? Well ….(cross your fingers again)
What if we want to host in IE? Add a .svc file <%@ServiceHost Service="RumorServerLibrary.RumourServiceImpl" %> <%@Assembly Name="RumorServerLibrary" %>
But you hard coded stuff! Behold the power of config
So what have we learned? Config good, code bad We can have multiple endpoints
Configuration Settings Service Configuration EditorProtocols must have their own base address
One half of the story Let’s write a client(your fingers are still crossed, right?)
So what have we learned? svcutil is our friend use the config files
It’s all your fault Exceptions and errors.
So what have we learned? Raw exceptions are not helpful Marshall everything to SOAP faults Strong SOAP faults rock my world
And finally, duplex channels Two communication Remoting is dead.
So what have we learned? Server defines callback interface Client implements Do not mark as [ServiceContract]Publish / Subscribe model
Books WCF Step by Step – John Sharp; MS Press Pro WCF – Peiris & Mulder; A Press WCF Unleashed – McMurty et al; SAMS
Web WCF Blogs : http://wcf.netfx3.com/blogs/ .net 3.0 WCF site : http://wcf.netfx3.com/ WCF Extensions for VS 2005: http://www.microsoft.com/downloads/details.aspx?familyid=F54F5537-CC86-4BF5-AE44-F5A1E805680D