---
title: SAIF.Services.Printing architecture
summary: Architectural responsibilities, boundaries, and interaction patterns.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-07-24
library: SAIF.Services.Printing
reference_type: package
---

# SAIF.Services.Printing architecture

`SAIF.Services.Printing` separates report composition from transport concerns. `ReportBase` and `IReport` define the reusable report workflow, `XDesignXDocument` and `XDesignXElement` shape xPression payloads, `clsPrint` sends xPression print and distribution requests, and `clsRSPrint` renders SSRS reports through a separate SOAP endpoint.

## Responsibilities
- Encapsulate xPression document preview, print, and distribution calls.
- Encapsulate SSRS report preview and parameter submission.
- Provide a base report workflow that manages XML creation, file persistence, and error collection.
- Translate report XML into the xPression-specific element structure expected by downstream services.

## Component boundaries
- `Reporting.IReport`: public contract for report creation, rendering, printing, distribution, and saving.
- `Reporting.ReportBase`: reusable implementation of the `IReport` workflow that delegates transport work to `clsPrint`.
- `clsPrint`: xPression SOAP client wrapper with synchronous and transactional MSMQ-backed asynchronous distribution paths.
- `clsRSPrint`: SSRS `ReportExecutionService` wrapper for parameterized report rendering.
- `Reporting.XDesignXDocument` and `Reporting.XDesignXElement`: XML document and element wrappers that generate xPression-compatible markup.
- `Reporting.ErrorDetail`: error container returned through `IReport.Errors`.

## Interaction model
- Consumers populate `ReportBase`-derived reports, then call `Render`, `Print`, `Distribute`, or `Save` through the `IReport` surface.
- `ReportBase.Render` selects a default printer through `clsSecurityPrincipal`, then calls `clsPrint.previewDocument` with the current package, XML, and output profile.
- `clsPrint.distributeDocument` either invokes the xPression SOAP service directly or serializes a `CompositeRequestClass` message into MSMQ when `Asynchronous` is enabled.
- `clsRSPrint.PreviewDocument` loads the target SSRS report, applies any queued parameters, and renders the requested output format.

## Architecture diagram
The following diagram shows the main components and their runtime dependencies.

```mermaid
flowchart TD
    Consumer[Consumer or derived report class] --> IReport[IReport]
    IReport --> ReportBase[ReportBase]
    ReportBase --> XDoc[XDesignXDocument / XDesignXElement]
    ReportBase --> ClsPrint[clsPrint]
    Consumer --> ClsRSPrint[clsRSPrint]
    ClsPrint --> Xpresso[xPression SOAP service]
    ClsPrint --> MSMQ[MSMQ queue]
    ClsRSPrint --> SSRS[SSRS ReportExecutionService]
    ReportBase --> EnvSvc[EnvironmentServiceBase]
    ClsPrint --> EnvSvc
    ClsRSPrint --> EnvSvc
```

## Sequence diagram
The following diagram shows the asynchronous xPression distribution path.

```mermaid
sequenceDiagram
    participant Caller
    participant Report as ReportBase
    participant Print as clsPrint
    participant MQ as MessageQueue
    Caller->>Report: Distribute(overwrite)
    Report->>Print: distributeDocument(package, xml)
    alt Asynchronous = True
        Print->>Print: Build CompositeRequestClass
        Print->>MQ: Send transactional message
        MQ-->>Print: Message accepted
    else Asynchronous = False
        Print->>Print: Call xPression distributeDocument
    end
    Print-->>Report: Success or exception
    Report-->>Caller: Boolean result
```

## Design constraints
- The library depends on `EnvironmentServiceBase` to provide `documentGeneratorServiceUrl`, `documentMSMQPath`, `idmFilePath`, and `sqlReportingServiceUrl` before runtime operations can succeed.
- `clsRSPrint` supports preview and render operations only; `DistributeDocument` throws `NotImplementedException`.
- `ReportBase` succeeds only when a consumer supplies report XML and a report package name before render or distribution operations.

## Related documentation
- [Index](index.md)
- [Overview](overview.md)
- [Dependencies](dependencies.md)
- [Operations and processes](operations-processes.md)
- [Business rules](business-rules.md)
- [Configuration](configuration.md)
- [API reference](api/index.md)

## Sources
- `Services\SAIF.Services.Printing\clsPrint.vb`
- `Services\SAIF.Services.Printing\clsRSPrint.vb`
- `Services\SAIF.Services.Printing\Reporting\IReport.vb`
- `Services\SAIF.Services.Printing\Reporting\ReportBase.vb`
- `Services\SAIF.Services.Printing\Reporting\ErrorDetail.vb`
- `Services\SAIF.Services.Printing\Reporting\XDesignXDocument.vb`
- `Services\SAIF.Services.Printing\Reporting\XDesignXElement.vb`
