dev386 best practices for.net smart clients and web services development marc ghys & bart...

40
DEV386 Best Practices for .NET Smart Clients and Web Services Development Marc Ghys & Bart Debeuckelaere .NET architects, Euricom

Upload: blanche-candace-reeves

Post on 17-Jan-2018

218 views

Category:

Documents


0 download

DESCRIPTION

Smart clients & web services Overview Web Services SOAP over LAN SOAP over WAN (ADSL) SOAP over Internet BackofficeSOAPWinFormApplication

TRANSCRIPT

Page 1: DEV386 Best Practices for.NET Smart Clients and Web Services Development Marc Ghys & Bart Debeuckelaere.NET architects, Euricom

DEV386Best Practices for .NET Smart Clients and Web Services DevelopmentMarc Ghys & Bart Debeuckelaere.NET architects, Euricom

Page 2: DEV386 Best Practices for.NET Smart Clients and Web Services Development Marc 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

Page 3: DEV386 Best Practices for.NET Smart Clients and Web Services Development Marc Ghys & Bart Debeuckelaere.NET architects, Euricom

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

Page 4: DEV386 Best Practices for.NET Smart Clients and Web Services Development Marc Ghys & Bart Debeuckelaere.NET architects, Euricom

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 !!!

Page 5: DEV386 Best Practices for.NET Smart Clients and Web Services Development Marc Ghys & Bart Debeuckelaere.NET architects, Euricom

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>

Page 6: DEV386 Best Practices for.NET Smart Clients and Web Services Development Marc Ghys & Bart Debeuckelaere.NET architects, Euricom

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

Page 7: DEV386 Best Practices for.NET Smart Clients and Web Services Development Marc Ghys & Bart Debeuckelaere.NET architects, Euricom

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

Page 8: DEV386 Best Practices for.NET Smart Clients and Web Services Development Marc Ghys & Bart Debeuckelaere.NET architects, Euricom

Securing a web service• Using Windows integrated security• Using a client certificate

demodemo

Page 9: DEV386 Best Practices for.NET Smart Clients and Web Services Development Marc 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

Page 10: DEV386 Best Practices for.NET Smart Clients and Web Services Development Marc Ghys & Bart Debeuckelaere.NET architects, Euricom

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

Page 11: DEV386 Best Practices for.NET Smart Clients and Web Services Development Marc Ghys & Bart Debeuckelaere.NET architects, Euricom

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

Page 12: DEV386 Best Practices for.NET Smart Clients and Web Services Development Marc Ghys & Bart Debeuckelaere.NET architects, Euricom

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

Page 13: DEV386 Best Practices for.NET Smart Clients and Web Services Development Marc Ghys & Bart Debeuckelaere.NET architects, Euricom

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

Page 14: DEV386 Best Practices for.NET Smart Clients and Web Services Development Marc Ghys & Bart Debeuckelaere.NET architects, Euricom

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

Page 15: DEV386 Best Practices for.NET Smart Clients and Web Services Development Marc Ghys & Bart Debeuckelaere.NET architects, Euricom

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”);

Page 16: DEV386 Best Practices for.NET Smart Clients and Web Services Development Marc Ghys & Bart Debeuckelaere.NET architects, Euricom

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

Page 17: DEV386 Best Practices for.NET Smart Clients and Web Services Development Marc Ghys & Bart Debeuckelaere.NET architects, Euricom

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

Page 18: DEV386 Best Practices for.NET Smart Clients and Web Services Development Marc Ghys & Bart Debeuckelaere.NET architects, Euricom

Creating custom controls• Wrapping an existing control• Using an extender• Inheriting an existing control• Drawing the control with GDI+• Using the TypeConverter class

demodemo

Page 19: DEV386 Best Practices for.NET Smart Clients and Web Services Development Marc 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

Page 20: DEV386 Best Practices for.NET Smart Clients and Web Services Development Marc Ghys & Bart Debeuckelaere.NET architects, Euricom

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

Page 21: DEV386 Best Practices for.NET Smart Clients and Web Services Development Marc Ghys & Bart Debeuckelaere.NET architects, Euricom

Treating offline situationsExecuting business logic offline

MyApp.BusinessRules.Customer

MyApp.BusinessObjects.Customer

Server Client

Data

MyApp.DataAccess.Customer

Customer.ValidateEmail([email protected]);

Page 22: DEV386 Best Practices for.NET Smart Clients and Web Services Development Marc Ghys & Bart Debeuckelaere.NET architects, Euricom

Agenda

Smart clients and web servicesCustom user controlsOffline business logicError handling over SOAPManaging stateNo touch deploymentDemo of a real-life example

Page 23: DEV386 Best Practices for.NET Smart Clients and Web Services Development Marc Ghys & Bart Debeuckelaere.NET architects, Euricom

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

Page 24: DEV386 Best Practices for.NET Smart Clients and Web Services Development Marc Ghys & Bart Debeuckelaere.NET architects, Euricom

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

Page 25: DEV386 Best Practices for.NET Smart Clients and Web Services Development Marc Ghys & Bart Debeuckelaere.NET architects, Euricom

Custom Exceptions• Using SOAP headers to send a

custom exception to a client

demodemo

Page 26: DEV386 Best Practices for.NET Smart Clients and Web Services Development Marc 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

Page 27: DEV386 Best Practices for.NET Smart Clients and Web Services Development Marc Ghys & Bart Debeuckelaere.NET architects, Euricom

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>

Page 28: DEV386 Best Practices for.NET Smart Clients and Web Services Development Marc Ghys & Bart Debeuckelaere.NET architects, Euricom

No-touch deploymentAppUpdater component

Files are downloaded using HTTP-DAVIncludes directory and file enumeration

Free source downloadCan be adapted to your needs

Page 29: DEV386 Best Practices for.NET Smart Clients and Web Services Development Marc Ghys & Bart Debeuckelaere.NET architects, Euricom

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

Page 30: DEV386 Best Practices for.NET Smart Clients and Web Services Development Marc Ghys & Bart Debeuckelaere.NET architects, Euricom

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

Page 31: DEV386 Best Practices for.NET Smart Clients and Web Services Development Marc Ghys & Bart Debeuckelaere.NET architects, Euricom

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

Page 32: DEV386 Best Practices for.NET Smart Clients and Web Services Development Marc Ghys & Bart Debeuckelaere.NET architects, Euricom

Download an updated assembly• As a DIME attachment using WSE• Using BITS

demodemo

Page 33: DEV386 Best Practices for.NET Smart Clients and Web Services Development Marc 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

Page 34: DEV386 Best Practices for.NET Smart Clients and Web Services Development Marc Ghys & Bart Debeuckelaere.NET architects, Euricom

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

Page 35: DEV386 Best Practices for.NET Smart Clients and Web Services Development Marc Ghys & Bart Debeuckelaere.NET architects, Euricom

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

Page 36: DEV386 Best Practices for.NET Smart Clients and Web Services Development Marc Ghys & Bart Debeuckelaere.NET architects, Euricom

Peach GUI FrameworkAdvantages

Provides numerous technical facilitiesError HandlingTranslationSecurityCaching

Page 37: DEV386 Best Practices for.NET Smart Clients and Web Services Development Marc Ghys & Bart Debeuckelaere.NET architects, Euricom

demodemo

Peach GUI framework

Page 38: DEV386 Best Practices for.NET Smart Clients and Web Services Development Marc Ghys & Bart Debeuckelaere.NET architects, Euricom

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

Page 39: DEV386 Best Practices for.NET Smart Clients and Web Services Development Marc Ghys & Bart Debeuckelaere.NET architects, Euricom

evaluationsevaluations

Page 40: DEV386 Best Practices for.NET Smart Clients and Web Services Development Marc Ghys & Bart Debeuckelaere.NET architects, Euricom

© 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.