dev386 best practices for.net smart clients and web services development marc ghys & bart...
DESCRIPTION
Smart clients & web services Overview Web Services SOAP over LAN SOAP over WAN (ADSL) SOAP over Internet BackofficeSOAPWinFormApplicationTRANSCRIPT
DEV386Best Practices for .NET Smart Clients and Web Services DevelopmentMarc Ghys & Bart Debeuckelaere.NET architects, Euricom
Agenda
Smart clients and web servicesCustom user controlsOffline business logicError handling over SOAPNo touch deploymentDemo of a real-life example
Smart clients & web servicesOverview
Web ServicesWeb Services
SOAP over LANSOAP over LAN
SOAP over WAN (ADSL)SOAP over WAN (ADSL)
SOAP over InternetSOAP over Internet
BackofficeBackofficeSOAPSOAPWinFormWinFormApplicationApplication
Smart clients & web services Performance
Design to performancePerformance ≠ ScalabilityFocus on user experience
Limit number of roundtripsDo web service calls when users expect it, e.g. not in the middle of a page in an OnLeave event
Cache data to the max in your winform clientCompress SOAP messages
I.I.S. compressionCustom compression
Use Windows Server 2003 !!!
Smart clients & web services Security
Windows built-in authentication mechanismBasicBasic over SSLDigestIntegrated Client certificates
SOAP headersCustom handling of authentication
WS-Security (new in WSE)Set authentication mode in web.config file
// Fragment of a Web.config file.<authentication mode= "Windows"></authentication>
Smart clients & web services Windows integrated authentication
Uses credentials of logged on userTransparent to user
myWebService.Credentials = System.Net.CredentialCache.DefaultCredentials;
Authentication bug causes repeated authentication roundtrips with every web service call in .NET framework 1.0
solved by QFExxxx
codeTableManager.Credentials = new System.Net.NetworkCredential(“Marc",“pwd");
Can also be set manually
Smart clients & web services Client certificates
Stronger Public Key cryptographyUses SSL 3.0 or TLS 1.0 protocolMany ways to manage access
X509Certificate x509 = X509Certificate.CreateFromCertFile(@"c:\Marc.cer");myPRoxy.ClientCertificates.Add(x509);
Get certificate from store (new in WSE)store = WSE.X509CertificateStore.LocalMachineStore(WSE.X509CertificateStore.MyStore);store.OpenRead();certificates = store.FindCertificateBySubjectString(“euricom"));
Get certificate from a file
Securing a web service• Using Windows integrated security• Using a client certificate
demodemo
Agenda
Smart clients and web servicesCustom user controlsOffline business logicError handling over SOAPNo touch deploymentDemo of a real-life example
Custom user controlsOverview
Easy to add extra functionalityTranslation, security
Force specific property valuesFont type & size, styling
Encapsulation of 3rd party controlsTransparent work-arounds for bugsRenaming properties & methods
3 possible approachesInherit, wrap or extend
Custom user controlsDeriving from an existing control
Fastest way to create a custom controlDerive from any existing control
All standard functionality immediately availableAutomatically reuses designer of inherited control
No real encapsulationDifficult to hide and/or rename properties and methodsVery difficult to create a custom designer
Custom user controlsDeriving from an existing control
No multiple inheritance in .NETImpossible to derive from a ‘basecontrol’ that contains shared functionality for a set of controls (e.g. validation, formatting, ...)
System.Windows.Forms.TextBox
Euricom.Toolkit.BaseControlEuricom.Toolkit.ListBox
Solution:instantiate BaseControl in the custom control and delegate properties, methods and events
Custom user controlsWrapping an existing control
User control derives from a ‘BaseControl’Contains generic properties, methods and events used by all custom controls
Reuse the functionality of an existing control by placing it on the user control
Expose control’s features by delegating properties, methods and eventsReuse of designer
Custom user controlsIssues with wrapping controls
Problem with delegating leave eventFires multiple times or not at allSolved in .NET framework 1.1
Performance issue in .NET framework 1.0Solved with QFExxxx
Custom user controlsUsing extenders
Loosely coupled way to add functionality to any existing control
Implement the IExtenderProvider interfaceBuilt-in tooltip control is an extender
Adds extra properties to existing controlsAt design-time, properties are added to the property windows of controlsAt run-time, properties are accessed through the extender
toolTipExtender.SetToolTip(txtFirstName, “Name of the person”);
Custom user controlsUsing GDI+ to draw your control
Gives you pixel-level control over how the control is shownOnPaint event provides GDI+ Graphics object
protected override void OnPaint(PaintEventArgs p){
// Draw border around controlp.Graphics.DrawRectangle(myPen, 0, 1, 300, 100);
}
Use Invalidate() to force redrawe.g. When a property has changed
Custom user controlsDesign-time support
Reuse and improve built-in designersE.g adding extra markers using GDI+ by overriding OnPaintAdornments()
Use TypeConverter class to improve generated code
e.g. show ‘subproperties’ by deriving from ExpandableObjectConverter
Creating custom controls• Wrapping an existing control• Using an extender• Inheriting an existing control• Drawing the control with GDI+• Using the TypeConverter class
demodemo
Agenda
Smart clients and web servicesCustom user controlsOffline business logicError handling over SOAPNo touch deploymentDemo of a real-life example
Treating offline situationsExecuting business logic offline
Need for business logic on the client E.g. validation of input data
Put shared business logic in BusinessRules class and deploy to clientBusinessObject class inherits from BusinessRule and adds persistence functionality
Treating offline situationsExecuting business logic offline
MyApp.BusinessRules.Customer
MyApp.BusinessObjects.Customer
Server Client
Data
MyApp.DataAccess.Customer
Customer.ValidateEmail([email protected]);
Agenda
Smart clients and web servicesCustom user controlsOffline business logicError handling over SOAPManaging stateNo touch deploymentDemo of a real-life example
Error handling over SOAPOverview
Standard Exception over SOAPLimited to one exception and standard properties
Returning serialized custom exceptionsCreate a custom exception classe.g. containing multiple ‘sub-exceptions’Throw a new SOAP exception and put serialized custom exception in XML node
Error handling over SOAPOverview
Using SOAP headers to transfer exceptions
Define SOAP header class containing CustomException propertyType can be anything (e.g. DataSet)Convert Exception data to CustomException type in WebService layer
Custom Exceptions• Using SOAP headers to send a
custom exception to a client
demodemo
Agenda
Smart clients and web servicesCustom user controlsOffline business logicError handling over SOAPNo-touch deploymentDemo of a real-life example
No-touch deploymentAppUpdater component
Three ways to check versionsDirect file check
Check on last modified dateManifest Check
XML web service checkWeb service not included in AppUpdater, has to be developed seperately
<VersionConfig><AvailableVersion>1.1.5.2</AvailableVersion><ApplicationUrl>http://appserver/crm/versions/V1152/</ApplicationUrl>
</VersionConfig>
No-touch deploymentAppUpdater component
Files are downloaded using HTTP-DAVIncludes directory and file enumeration
Free source downloadCan be adapted to your needs
No-touch deploymentCustom updater
Written from scratchFlexibility in features, coding style, etc...
Support for zone based deploymentDeploying a new version to 4.500 clients is not done in 5 minutes!Deploy to zones of 500 clients in different timeframesAssemblies are compressed and sent as DIME attachments using WSE
No-touch deploymentCustom updater
Peach.exePeach.exe Versions.xmlVersions.xml
Main formMain form
WithdrawalWithdrawal form form
InsuranceInsurance form form
Version 2.0.1.28Version 2.0.1.28
Get version info through web serviceGet version info through web service
Download new versionDownload new versionMain formMain form
WithdrawalWithdrawal form form
InsuranceInsurance form form
as DIME attchmentas DIME attchment
No-touch deploymentBITS
Downloads software in backgroundUsed by Windows 2000, Windows XP and Windows 2003 for autoupdate
Uses idle network bandwidthResumes after network disconects, reboots
Version 1.5 now available in Windows Server 2003, as upgrade for Win2000, XP
Download an updated assembly• As a DIME attachment using WSE• Using BITS
demodemo
Agenda
Smart clients and web servicesCustom user controlsOffline business logicError handling over SOAPNo touch deploymentDemo of a real-life example
Peach GUI Framework
Peach GUI FrameworkPeach GUI Framework
GUI ControlsGUI ControlsWizard ControlWizard Control
Error HandlingError HandlingTranslationTranslation
SecuritySecurityCachingCaching
ConfigurationConfiguration
PeachPeachTodayToday My OfficeMy Office CustomersCustomers InsuranceInsurance BankingBanking
MultipleMultipleapplication application
supportsupport
Peach GUI FrameworkAdvantages
Allows seperated development teams to develop independent plug-in applications
Framework handles inter-application communicationFramework can be improved seperately
Forces consistent look & feelForm & Wizard controlsQuickstep
Peach GUI FrameworkAdvantages
Provides numerous technical facilitiesError HandlingTranslationSecurityCaching
demodemo
Peach GUI framework
Community Resources
Community Resourceshttp://www.microsoft.com/communities/default.mspx
Most Valuable Professional (MVP)http://www.mvp.support.microsoft.com/
NewsgroupsConverse online with Microsoft Newsgroups, including Worldwidehttp://www.microsoft.com/communities/newsgroups/default.mspx
User GroupsMeet and learn with your peershttp://www.microsoft.com/communities/usergroups/default.mspx
evaluationsevaluations
© 2003 Microsoft Corporation. All rights reserved.© 2003 Microsoft Corporation. All rights reserved.This presentation is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS SUMMARY.This presentation is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS SUMMARY.