Service Model Programming Model
Only WCF Services can leverage AppFabric
Define service Host in AppFabric Test with WCF Test Client
Define service contract and entities Implement service Configure service Host in IIS & AppFabric Test with WCF Test Client
Host (IIS | AppFabric ) Service Configuration (web.config) Service Endpoint Address ( Binding(basicHttp) Service Contract (ICalculator) Host Service Implementation Service Contract Data Contract Service Endpoint (Address, Binding Contract) Service Behavior Key Service Concepts Service Contract (ICalculator) Operations (signatures) double Add(double a, double b) double GetArea(Rectangle r) Operations (signatures) double Add(double a, double b) double GetArea(Rectangle r) Service Implementation (MyCalc: ICalculator) Operations (implementation) double Add(double a, double b) double GetArea(Rectangle r) Operations (implementation) double Add(double a, double b) double GetArea(Rectangle r) Service Behaviors (Metadata) Data Contract Rectangle double width, double height Rectangle double width, double height
Create Client App Add Reference to Data Contract Assemblies (optional) Add Service Reference Instantiate Proxy Call Methods on Proxy
Proxy Endpoints Messages Service Instance Key Client Concepts Client Service Instance Proxy Instance (MyCalcClient) Client Configuration (app.config) Client Endpoint Address ( Binding(basicHttp) Service Contract (ICalculator) proxy.Add(5,2 ) Send Message Add(5,2) Receive Message 7
11
Tracked Events Normal Operation: ServiceHost events Aggregates for Operations Completed Calls Troubleshooting: Throttling Service Exceptions User Defined Errors Failed Calls Faulted Calls 14
15
16
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); myEventProvider.WriteEvent(ref errorDescriptor, title, serviceName, errorMessage); error event id's 301,302,303 mean error, warning, info respectively WCFUserEventProvider eventWriter = new WCFUserEventProvider(); eventWriter.WriteErrorEvent(“AddOperation”, “An error occurred.”);
Introducing WCF Services