150 likes | 267 Views
Intro to WCF From the beginning and uses. Steve Maier @YsFred4 http://strugglingthru.net/ steve.maier@gmail.com AppRochester. Before WCF. Sockets Named Pipes TCPIP HTTP MSMQ Everything had a different API that you had to learn. Switching from one to another was not simple.
E N D
Intro to WCF From the beginning and uses Steve Maier @YsFred4 http://strugglingthru.net/ steve.maier@gmail.com AppRochester
Before WCF • Sockets • Named Pipes • TCPIP • HTTP • MSMQ • 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 • TCP • HTTP • MSMQ • Named Pipes • Peer-to-Peer • XML configuration to define • Endpoints, binding, behaviors, etc • Can use code behind instead of XML
ABCs of WCF • A – Address • the location of the service and the transport protocol used to communicate with the service • B – Binding • How do I talk to the service • Basic binding, TCP binding • C – Contract • a platform-neutral and standard way of describing what the service does
Examples of ABCs of WCF • A – Address • net.tcp://localhost:8081/SpeakerService • http://localhost:49868/SpeakerService.svc • http://localhost:57402/TaPService.svc?wsdl
Examples of ABCs of WCF • B – Binding • netTcpBinding • netPeerTcpBinding • basicHttpBinding (SOAP compatible) • mexHttpBinding • mexHttpsBinding • netNamedPipeBinding • msmqIntegrationBinding
Examples of ABCs of WCF • C – Contract • [ServiceContract] publicinterfaceISpeakerService{ [OperationContract] SpeakerInfoGetNextSpeaker(); [OperationContract] voidAddSpeaker(SpeakerInfonewSpeaker); [OperationContract] IEnumerable<SpeakerInfo> GetAllSpeakers(); }
Service Configuration Editor • Windows SDK Tools • Allows editing of the app.config to add services • demo
Hosting WCF Services • WCF Services can be hosted in many different things. • IIS / Azure (ASP.NET project) • Apps • Windows Services
Using WCF for a Singleton • WCF can also be used to implement the Singleton pattern • Yes it is overkill, but it will work • Demo
WCF as a Web Service • Hosted with IIS on a server or in the cloud • ASP.NET projects • Sync (default) or Async • Demo
WCF Goes RESTful • NuGet package from MS for WCF REST services • Demo
WCF Futures • Web API • http://wcf.codeplex.com/ • Way to configure wcf for web messaging, even form posts • Simplified setup • NugetWebApi.All • Jquery Support • JSON