Upload
victor-richards
View
212
Download
0
Embed Size (px)
Citation preview
Intro to WCFFrom the beginning and uses
Steve Maier@YsFred4http://strugglingthru.net/[email protected]
Before WCFSocketsNamed PipesTCPIPHTTPMSMQ
Everything had a different API that you had to learn.
Switching from one to another was not simple.
With WCF we get…Consistent interface for all communication
TCPHTTPMSMQNamed PipesPeer-to-Peer
XML configuration to defineEndpoints, binding, behaviors, etc
Can use code behind instead of XML
ABCs of WCFA – Address
the location of the service and the transport protocol used to communicate with the service
B – BindingHow do I talk to the serviceBasic binding, TCP binding
C – Contracta platform-neutral and standard way of describing
what the service does
Examples of ABCs of WCFA – Address
net.tcp://localhost:8081/SpeakerServicehttp://localhost:49868/SpeakerService.svchttp://localhost:57402/TaPService.svc?wsdl
Examples of ABCs of WCFB – Binding
netTcpBinding netPeerTcpBinding basicHttpBinding (SOAP compatible)mexHttpBindingmexHttpsBindingnetNamedPipeBindingmsmqIntegrationBinding
Examples of ABCs of WCFC – Contract
[ServiceContract] public interface ISpeakerService {
[OperationContract] SpeakerInfo GetNextSpeaker();
[OperationContract] void AddSpeaker(SpeakerInfo newSpeaker);
[OperationContract] IEnumerable<SpeakerInfo> GetAllSpeakers();
}
Service Configuration EditorWindows SDK ToolsAllows editing of the app.config to add
services
demo
Service Configuration Editor (cont.)
WCF is just a Web Service?Web Services WCF
Asmx svc but can be treated like an asmx
HTTP and stateless Different hosting environments
(IIS, apps, services)
SOAP (http and xml) Binary or text data
XmlSerializer DataContractSerializer
Exceptions are SOAP faults Exceptions can be configured to be handed
back to the client
Hosting WCF ServicesWCF Services can be hosted in many
different things.IIS / Azure (ASP.NET project)AppsWindows Services
Using WCF for a SingletonWCF can also be used to implement the
Singleton patternYes it is overkill, but it will work
Demo
WCF as a Web ServiceHosted with IIS on a server or in the cloudASP.NET projects
Sync (default) or Async
Demo
WCF Goes RESTfulNuGet package from MS for WCF REST
services
Demo
WCF FuturesWeb API
http://wcf.codeplex.com/Way to configure wcf for web messaging, even
form postsSimplified setupNuget WebApi.All
Jquery SupportJSON