DEV332 Programming for the Middle Tier in Visual Basic.NET Billy Hollis Author / Consultant
Agenda Typical architectural elements in the middle tier Web Services basics (briefly) Windows services Performance counters Event logs Message queues
Typical Architecture Elements Web Service Façade Remoting Façade (Windows Service) Business rules (Operations with no connection) Data Access Layer (all connected operations) Message Queues Windows Services Remote Web Services
Designing Web Services Group related operations and data into one method Decide on: Interface and return data Security Use output caching to improve performance Define your input and output data structures using XSD schemas Separate XML Web service from underlying business logic
XML Web Services Mapping Data Schema Services InvocationWebXML XSD WSDL SOAP ApplicationConceptsFrameworkObjects Classes Methods Calls The.NET Framework provides a bi-directional mapping
Returning Data From An XML Web Service SQL Server Customers DataAdapter XML Web service DataSet IIS Oracle Orders XML DataSet Generic Client.NET Client DataAdapter
Data Web Services demo demo
Binary Data Web services are not limited to textual data – images, sound files, etc Return as bytes with Base64 stream Use WS-Attachments (DIME) Direct Internet Messaging Encapsulation Available using WSE toolkit or in Visual Studio.NET 2003 Can use over TCP, other protocols
Web Services vs. Remoting Web Services are easier to create and configure Web Services can be accessed by non.NET systems Remoting faster and easier to secure Remoting offers true exceptions Decision point – if you control both ends, remoting is usually the better choice
Creating A Windows Service Great for non-UI, long-running functionality Monitoring Scheduled Activity Remoting Host Respond to events Timer tick Message queue receive Directory/file change Event log write
Installing Windows Services Can run under different security context LocalSystem requires no login Install using command line utility installutil.exe [projectname.exe] Uninstall using installutil.exe /u [projectname.exe] Custom installer
Service Events Inherits from System.ServiceProcess.ServiceBase Override event methods: MethodBehavior OnStartSet action for when service is started (thirty seconds maximum!) OnPauseSet action for when service is paused OnStopSet action for when service is stopped OnContinueSet action for when service is resumed from pause OnShutDownSet action for when system is shutting down OnCustomCommandSet action for a custom command OnPowerEventSet action for low battery/suspend
Debugging Windows Services F5 debuggging not available Service must be deployed and installed Attach to the Service’s process Still set breakpoints for events Have all errors/exceptions logged to Windows Event Log
Creating Windows Services demo demo
Service Controller Service Controller class allows you to stop, start, pause or obtain information about windows services Namespace: System.ServiceProcess.ServiceController Can only communicate via custom numeric commands
Controlling Windows Services demo demo
Performance Counters Per Application Performance Counters Enable easily monitoring of individual applications Custom Performance Counters APIs Now possible to publish unique application- specific performance data Great for real-time application monitoring Example: total orders, orders/sec
Event Logs Indispensable in the middle tier Log errors and activity Drag and drop programming Can monitor event log with a Windows Service Take action Record event to database
Message Queue Enables you to connect to, monitor, send/receive/peek and administer message queues Loosely coupled programming MessageQueue Class Send/receive/peek messages in the queue Message Class Construct for the message Namespace: System.Messaging
Performance Counters and Message Queues demo demo
Ask The Experts Get Your Questions Answered Billy will be in the Ask the Experts booth Wednesday afternoon from 2:00 to 4:00
Community Resources Most Valuable Professional (MVP) Newsgroups Converse online with Microsoft Newsgroups, including Worldwide User Groups Meet and learn with your peers
evaluations evaluations
© 2003 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS SUMMARY.