Christian Weyer Solution Architect thinktecture

Slides:



Advertisements
Similar presentations
Christian Weyer Solution Architect thinktecture
Advertisements

Michael S. Chan xLM Solutions, LLC
GETTING STARTED WITH WINDOWS COMMUNICATION FOUNDATION 4.5 Ed Jones & Grey Guindon.
System Operation Manager 2007 R2 im Überblick SESSION: I207 Walter Pitrof Technology Solution Professional Microsoft Switzerland
WCF Intro Scott Reed Owner - Brain Hz Software Instructor – DevelopMentor
Latest techniques and Applications in Interprocess Communication and Coordination Xiaoou Zhang.
Windows Communication Foundation and Web Services.
Laurent Bugnion Senior User Experience Developer IdentityMine.
Bernd Schneider Technical Solution Professional - BI Microsoft Schweiz.
Darryl Burling Developer Evangelist Microsoft The age of connected applications Whats new in VS2008 WCF Background: WS*,.Net 3.0 and WCF ABC’s & improvments.
Urs P. Küderli Principal Security Architect Microsoft.
The Microsoft Technical Roadshow 2006 Windows Communication Foundation Mike Taulty Developer & Platform Group Microsoft Ltd
Christian Binder Senior Platform Strategy Manager Microsoft.
Ronnie Saurenmann Microsoft Switzerland
Ingo Rammer thinktecture.
Getting Started with Windows Communication Foundation 4.5 Ed Jones, MCT, MCPD, MCTS Consultant RBA Inc.
Getting Started with WCF Windows Communication Foundation 4.0 Development Chapter 1.
Microsoft ® Official Course Monitoring and Troubleshooting Custom SharePoint Solutions SharePoint Practice Microsoft SharePoint 2013.
Christian Weyer thinktecture.
.NET, and Service Gateways Group members: Andre Tran, Priyanka Gangishetty, Irena Mao, Wileen Chiu.
Sascha P. Corti Developer Evangelist Microsoft Switzerland
Windows.Net Programming Series Preview. Course Schedule CourseDate Microsoft.Net Fundamentals 01/13/2014 Microsoft Windows/Web Fundamentals 01/20/2014.
Copyright ©2004 Virtusa Corporation | CONFIDENTIAL Introduction to Windows Communication Foundation Ruwan Wijesinghe.
[Title of the course] WCF
Christian Jäggli Principal Consultant Microsoft Corporation.
ESB Guidance 2.0 Kevin Gock
Doing Something Useful with Enterprise Library 3.0 Benjamin Day Level: Intermediate.
Module 14: WCF Send Adapters. Overview Lesson 1: Introduction to WCF Send Adapters Lesson 2: Consuming a Web Service Lesson 3: Consuming Services from.
Microsoft Visual Studio 2010 Muhammad Zubair MS (FAST-NU) Experience: 5+ Years Contact:- Cell#:
Brian Noyes Chief Architect IDesign Inc ( Session Code: SOA 305.
Tom Castiglia Hershey Technologies
Microsoft Visual Studio 2010 Muhammad Zubair MS (FAST-NU) Experience: 5+ Years Contact:- Cell#:
Intro to WCF From the beginning and uses Steve AppRochester.
11 Web Services. 22 Objectives You will be able to Say what a web service is. Write and deploy a simple web service. Test a simple web service. Write.
Christian Weyer Solution Architect thinktecture
Visual Studio 2008 and.NET 3.5 provide seamless support for all of the protocols and techniques popular in Web 2.0-style applications. Visual Studio.
Random Logic l Forum.NET l Web Services Enhancements for Microsoft.NET (WSE) Forum.NET ● October 4th, 2006.
Virtual techdays INDIA │ august 2010 Deep Dive into WCF 4.0 Features Sarath S S V S │ Program Manager, BING, Microsoft India R&D.
Mahesh Krishnan, Senior Consultant, Readify Slide 1.
Telerik Software Academy Web Services & Cloud.
2 Productive Windows Communication Foundation Jeremy Boyd Mindscape MSDN Regional Director – New Zealand SOA315.
Kemal Baykal Rasim Ismayilov
Configuring and Troubleshooting Identity and Access Solutions with Windows Server® 2008 Active Directory®
Ken Casada Developer Evangelist Microsoft Switzerland
Windows Communication Foundation David Anderson Independent Software Developer DCOM Productions.
Presentation 24: Windows Communication Foundation Introduced Objektorienteret Netværkskommunikation.
Agenda What Is the Windows Communication Foundation? How Does It Work? How Do I Use and Deploy It? Bindings Addresses Contracts How to host WCF services.
Satisfy Your Technical Curiosity Beyond ABC: WCF practices from the field Christian Weyer thinktecture Co-Founder & Solution Architect
.NET Mobile Application Development XML Web Services.
Dhananjay Kumar MVP-Connected System 1. WCF  Agenda What is WCF ? Why WCF? Address, Binding, Contract End Points Hosting Message Patterns Programming.
Christian Weyer thinktecture.
The SOAP Story Martin Parry Developer & Platform Group Microsoft Ltd
2 Microsoft Confidential3 The Microsoft Web Platform is the software of choice when building web solutions or applications for your business, large.
Justin Smith Technical Evangelist Microsoft Corporation CON301.
Integrating and Extending Workflow 8 AA301 Carl Sykes Ed Heaney.
Shani Raba Team Leader & Software Architect
OE-NIK HP Advanced Programming WCF WCF SOAP service, host, client Exception handling (NOT required)
BizTalk Damir Dobric Lead Architect. Agenda Microsoft BizTalk RFID Overview Architecture Application models Implementing Event Handlers Sensors.
Nati Dobkin
Microsoft Confidential Risman Adnan ISV Lead, Microsoft Indonesia
Windows Communication Foundation and Web Services
Introducing the Microsoft® .NET Framework
Windows Communication Foundation
Welcome POS Synchronize Concept 08 Sept 2015.
Windows Communication Foundation
Windows Communication Foundation and Web Services
Building real-time web apps with WebSockets using IIS, ASP.NET and WCF
The SOAP Story Martin Parry Developer & Platform Group Microsoft Ltd
WCF Data Services and Silverlight
Mark Quirk Head of Technology Developer & Platform Group
Presentation transcript:

Christian Weyer Solution Architect thinktecture

Support & consulting for Windows and.NET software developers and architects Developer coaching and mentoring Architecture consulting and prototyping Architecture and code reviews Application optimization, troubleshooting, debugging Focus on distributed applications, service orientation, workflows, cloud computing, interoperability, security, end-to-end solutions Windows Server, WCF, WF, MSMQ, Azure Services, Windows Azure

WCF is not just Web Services ! WCF is not always about SOA ! WCF does not stand for Web Services Consumption Foundation Windows Cool-SOA Foundation It is the Windows Communication Foundation ! 3

Consuming Hosting Bindings Quotas & throttles WSDL Performance & throughput Large data Tracing 4 Problems  Solutions/Tips  Samples

Contract modelling REST Security Asynchronous processing Fault handling Deep extensibility WF integration NATs & firewalls... and surely more... 5

Do I always need to create a proxy class from WSDL/MEX? How can I make consuming services more robust? Is there a way to improve performance when calling services? 6

For non-interop no need to use svcutil.exe or ‘Add Service Reference’ shared contracts approach works good in WCF-to- WCF scenarios ChannelFactory and DuplexChannelFactory are powerful means use custom interface extending service contract & IClientChannel Avoid using statement when dealing with proxies (ICommunicationObject-derived objects) can still throw at end of using block, e.g. for network errors explicit exception handling; can be dealt with e.g. in extension method 7

Try to cache proxy or ChannelFactory in high-throughput applications creating them can mean significant overhead ASP.NET client applications should not create ChannelFactory on each page call 8

9 interface IMyContractChannel : IMyContract, System.ServiceModel.IClientChannel {} ChannelFactory cf = new ChannelFactory (binding, address); IMyContractChannel client = cf.CreateChannel(); client.DoIt(…); client.Close(); try { … client.Close(); } catch (CommunicationException e) { … client.Abort(); } catch (TimeoutException e) { … client.Abort(); } catch (Exception e) { … client.Abort(); throw; } IMyContractChannel channel = ChannelFactoryManager.GetChannel("BasicHttpBinding"); Client side

Which host to use? IIS/WAS or a self-host? How do I inject logic in IIS/WAS hosting? 10

Use IIS/WAS for robust, highly scalable services beware of the process & AppDomain lifecycle features when using non-HTTP (TCP, Named Pipes, MSMQ) with WAS hosting AppDomain recycling still comes into your way Use self-hosting in Windows Service to have full control and light-weight hosting environment Custom ServiceHost & ServiceHostFactory implementations to provide custom initialization code hook up factory in.svc file for IIS/WAS 11

12 class MyServiceHost : System.ServiceModel.ServiceHost { public MyServiceHost(Type serviceType, params Uri[] baseAddresses) : base(serviceType, baseAddresses) {... } protected override void ApplyConfiguration() {... } class MyServiceHostFactory : System.ServiceModel.Activation.ServiceHostFactory { protected override ServiceHost CreateServiceHost( Type serviceType, Uri[] baseAddresses) { return new MyServiceHost(serviceType, baseAddresses); } Custom ServiceHost Custom ServiceHostFactory.svc file

My WCF service is slow, what is happening? I want to use HTTP but not necessarily angle brackets (aka ‚XML‘) How can I choose from the best communication options? 13

Beware of using the wrong bindings e.g. Visual Studio WCF wizards use WsHttpBinding (heavy with message security & session-based) only use features you really need Think about the real need for session-bound channels/bindings sessions change the game of fault and error handling use sessions when you need session semantics in your service But: sessions can give performance improvements e.g. security token hand-shake happens only once with SecureConversation 14

Custom bindings will save your day e.g. binary over HTTP often a good trade-off for WCF-to-WCF communication scenarios build custom binding in config or code Create user-defined binding for easier re- usage bake common custom binding setups into re- usable code and config implementations 15

16 <add name="netHttpBinding" type="NetHttpBindingCollectionElement, Thinktecture.ServiceModel, Version=…" /> public class NetHttpBinding : System.ServiceModels.Channels.Binding, ISecurityCapabilities { HttpTransportBindingElement httpTransport; HttpsTransportBindingElement httpsTransport; BinaryMessageEncodingBindingElement binaryEncoding; NetHttpSecurityMode securityMode;... } app/web.config User-defined binding

Beyond Hello World, all my services and consumers fail with strange exceptions My services do not perform the way they are supposed to How can I teach WCF to be less ‘conservative’ in closed Intranet environments? 17

Bindings adjust buffers, connection limits, timeouts Behaviors configure throttling service behavior Serializers check maximum items in object graph value Custom ChannelFactory and ServiceHost can automate all this e.g. through profiles 18 Defaults not true! SvcConfigEditor

19 app/web.config Consuming code

Some non-WCF consumers cannot understand the WSDL WCF produces My WSDL contains the wrong host name 20

Use custom extension to flatten WSDL into one file need to use same namespace values for ServiceContract, ServiceBehavior, BindingNamespace eliminates wsdl:import and xsd:import Register host headers in IIS to reflect names into WSDL for HTTP and HTTPS Specify different URIs for listening and exposing in WSDL Consider exposing a static WSDL which documents your published interface version 21

22.svc file applicationHost.config (IIS7)

My service eats a lot of memory and chokes the CPU when sending/receiving large data Bigger messages are making my communication really slow I have arbitrary, non-structured data to transfer 23

WCF supports MTOM for encoding binary data MTOM especially useful for interop Chunking channels available as SDK & community samples enables sending chunks of data instead of one single piece transparently works with different transports as a binding element 24

Consider using streaming for transfering abitrary data requires certain contract shape Stream Message Stream as single body in MessageContract works over any transport besides MSMQ works with transport and mixed-mode security still watch out for quotas powerful with web programming model 25

26 [ServiceContract] public interface IVideoPlayer { [OperationContract] [WebGet(UriTemplate = "videos/{videoID}")] [WebContentType(MimeType = "video/x-ms-wmv")] Stream Play(string videoID); } WebServiceHost webHost = new WebServiceHost( typeof(VideoPlayerService)); WebHttpBinding binding = new WebHttpBinding(); binding.TransferMode = TransferMode.Streamed; webHost.AddServiceEndpoint( typeof(IVideoPlayer), binding, " Service contract Host Client

Somehow my entire WCF-based application is ‚slow‘ Hosting my WCF service in IIS seems not to perform well under high load I cannot seem to get a high throughput when clients talk to my service via HTTP All that data is being transferred again and again, it makes my system slow 27

Configuring throttling can heal a lot (look there!).NET 3.5 SP1 provides asynchronous HTTP module & handler for hosting WCF in IIS for better behavior Client-side HTTP communication is limited to 2 concurrent connections to a server configurable through System.Net Cache, cache, cache! try to use caching intensively (but wisely) to save unnecessary round-trips 28

29 public List ListEpisodes() { IDataCache cache = DataCacheFactory.CreateInstance(); List episodes = cache.Get >(CacheConstants.AllEpisodes); if (episodes == null) { var episodeList = mediaLogic.ListAllEpisodes(); episodes = EpisodeDataMapper.MapAllEpisodes(episodeList); cache.Add(CacheConstants.AllEpisodes, episodes); } return episodes; } public interface IDataCache { void Add(string key, object cacheItem); TCacheItem Get (string key); void Remove(string key); } app/web.config E.g. service facade Caching lib

Use it! It can save your… If things go wrong and you have no clue why: trace! But do not overuse it when in production wrong usage can mean severe overhead Configured via config file can be manipulated via code, but only through WMI Did I already say tracing can save your …? 30

31 <add initializeData=„MyService_Trace.svclog" type="System.Diagnostics.XmlWriterTraceListener, …" name="ServiceModelTraceListener" traceOutputOptions="Timestamp" /> $ms = get-wmiobject -class "AppDomainInfo" -namespace "root\servicemodel" -computername "." | where {$_.Name -eq "MyWCFHost.exe"} $ms.TraceLevel = "Warning, ActivityTracing" $ms.Put() … app/web.config PS script app/web.config

Avoiding problems with the using statement Custom encoders aspx Tracing ms aspx ms aspx 32

Setting up IIS SSL host headers WindowsServer2003/Library/IIS/ 596b9108-b1a7-494d-885d-f8941b07554c.mspx 25/ssl-certificates-on-sites-with-host-headers.aspx baseAddressPrefixFilter bb aspx Chunking channel Release/ProjectReleases.aspx?ReleaseId=

Asynchronous WCF HTTP Module/Handler for IIS7 for Better Server Scalability /08/13/orcas-sp1-improvement- asynchronous-wcf-http-module-handler-for- iis7-for-better-server-scalability.aspx WCF bindings & more 34

We have code solutions for some WCF problems, for free of course Thinktecture.ServiceModel  Christian Weyer Weblog Christian Weyer thinktecture 35

In-depth support and consulting for software architects and developers {}

Presentations TechDays: MSDN Events: MSDN Webcasts: MSDN Events MSDN Events: Save the date: TechEd 2009 Europe, 9-13 November 2009, Berlinhttp:// MSDN Flash (our by weekly newsletter) Subscribe: MSDN Team Blog RSS: Developer User Groups & Communities Mobile Devices: Microsoft Solutions User Group Switzerland: Managed User Group of Switzerland: FoxPro User Group Switzerland:

Presentations TechDays: TechNet Events TechNet Events: Save the date: TechEd 2009 Europe, 9-13 November 2009, Berlinhttp://technet.microsoft.com/de-ch/bb aspx TechNet Flash (our by weekly newsletter) Subscribe: Schweizer IT Professional und TechNet Blog RSS: IT Professional User Groups & Communities SwissITPro User Group: NT Anwendergruppe Schweiz: PASS (Professional Association for SQL Server):

7. – 8. April 2010 Congress Center Basel

Classic Sponsoring Partners Media Partner Premium Sponsoring Partners