15
Intro to WCF From the beginning and uses Steve Maier @YsFred4 http://strugglingthru.net/ [email protected] AppRochester

Intro to WCF From the beginning and uses Steve Maier @YsFred4 [email protected] AppRochester

Embed Size (px)

Citation preview

Page 1: Intro to WCF From the beginning and uses Steve Maier @YsFred4  steve.maier@gmail.com AppRochester

Intro to WCFFrom the beginning and uses

Steve Maier@YsFred4http://strugglingthru.net/[email protected]

Page 2: Intro to WCF From the beginning and uses Steve Maier @YsFred4  steve.maier@gmail.com AppRochester

Before WCFSocketsNamed PipesTCPIPHTTPMSMQ

Everything had a different API that you had to learn.

Switching from one to another was not simple.

Page 3: Intro to WCF From the beginning and uses Steve Maier @YsFred4  steve.maier@gmail.com AppRochester

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

Page 4: Intro to WCF From the beginning and uses Steve Maier @YsFred4  steve.maier@gmail.com AppRochester

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

Page 5: Intro to WCF From the beginning and uses Steve Maier @YsFred4  steve.maier@gmail.com AppRochester

Examples of ABCs of WCFA – Address

net.tcp://localhost:8081/SpeakerServicehttp://localhost:49868/SpeakerService.svchttp://localhost:57402/TaPService.svc?wsdl

Page 6: Intro to WCF From the beginning and uses Steve Maier @YsFred4  steve.maier@gmail.com AppRochester

Examples of ABCs of WCFB – Binding

netTcpBinding netPeerTcpBinding basicHttpBinding (SOAP compatible)mexHttpBindingmexHttpsBindingnetNamedPipeBindingmsmqIntegrationBinding

Page 7: Intro to WCF From the beginning and uses Steve Maier @YsFred4  steve.maier@gmail.com AppRochester

Examples of ABCs of WCFC – Contract

[ServiceContract]     public interface ISpeakerService     {         

[OperationContract]         SpeakerInfo GetNextSpeaker();         

[OperationContract]         void AddSpeaker(SpeakerInfo newSpeaker);         

[OperationContract]         IEnumerable<SpeakerInfo> GetAllSpeakers();     

}

Page 8: Intro to WCF From the beginning and uses Steve Maier @YsFred4  steve.maier@gmail.com AppRochester

Service Configuration EditorWindows SDK ToolsAllows editing of the app.config to add

services

demo

Page 9: Intro to WCF From the beginning and uses Steve Maier @YsFred4  steve.maier@gmail.com AppRochester

Service Configuration Editor (cont.)

Page 10: Intro to WCF From the beginning and uses Steve Maier @YsFred4  steve.maier@gmail.com AppRochester

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

Page 11: Intro to WCF From the beginning and uses Steve Maier @YsFred4  steve.maier@gmail.com AppRochester

Hosting WCF ServicesWCF Services can be hosted in many

different things.IIS / Azure (ASP.NET project)AppsWindows Services

Page 12: Intro to WCF From the beginning and uses Steve Maier @YsFred4  steve.maier@gmail.com AppRochester

Using WCF for a SingletonWCF can also be used to implement the

Singleton patternYes it is overkill, but it will work

Demo

Page 13: Intro to WCF From the beginning and uses Steve Maier @YsFred4  steve.maier@gmail.com AppRochester

WCF as a Web ServiceHosted with IIS on a server or in the cloudASP.NET projects

Sync (default) or Async

Demo

Page 14: Intro to WCF From the beginning and uses Steve Maier @YsFred4  steve.maier@gmail.com AppRochester

WCF Goes RESTfulNuGet package from MS for WCF REST

services

Demo

Page 15: Intro to WCF From the beginning and uses Steve Maier @YsFred4  steve.maier@gmail.com AppRochester

WCF FuturesWeb API

http://wcf.codeplex.com/Way to configure wcf for web messaging, even

form postsSimplified setupNuget WebApi.All

Jquery SupportJSON