introducing wcf services l.
Skip this Video
Loading SlideShow in 5 Seconds..
Introducing WCF Services PowerPoint Presentation
Download Presentation
Introducing WCF Services

play fullscreen
1 / 20
Download Presentation

Introducing WCF Services - PowerPoint PPT Presentation

grace
179 Views
Download Presentation

Introducing WCF Services

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Introducing WCF Services

  2. WCF Programming Model SOAPServices Workflow Services Web HTTP Services Data Services RIA Services Service Model Data Contract Service Contract Service Behavior Channel Model Formats (Atom, JSON, XML,…) Transports (HTTP, TCP, …) Protocols (SOAP, HTTP, Open Data Protocol,…)

  3. WCF is the way to build services on the .NET Framework ASMX is limiting WCF is powerful • HTTP-only hosting in IIS • Tightly coupled implementation & interface • No support for security, guaranteed delivery, transactions, binary serialization • Advanced scenarios require mixing models • highly configurable and highly extensible • supports what ASMX cannot • supports a unified programming model across all protocols ASMX is at the end of what it can do with “HelloWorld” WCF 4 makes “HelloWorld” easy & extends to other scenarios Only WCF Services can leverage AppFabric

  4. Creating the ASMX-Equivalent WCF SOAP Service

  5. Creating the “Typical” WCF SOAP Service

  6. Host (IIS | AppFabric) Service Implementation (MyCalc: ICalculator) Key Service Concepts Data Contract Service Contract (ICalculator) Operations (implementation) double Add(double a, double b) double GetArea(Rectangle r) Operations (signatures) double Add(double a, double b) double GetArea(Rectangle r) Rectangle double width, double height • Host • Service Implementation • Service Contract • Data Contract • Service Endpoint (Address, Binding Contract) • Service Behavior Service Configuration (web.config) Service Behaviors (Metadata) Service Endpoint Address (http://localhost/MyCalc.svc) Binding(basicHttp) Service Contract (ICalculator)

  7. Creating the “TYPICAL” WCF Service

  8. Key WCF 4 Configuration Features • File-Less (Config Based) Activation <serviceActivations> <add relativeAddress="Calculator.svc" service="Microsoft.ServiceModel.Samples.CalculatorService" /> <serviceActivations> • Inheritance Model for Configuration • Default Protocol Mapping <protocolMapping> <add scheme="http" binding="wsHttpBinding" /> </protocolMapping>

  9. Creating the “Typical” Client

  10. Key Client Concepts Client Proxy Instance (MyCalcClient) proxy.Add(5,2) Client Configuration (app.config) Client Endpoint • Proxy • Endpoints • Messages • Service Instance Address (http://localhost/MyCalc.svc) Binding(basicHttp) Service Contract (ICalculator) Send Message Receive Message 7 Add(5,2) Service Instance

  11. Best Practice Proxy Use CalculatorClient proxy = new CalculatorClient(); Try { proxy.Add(1,5); proxy.Close(); } Catch (Exception ex) { proxy.Abort(); throw; }

  12. Creating the "Typical" WCF Client in ASP.NET

  13. AppFabric Dashboard – WCF Call History

  14. Tracked Events Normal Operation: ServiceHost events Aggregates for Operations Completed Calls Troubleshooting:Throttling Service Exceptions User Defined Errors Failed Calls Faulted Calls

  15. Endpoint Management

  16. Service Management

  17. Using AppFabric to Monitor WCF Services

  18. Emitting User Defined Errors DiagnosticSection config = (DiagnosticSection) WebConfigurationManager.GetSection("system.serviceModel/diagnostics"); providerId = new Guid(config.EtwProviderId); myEventProvider = new EventProvider(providerId); errorDescriptor = new EventDescriptor(ErrorEventId, Version, Channel, ErrorLevel, Opcode, Task, Keywords); error event id's 301,302,303 mean error, warning, info respectively myEventProvider.WriteEvent(ref errorDescriptor, title, serviceName, errorMessage); WCFUserEventProvider eventWriter = new WCFUserEventProvider();eventWriter.WriteErrorEvent(“AddOperation”, “An error occurred.”); Get the ETW Provider ID Create a new Event Provider for that ID Define an event descriptor Write the event We provide a sample that encapsulates all this into just:

  19. Using AppFabric to Monitor WCF Services

  20. Lab 2 • Introducing WCF Services