1 / 20

Introducing WCF Services

Introducing WCF Services. WCF. Programming Model. SOAP Services. 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

grace
Télécharger la présentation

Introducing WCF Services

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

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

More Related