Note: This blog post was created with AI assistance to help explain Uniface concepts clearly.
π What Are Session Services?
Session services in Uniface 10.4 are special components that handle task-specific behavior in the presentation tier of your application. Think of them as the middleman between what users see and what happens with your data.
π‘ A Simple Example
Imagine a user filling out a customer form on a web page. The user enters the information and clicks "Save". The session service is what actually processes that save operation behind the scenes. The web page just displays the form, but the session service does the real work.
π― What Can Session Services Do?
Session services are powerful tools that can handle several important tasks:
- Managing Referential Integrity and Transactions β They ensure your data relationships stay consistent and operations complete properly
- Implementing Business Logic β They can work with one or multiple entities to perform complex operations
- Exposing XML Record Sets β They provide disconnected XML data to client components
- Maintaining Conversational State β They keep track of server-side information during user sessions
βοΈ Technical Details Made Simple
π Stateless by Default
Session services are typically stateless, meaning they don't remember information between calls. However, Uniface provides special triggers that allow you to set and retrieve state information when needed.
π XML Data Exchange
When session services exchange data with other components, they use disconnected XML record sets. These XML structures are described by Document Type Definitions (DTDs). The good news? Uniface generates these DTDs automatically when you let Uniface create your session services.
π οΈ Creating a Session Service
Here's the interesting part: technically, there's almost no difference between a regular service and a session service. To create a session service, you simply:
- Create a regular Service component
- Change the Component Type property to 4 (Session Service)
- Set the value of the State Managed By property (
<$cmpStateManagedBy>
)
π Real-World Use Case
Let's say you're building an e-commerce application. A customer browses products on a Dynamic Server Page, adds items to their cart, and proceeds to checkout. Your session service would handle:
- Validating the cart contents
- Checking inventory availability
- Processing the payment transaction
- Updating multiple database tables (orders, inventory, customer history)
- Ensuring all changes happen together or not at all (transaction management)
The Dynamic Server Page shows the user interface, but the session service orchestrates all the business logic behind the scenes.
β Key Takeaways
- Session services separate presentation from business logic
- They're designed to be stateless but can manage state when needed
- They communicate using XML record sets
- They're easy to create from regular services with just a few property changes
- They're perfect for handling complex multi-entity operations
π― When to Use Session Services
Use session services when you need to:
- Keep your presentation layer clean and focused on display logic
- Implement complex business rules that involve multiple data entities
- Ensure data consistency across related operations
- Provide reusable business logic that multiple presentation components can call
Session services are a fundamental building block in Uniface applications, helping you create maintainable, scalable applications with clear separation of concerns. π
Top comments (0)