---
title: SimpleCertifiedMailServiceProxy
summary: API reference for SimpleCertifiedMailServiceProxy.
status: draft
owner: SAIF.Core Documentation Team
last_reviewed: 2026-09-24
library: SAIF.Services.Web.Proxies
reference_type: package
---

# SimpleCertifiedMailServiceProxy

`SimpleCertifiedMailServiceProxy` implements `ISimpleCertifiedMailServiceProxy` over the public generated `ADSAPISoapClient`, the only wrapper in this library that resolves both its endpoint and its fallback credentials from `IEnvironmentService` rather than taking a caller-supplied URL, and the only one that logs a domain-specific failure exception before raising it. It is constructor-injected into `SubpoenaLabelService` and `DocumentDeferredService`.

## Purpose
- Size a default certified-mail label by page count and reject requests over 76 pages ([WP-BR-015](../../business-rules.md#wp-br-015-default-label-size-is-set-by-page-count)).
- Resolve the SimpleCertifiedMail endpoint URL and any caller-omitted credentials (`UserName`, `Password`, `ClientCode`, `PartnerKey`) from `IEnvironmentService.GetConfigSetting` ([WP-BR-014](../../business-rules.md#wp-br-014-simplecertifiedmail-credentials-default-from-configuration)).
- Select `production` or `preview` mode from an explicit caller flag or `IEnvironmentService.IsProduction` ([WP-BR-019](../../business-rules.md#wp-br-019-label-mode-follows-the-caller-flag-or-isproduction)).
- Log and raise `SimpleCertifiedException` when the remote service returns a non-success status code ([WP-BR-018](../../business-rules.md#wp-br-018-a-failed-label-response-is-logged-and-thrown)).

## Context
- Namespace: `SAIF.Services.Web.Proxies`
- Assembly/package: `SAIF.Services.Web.Proxies` (packaged in `SAIF.SAIFCode.Core`)

## Public members
| Member | Signature | Purpose |
| --- | --- | --- |
| Constructor | `SimpleCertifiedMailServiceProxy(IEnvironmentService environmentService, ILogService logService)` | Guards both injected services, builds an HTTPS `BasicHttpBinding(Transport)` client, and reads the endpoint from `GetConfigSetting("SimpleCertifiedMailService.Url")` ([WP-BR-001](../../business-rules.md#wp-br-001-required-arguments-must-be-non-null-or-non-empty), [WP-BR-014](../../business-rules.md#wp-br-014-simplecertifiedmail-credentials-default-from-configuration)) |
| `GetDefaultLabelData` | `CertifiedLabelData GetDefaultLabelData(int numberOfPages)` | Returns default label data with envelope size determined by page count, throwing `InvalidNumberOfPagesException` for more than 76 pages ([WP-BR-015](../../business-rules.md#wp-br-015-default-label-size-is-set-by-page-count)) |
| `GetLabelOnly` | `CertifiedLabelData GetLabelOnly(CertifiedLabelData data)` | Requests a label from the remote service and discards the returned image ([WP-BR-016](../../business-rules.md#wp-br-016-getlabelonly-discards-the-label-image)) |
| `SaveLabelAsGif` | `void SaveLabelAsGif(CertifiedLabelData data, string fileName)` | Requests a label, Base64-decodes it, and saves it as `fileName + ".gif"`; does nothing if the label is null |
| `GetModeOption` | `ModeOptions GetModeOption(bool? isProductionMode)` | Resolves `production`/`preview` from the explicit flag, or from `IEnvironmentService.IsProduction` when the flag is null ([WP-BR-019](../../business-rules.md#wp-br-019-label-mode-follows-the-caller-flag-or-isproduction)) |
| `Dispose` | `void Dispose()` | Closes the underlying generated `ADSAPISoapClient` by calling `Close()`, without an `Abort()` fallback on a faulted channel* |

## Behavioral notes
- The private `GetCertifiedLabel` truncates `FromAddress1`, `FromAddress2`, and `ToName` to 46 characters before sending the request ([WP-BR-017](../../business-rules.md#wp-br-017-sender-address-and-recipient-name-are-truncated)).
- A non-`1` `StatusCode` in the wire response is logged via `ILogService.LogException("SimpleCertifiedMailService", "GetCertifiedLabel", "", ex)` and then raised as `SimpleCertifiedException` ([WP-BR-018](../../business-rules.md#wp-br-018-a-failed-label-response-is-logged-and-thrown)).
- Callers can bypass configuration entirely by supplying credentials directly on `CertifiedLabelData`; `DocumentDeferredService.cs` lines 112–114 do this, and when present these values take precedence over configuration.

## Constraints and usage notes
- Message-level `ClientCredentialType = Certificate` is set on the binding but has no effect in `Transport` security mode*.
- No Autofac registration for this class (via `ISimpleCertifiedMailServiceProxy`) exists anywhere in this repository; the composition root is external**.

> **Note:** Statements marked with * were inferred from code structure, naming conventions, or
> contextual evidence where direct confirmation was not available in source artifacts. Statements
> marked with ** could not be confirmed; treat as unknown until verified.

## Sources
- `Services/SAIF.Services.Web.Proxies/SimpleCertifiedMailServiceProxy.cs`
- `Services/SAIF.Services.Web.Proxies/ISimpleCertifiedMailServiceProxy.cs`
